Upgrading

Upgrading to Version 4.0

The minimum required PHP version is 8.0.

The Nette\Utils\Reflection class provided the methods getParameterType(), getPropertyType(), and getReturnType() for working with types. These methods were created when PHP didn't have union, intersection, or the newest disjunctive normal form types, with which they no longer work correctly. They have been replaced by the Type class. As of version 4.0, these methods have been removed.

The variable Nette\Utils\Html::$xhtml has been removed.

Flags in some methods have been replaced by named arguments. The original notation still works, but is no longer preferred: Json::PRETTYpretty:, Json::ESCAPE_UNICODEasciiSafe:, Json::FORCE_ARRAYforceArrays:, PREG_GREP_INVERT in Arrays::grep()invert:, Image::SHRINK_ONLY in Image::resize()shrinkOnly:, and the PREG_* flags in Strings::split(), match() and matchAll().

The method Nette\Utils\Reflection::getParameterDefaultValue() is deprecated, because the native ReflectionParameter::getDefaultValue() already works correctly.

If you use RobotLoader, update it to version 4 as well.

Finder

Finder has moved to the nette/utils package. Remove the original nette/finder package:

composer remove nette/finder

On Linux, Finder now operates in case-sensitive mode by default.

In the previous version, the exclude() and filter() methods behaved differently depending on whether they were called before or after from() or in(). This is no longer the case; exclude() and filter() always function the same way. The behavior of filter() called after from()/in() is now handled by the new method descentFilter().

Finder no longer implements the Countable interface.

A string starting with a slash in Finder::findFiles('/f*') is now considered an absolute path. If you intended a relative path from the current directory, replace it with, for example, Finder::findFiles('./f*').

If a directory you are searching in does not exist, Nette\InvalidStateException is thrown (instead of the previous UnexpectedValueException).

What else the rewritten Finder can do is described in the article Finder 4.0: 10 years of experience under the hood.

Upgrading to Version 3.1

  • Nette\Utils\Arrays::searchKey() was renamed to getKeyOffset()
  • Nette\Utils\Callback::closure() is deprecated in favor of Closure::fromCallable()
  • Nette\Utils\Reflection::toString() appends () after the function/method name
  • Nette\Utils\Strings::toAscii() triggers a notice when ext-intl is not present

Upgrading to Version 3.0

The Nette\Localization\ITranslator interface has changed.

Nette\Object is deprecated since Nette 2.4 and was removed in Nette 3.0, but it still exists under the new name Nette\LegacyObject (the name object cannot be used since PHP 7.1) in the nette/deprecated package.

Upgrading to Version 2.4

Framework classes now use the Nette\SmartObject trait instead of inheriting from Nette\Object, which differs in several cases:

  • it supports “emulated properties” only when the annotation @property type $name is present
  • it does not support “extension methods”
  • it does not support “getReflection”
  • it does not support obtaining methods such as $this->formSubmitted; use a classic PHP callback [$this, 'formSubmitted'] instead

The Nette\Utils\Html::add() method was replaced by addHtml() and addText().

Upgrading to Version 2.3

  • Image::from() throws ImageException when it is unable to decode the file
  • Image::getFormatFromString() is deprecated
  • Strings::chr() and normalize() now work only with UTF-8 encoding
  • Strings::chr() throws Nette\InvalidArgumentException if the code point is not in the valid range
version: 4.x 3.x