Nette Documentation Preview

syntax
Upgrading
*********


Upgrading to Version 3.0
========================

Nette 3.0 adds type hints to method parameters and return values. If you override such a method in a class inheriting from Nette (for example in a presenter or component), you must add the same type hints, otherwise PHP raises a "Declaration must be compatible" error. 

The `Nette\Application\IRouter` interface has changed. The `match()` method now returns, and `constructUrl()` accepts, an array of parameters instead of a `Nette\Application\Request` object.

Nette now checks that each signal is sent from the same origin (i.e. the same domain and subdomain). This same-origin policy is a critical security mechanism that helps reduce possible attack vectors. If you want to allow other origins, add the `@crossOrigin` annotation to the handler method:

```php
/**
 * @crossOrigin
 */
public function handleXy(): void
{
}
```

This also applies to form submissions. If you want to allow submission from other origins, do it this way:

```php
$form = new Nette\Application\UI\Form;
$form->allowCrossOrigin();
```

The constructor of `Nette\ComponentModel\Component` has not been used for years and was removed in version 3.0. It is a BC break: if you call the parent constructor in a component or presenter inheriting from `Nette\Application\UI\Presenter`, you must remove the call.


Upgrading to Version 2.4
========================

- `Route` and `SimpleRouter` now generate the same HTTP/HTTPS scheme that was used to access the site. A route that requires a specific protocol can be defined with the scheme, e.g. `Route('http://domain.cz/<presenter>')`.
- For bool-type parameters of render/action methods (i.e. with a default value of true or false) and for persistent parameters, `false` and `null` are now distinguished. If the parameter is not present in the URL, its value is now `null` (previously `false`).
- The class returned by `Presenter::getReflection()` is no longer a descendant of `Nette\Reflection\ClassType`, and `getReflection()->getMethod()` is no longer a descendant of `Nette\Reflection\Method`.
- The `SECURED` flag and `Route::$defaultFlags` are deprecated.


Upgrading to Version 2.3
========================

- routes and presenter names are **case-sensitive**. Nette warns you if you use the wrong case in a presenter name; for performance reasons the Route mask is not checked, so verify it manually.
- `Route::addStyle()` and `Route::setStyleProperty()` are deprecated and now trigger `E_USER_DEPRECATED`.
- the template extension `.phtml` and the old link syntax are no longer supported.

Upgrading

Upgrading to Version 3.0

Nette 3.0 adds type hints to method parameters and return values. If you override such a method in a class inheriting from Nette (for example in a presenter or component), you must add the same type hints, otherwise PHP raises a „Declaration must be compatible“ error.

The Nette\Application\IRouter interface has changed. The match() method now returns, and constructUrl() accepts, an array of parameters instead of a Nette\Application\Request object.

Nette now checks that each signal is sent from the same origin (i.e. the same domain and subdomain). This same-origin policy is a critical security mechanism that helps reduce possible attack vectors. If you want to allow other origins, add the @crossOrigin annotation to the handler method:

/**
 * @crossOrigin
 */
public function handleXy(): void
{
}

This also applies to form submissions. If you want to allow submission from other origins, do it this way:

$form = new Nette\Application\UI\Form;
$form->allowCrossOrigin();

The constructor of Nette\ComponentModel\Component has not been used for years and was removed in version 3.0. It is a BC break: if you call the parent constructor in a component or presenter inheriting from Nette\Application\UI\Presenter, you must remove the call.

Upgrading to Version 2.4

  • Route and SimpleRouter now generate the same HTTP/HTTPS scheme that was used to access the site. A route that requires a specific protocol can be defined with the scheme, e.g. Route('http://domain.cz/<presenter>').
  • For bool-type parameters of render/action methods (i.e. with a default value of true or false) and for persistent parameters, false and null are now distinguished. If the parameter is not present in the URL, its value is now null (previously false).
  • The class returned by Presenter::getReflection() is no longer a descendant of Nette\Reflection\ClassType, and getReflection()->getMethod() is no longer a descendant of Nette\Reflection\Method.
  • The SECURED flag and Route::$defaultFlags are deprecated.

Upgrading to Version 2.3

  • routes and presenter names are case-sensitive. Nette warns you if you use the wrong case in a presenter name; for performance reasons the Route mask is not checked, so verify it manually.
  • Route::addStyle() and Route::setStyleProperty() are deprecated and now trigger E_USER_DEPRECATED.
  • the template extension .phtml and the old link syntax are no longer supported.