Statistics
9309438
806
15
23d
Badges
Tags
nette
Dependencies
  • php (>=7.1)

Nette Utility Classes

Downloads this Month Build Status Coverage Status Latest Stable Version License

Introduction

In package nette/utils you will find a set of useful classes for everyday use:

Documentation can be found on the website.

Installation

The recommended way to install is via Composer:

composer require nette/utils

It requires PHP version 7.1 and supports PHP up to 7.3.

  • v3.0.1 Released version 3.0.1

    • Reflection::getUseStatements() throw exceptions on anonymous class
    • Reflection: added 'null' to builtin types (in fact it is reserved type since PHP 7.0)
    • added Reflection::getPropertyType() (for PHP 7.4)
    • Validators: better exception message
    • Validators: added 'file', 'directory', 'class', 'interface' & mixed
    • Validators: added support for ?nullable types
    • Validators: grouped & sorted $validators
    • Validators: catches TypeError for incompatible types
    • Validator:: accepts the plus character as a valid option in numeric strings (#184)
    • added Arrays::toObject()
    • Image: fixed empty error_get_last() #183

    For the details you can have a look at the diff.

  • v3.0.0 Released version 3.0.0 🎉

    • requires PHP 7.1
    • uses declare(strict_types=1)
    • uses PHP 7.1 scalar and return type hints
    • Object, ObjectMixin: silently marked as deprecated
    • added PhpStorm metadata for autocompletion

    Changes

    • Strings::before(), after(), indexOf() and pos() return NULL instead of FALSE if the needle was not found
    • Arrays::searchKey() returns NULL instead of FALSE when item is not found
    • Image::save() and send() throws ImageException on failure (BC break)
    • Validators::assertField: first argument has type hint array
    • Callback::toReflection() removed support for Nette\Reflection
    • some classes & members marked as final
    • ITranslator: allow multiple parameters for translated messages (#178)
    • deprecated ObjectMixin::getSuggestion()
    • MemberAccessException extends from Error (BC break)
    • removed StaticClassException, StaticClass throws Error
    • Image::save() $file cannot be null, added output()
    • DateTime: removed setTimestamp() and getTimestamp(), big int are supported in x64 PHP versions
    • Strings::findPrefix accepts only string[] (BC break)
    • Removed Nette\Object & ObjectMixin (BC break)
    • Callback::invoke() and invokeArgs() are deprecated in favor of native invocation
    • Callback: deprecated closure()
    • Validators::everyIs: first argument has typehint iterable (BC break)
    • Strings::normalize() a compare() dependency on Normalizer is optional
    • Strings::normalize() a compare() normalize strings into UTF-8 NFC (#150)
    • Filesystem::write() accept NULL in $mode parameter (#139)
  • v2.5.3 Released version 2.5.3

    • Callback: removes HTML from error message nette/mail#54
    • test: fixed compatiblity with PHP 7.3
    • Callback: fixed bug in is_callable($object, true) #176
    • Reflection: token_get_all() uses flag TOKEN_PARSE
    • FileSystem: better error messages

    For the details you can have a look at the diff.

  • v2.4.10 Released version 2.4.10

    This release marks the end of life of the nette/utils 2.4 series

    • Callback: removes HTML from error message nette/mail#54
    • test: fixed compatiblity with PHP 7.3
    • Callback: fixed bug in is_callable($object, true) #176
    • SmartObject: better error message

    For the details you can have a look at the diff.

  • v2.5.2 Released version 2.5.2

    • SmartObject: better error message
    • Image: throw exception when $file and $type is null (#170)

    For the details you can have a look at the diff.

  • v2.5.0 Released version 2.5.0

    • deprecated Nette\Object renamed to Nette\LegacyObject (to avoid fatal error in PHP 7.2)
    • usage of Nette\Object triggers notice or exception
    • removed stuff deprecated in v2.4
  • v2.4.9 Released version 2.4.9

    • FileSystem::rename() fix renaming file/directory if only case changes (#155)
    • Added Html::removeAttributes() - removing multiple attributes (#161)
    • Reflection::getParameterDefaultValue: fix constant visibility handling (php 7.1) (#156)
    • PHPStan: fixed some issues
    • Object, ObjectMixin: silently marked as deprecated

    For the details you can have a look at the diff.

  • v2.4.8 Released version 2.4.8

    • Html: accepts IHtmlString nette/forms#160
    • Html::addText() accepts Html as setText() does
    • Reflection: added support for PHP 7.2 type 'object'
    • ArrayList: triggers notice when indexes are not integers
    • travis: compatible with PHP 7.2

    For the details you can have a look at the diff.

  • v2.4.7 Released version 2.4.7

    • coding style: fixes, lowercase true/false/null
    • Image: attempt to serialize throws exception

    For the details you can have a look at the diff.

  • v2.4.6 Released version 2.4.6

    • Validators::isInRange() works with DateTime
    • Validators::isInRange() return FALSE when both limits are NULL

    For the details you can have a look at the diff.

  • v2.4.5 Released version 2.4.5

    • supports PHP up to 7.2
    • Validators::isInRange() compares strings as strings and numbers as numbers (BC break) nette/forms#146
    • Validators::isInRange() ignores NULL
    • Reflection::getReturnType() & getParameterType() supports 'parent'
    • Callback: workaround for Suhosin extension bug (#134)
    • each() replaced with current() and next()

    For the details you can have a look at the diff.

  • v2.4.4 Released version 2.4.4

    For the details you can have a look at the diff.

  • v2.4.2 Released version 2.4.2

    • added DateTime::fromParts()
    • DateTime::from() supports microseconds
    • Image: added support for WEBP #73
    • added Arrays::every(), some() & map() #36
    • Validators: support for types int[], string[] etc #119
    • added Validators::everyIs() #123
    • Validators: added validator 'iterable'
    • SmartObject: better exception message for deprecated property usage
    • Json skips workaround on PHP 7.0+
    • @return self -> static

    For the details you can have a look at the diff.

  • v2.3.11 Released version 2.3.11

    This release marks the end of life of the nette/utils 2.3 series

    • FileSystem: added read() (#124)
    • FileSystem: fix mkdir race condition (#120)
    • Image: fix conversion of percentage arguments to numeric values (#122)
    • fixed compatibility with PHP 7.1
    • @return self -> static

    For the details you can have a look at the diff.

  • v2.4.1 Released version 2.4.1

    • SmartObject: added support for annotations in traits (thx @matej21) #121
    • FileSystem: fix mkdir race condition (#120)
    • fixed compatibility with PHP 7.1

    For the details you can have a look at the diff.

  • v2.4.0 Released version 2.4.0

    • requires PHP 5.6
    • added trait Nette\SmartObject, it differs from Nette\Object:
      • magic properties without @Property annotation are deprecated
      • accessing methods as properties is deprecated
      • extension methods are deprecated
      • magic @methods are deprecated
      • getReflection is deprecated
      • invoking closure in property is deprecated
    • added trait Nette\StaticClass
    • Html: renamed add() to addHtml(); added addText() (#111)
    • Html: deprecated "expanded" attribute data
    • Html: added attribute public accessor methods
    • Image::place() preserves the alpha channel
    • Strings::random() renamed to Random::generate()
    • Random: uses random_bytes() on PHP 7
    • FileSystem: added read()
    • ArrayList: added prepend()
    • Json::encode() uses by default JSON_PRESERVE_ZERO_FRACTION (BC break) #89
    • DateTime: implements JsonSerializable, formats date in ISO 8601 format accepted by JavaScript's Date object (BC break)
    • Filter & RecursiveFilter are deprecated

    For the details you can have a look at the diff.

  • v2.3.10 Released version 2.3.10

    • Html: added addHtml() and addText() (#111)

    For the details you can have a look at the diff.

  • v2.3.9 Released version 2.3.9

    • Object: removed alias for ObjectMixin, it may interfere with nette/deprecated, which creates alias Nette\ObjectMixin

    For the details you can have a look at the diff.

  • v2.3.8 Released version 2.3.8

    • ArrayHash: fixed bug in ArrayIterator #103
    • Html::__toString() prints better error message
    • Image: ob_start() is protected to be not flushable

    For the details you can have a look at the diff.

  • v2.2.8 Released version 2.2.8

    • Callback::invokeSafe() removes function name also with arguments from error message
    • Callback::invokeSafe() workaround for HHVM bug facebook/hhvm#4625
    • __toString and Callback::invokeSafe() handles Throwable errors
    • Validator::is: fixed value overwriting
    • Random: use random_int() on PHP 7
    • Random: charlist now contains only unique characters
    • Random: rejects openssl_random_pseudo_bytes result when is not cryptographically strong
    • Random: skips microtime(), str_shuffle() and lcg_value() when cryptographically strong source is used
    • Image: fixed color allocation in palette-based images

    For the details you can have a look at the diff.

  • v2.3.7 Released version 2.3.7

    • Strings::toAscii() optimization
    • ObjectMixin::getSuggestion() better balance, replacement of prefix get|set|add|has|is costs 20
    • ObjectMixin::getSuggestion() better balance. Replacement is more expensive than insertion/deletion.
    • __toString and Callback::invokeSafe() handles Throwable errors
    • Callback::invokeSafe() removes function name also with arguments from error message

    For the details you can have a look at the diff.

  • v2.3.6 Released version 2.3.6

    ObjectMixin: added warning when method-getter is used by mistake (for getters without parameters) (BC break)

    Note: This release will trigger warning Did you forgot parentheses? when you call a method without parentheses, i.e. foreach ($form–>getErrors as $error).

    This notation is also used to create a callback. If you really want to create a callback, i.e. parentheses have not been forgotten and they are missing intentionally, replace this notation with a native PHP callback, for example [$form, 'getErrors']. Alternatively in PHP 5.3 you can use shutup operator: @$form->getErrors.

    For the details you can have a look at the diff.

  • v2.3.5 Released version 2.3.5

    • ObjectMixin: shows suggestions for undeclared members
    • ObjectMixin: added getExtensionMethods()
    • Random: use random_int() on PHP 7
    • Random: charlist now contains only unique characters
    • Random: rejects openssl_random_pseudo_bytes result when is not cryptographically strong
    • Random: skips microtime(), str_shuffle() and lcg_value() when cryptographically strong source is used
    • Image: fixed color allocation in palette-based images

    For the details you can have a look at the diff.

  • v2.2.5 Released version 2.2.5

    • Image::place() fixed unexpected output with transparency image #56
    • Image: better exception message [Closes #42]
    • Strings::webalize() converts non-breaking space … ™ ® etc in glibc mode
    • Validators::isUrl: backslashes in regexp escaped
    • Validators::isUrl: underscored subdomain support added
    • Strings::toAscii() removes \x80-\xFF chars
    • Strings::toAscii() converts degree sign to ^
    • Html: fixed quirky htmlspecialchars in PHP 5.6

    For the details you can have a look at the diff.

  • v2.2.6 Released version 2.2.6

    • Strings::toAscii() uses //IGNORE

    For the details you can have a look at the diff.

  • v2.2.7 Released version 2.2.7

    • Html: chars '<' in attributes are encoded in XHTML
    • travis: migrating to container-based infrastructure
    • Random: /dev/urandom is not used on Windows
    • improved coding style

    For the details you can have a look at the diff.

  • v2.3.1 Released version 2.3.1

    • Strings::toAscii() uses //IGNORE

    For the details you can have a look at the diff.

  • v2.3.2 Released version 2.3.2

    • Strings: added after() and before() (thanks @icaine) [Closes #20]
    • Arrays: added pick() - picks element from the array by key and return its value [Closes #54]
    • Random: fixed generating zero-length string with mcrypt
    • Image::fromString() undeprecated argument $format

    For the details you can have a look at the diff.

  • v2.3.3 Released version 2.3.3

    • Callback::invokeSafe() removes function name from error message
    • Callback::invokeSafe() workaround for HHVM bug facebook/hhvm#4625
    • Random: /dev/urandom is not used on Windows
    • improved coding style
    • travis: migrating to container-based infrastructure

    For the details you can have a look at the diff.

  • v2.3.4 Released version 2.3.4

    • Strings: added const for trim method whitespace charset
    • Json: accept whitespace-surrounded "null" for decode() as it is a valid JSON text
    • Image: fix exception message [Closes #71]
    • Html: chars '<' in attributes are encoded in XHTML

    For the details you can have a look at the diff.

  • v2.3.0 Released version 2.3.0

    • added Arrays::normalize(), Callback::invokeSafe(), Html::data(), Strings::firstLower()
    • Image::from() throws ImageException when is unable to decode file
    • Image::place() fixes support for alpha channel
    • Callback::closure() returns native closures since PHP 5.4
    • Strings::chr() throws Nette\InvalidArgumentException if code point is not in valid range
    • Validators::isUrl() accepts underscores in subdomains
  • v2.2.4 Released version 2.2.4

    • Json: workaroud for PHP fatal error caused by \u0000 at the beginning of key
    • speed optimization for Object, Strings::length(), Strings::substring()
    • Strings::toAscii(): unsupported characters are removed instead of being replaced with '?'
    • Html: floats in attributes are printed in natural notation [Closes nette/forms#50]

    For the details you can have a look at the diff.

  • v2.2.3 Released version 2.2.3

    • DateTime: createFromFormat returns FALSE on failure [Closes #33][Closes #34]

    For the details you can have a look at the diff.

  • v2.2.2 Released version 2.2.2

    • Strings, Arrays, Json: rewritten way how errors in PCRE functions are detected
    • added Validators::isUri()

    For the details you can have a look at the diff.

  • v2.2.1 Released version 2.2.1

    Added protection against innerHTML mXSS vulnerability.

    IE8 for code <div attr="´´foo=bar"> produces invalid innerHTML <div attr=´´foo=bar>. Adding a space at the end of the attribute forces IE to put quotes around the attribute.

    For the details you can have a look at the diff.

  • v2.2.0 Released version 2.2.0

    The first standalone release. For more information see readme.md.

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com