nette/utils
Handy PHP utility classes from Nette: strings, arrays, JSON, validators, safe HTML, and more. Lightweight, well-tested helpers that complement any framework or plain PHP app, making common tasks cleaner, safer, and faster to write.
A maintenance release focused on code quality: stricter types, better PHPDoc annotations, and PHPStan now runs as a mandatory CI check. No breaking changes.
Type::with()Type::fromValue()Helpers::splitClassName()Iterables::repeatable()is_file() does not work with symlinks under Windowssupport for PHP 8.5
Strings::trim() trims Line Separator and Ideographic Space (#326)DateTime::relativeToSeconds() checks for errormodify() correctly handle the relative time even if the daylight saving time is changedrelativeToSeconds() for converting relative time string to secondsFileSystem::resolvePath() #308Strings::matchAll(): added option 'lazy'Arrays::mapWithKeys() & Iterables::mapWithKeys()Iterables::memoize() & toIterator()IterablesArrays::firstKey(), lastKey()Arrays::filter()Arrays::first() & last(): added parameter $elseArrays::first() & last(): added parameter $predicate #305Image::getSupportedTypes()Strings::trim() trims unicode spaces and ZWSP (#304)Image::rgb()Image::rectangleWH(), filledRectangleWH(), calculateTextBox()Strings::length() uses mbstring, iconv and then utf8_decode #299getType() replaced with isDir() / isFile()some(), every() and map() (#298)Callback::unwrap() returns correct class name for private methodsgetParameterType(), getReturnType() and getPropertyType() marked as deprecatedImage::isTypeSupported()collect() returns listCallback::unwrap() returns correct class name for private methodsnew methods:
new parameters:
removed
isTypeDeclaration(), isBuiltinType(), isClassKeyword()Types::isSingle() -> isSimple()Image::clone() uses PNG format because GD2 is disabled since libgd 2.3.3extensionToType()Arrays::isList() uses array_is_list() is PHP 8.1Deprecated properties are written as [@property-deprecated](https://github.com/property-deprecated), no standard here exists. PhpStorm and static analysis tools do not see them, which is the intention.
Strings::indexOf() fixed empty $haystack and negative $nth #271Helpers::clamp()Validators::isPhpIdentifier(): Value is always string. (#268)Reflection::expandClassName() recognizes 'parent'Reflection::isClassKeyword(), Type::isClassKeyword()Reflection::getReturnType() & Type::fromReflection() return tentative type in PHP 8.1getReturnTypes(), getParameterTypes(), getPropertyTypes() are deprecatedArrayList::from()getReturnTypes(), getParameterTypes(), getPropertyTypes() are deprecatedmakeWritable() (#244)wrap() method (#180)Arrays::insertAfter() & insertBefore() fixed when $key is nullDateTime::fromParts() is non-locale aware #248first(), last() & contains()invoke() & invokeMethod()toAscii() fixed to correctly convert german umlauts (BC break) (#240)For the details you can have a look at the diff.
getReturnTypes(), getParameterTypes() and getPropertyTypes()getReturnType(), getParameterType() and getPropertyType() throws exception on union typesfromString() throws UnknownImageFileException when file type is unknownFor the details you can have a look at the diff.
fromString() throws UnknownImageFileException when file type is unknownFor the details you can have a look at the diff.
getText() decodes 'For the details you can have a look at the diff.
renameKey() fixed incorrect replacement for existing new keys #230renameKey() returns true if $oldKey was foundtoKey()isBuiltinType() added PHP 8 types mixed & falsegetReturnType() fixed for functionsFor the details you can have a look at the diff.
getMethodDeclaringMethod()toAscii() removes non-ascii characters when iconv is not supported #216For the details you can have a look at the diff.
How can I help you explore Laravel packages today?