All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
2.2.0 - 2025-01-10
Important
Initially, in the previous 2.1.0 release, several functions were deprecated (see Deprecated under 2.1.0 below).
After much thought on the direction I want this library to move in, I am reversing my decision to deprecate the Array and Temperature functions mentioned.
Dates::formatDifferenceOutput()a private function to handle formatting the output forDates::timeDifference()Dates::INTERVAL_UNITSconstant.- Added new parameter
$includeBcZonestoDates::timezoneInfo()andDates::validTimezone()- If true, includes all backwards compatible (and outdated) timezones.
- Added
PsalmandRectorPHPas dev-dependencies.
Arrays::flatten(),Arrays::mapDeep(), and all the temperature related functions inConversionsare no longer deprecated.- New tests added for the
Imageclass. Still a work in progress; working toward no 'codeCoverageIgnore'. Dates::timeDifference()logic was changed and a new parameter$extendedOutputadded.- If this parameter is
false(default), it returns the same output as usual. - If this parameter is
true, it formats the output with available non-zeroDateIntervalunits. For example: 2 days 2 hours 20 minutes old.
- If this parameter is
- BC BREAK:
Dates::timeDifference()output no longer uses '(s)'. Will add 's' if greater than one. Arraysclass has gone through a bit of a refactor:Arrays::mapDeep()updated to avoid circular references when dealing with objects.- New PHPUnit tests added to cover
mapDeep()as well.
- New PHPUnit tests added to cover
- Updated the
Arraysclass for psalm/phpstan templates/generics.- Still something I am admittedly not highly experienced with, so it may look/feel a little wonky. Going to improve it as I can.
- Optimized the
Conversion::haversineDistance()method. - Refactored unit tests.
- Changes throughout to make fixes and improvements reported by Psalm.
2.1.0 - 2024-04-23
This release focuses on setting up the future of the library. No new features or functionality has been added in this release.
- Added mend.io's Renovate to workflow
- Added
Esi\Clockto dependencies, updatedEsi\Utility\Datesaccordingly. - Added a code of conduct.
- Added a backwards compatibility promise.
- Reformatted this CHANGELOG to be more in line with the Keep a Changelog format.
- Implemented various PHPCS-Fixer recommendations.
- Updated coding style via
.php-cs-fixer.dist.php, and as a result, implemented those changes throughout the library. - Changed the header being used for all files to something smaller, and more simple.
- Bumped version requirement for the PHPUnit dev-dependency to 11.1
- Updated
testsgithub workflow to add uploading coverage data to Codecov.io - Made all utility classes
abstractas they never need instantiation. - Separate contributing information into its own file.
- Updated contributing information and guidelines.
The next major release, v3, will move to PHP 8.3 as a minimum requirement.
Arrays::flatten()'s current signature and functionality will change in the next major release (v3.0)Arrays::mapDeep()'s current signature and functionality will change in the next major release (v3.0)- The functionality of mapping the properties of an object will likely be moved to its own utility class/function.
Arrays::validJson()will be removed in the next major release (v3.0)- All the temperature related functions in
Conversions:- Current signature and functionality deprecated, will be changed in 3.0
- Removed deprecated
Arrays::exists - Removed all instances of
@phpstan-ignore-*opting to instead use a baseline for PHPStan (phpstan-baseline.neon)
2.0.0 - 2024-03-04
Utility has undergone a complete restructuring, wherein it is no longer a single super class. The class has been broken down into smaller classes or "components".
- Utility\Arrays
- Utility\Conversion
- Utility\Dates
- Utility\Environment
- Utility\Filesystem
- Utility\Image
- Utility\Numbers
- Utility\Strings
- New constants:
Conversion::EARTH_RADIUSConversion::METERS_TO_KILOMETERSConversion::METERS_TO_MILESDates::VALIDATE_TIMESTAMP_REGEXEnvironment::IP_ADDRESS_HEADERSEnvironment::HOST_HEADERSEnvironment::URL_HEADERSEnvironment::HTTPS_HEADERSEnvironment::REQUEST_HEADERSImage::IMAGE_TYPESNumbers::SUFFIXESNumbers::SIZE_FORMAT_UNITSNumbers::BINARY_STANDARD_BASENumbers::METRIC_STANDARD_BASENumbers::CONVERSION_MODIFIEREnvironment::PORT_SECUREEnvironment::PORT_UNSECUREEnvironment::VALIDATE_HOST_REGEXEnvironment::BOOLEAN_MAPPINGS
- Added new function
Arrays:valueExists
- Made a great improvement in code coverage/testing
- Effort to improve documentation, which can be found in
docs/or online here - Filesystem::lineCounter() (Utility::lineCounter() in Utility < 2.0) no longer has a
$skipEmptyparameter. It will now always skip empty lines.- Replaced the use of
file()withSplFileObjectand flagsSplFileObject::READ_AHEAD | SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE- Should be more efficient, especially for larger files.
- Replaced the use of
- Numbers::sizeFormat() (Utility::sizeFormat() in Utility < 2.0) has a new option:
- Numbers::sizeFormat(int $bytes, int $precision = 0, string $system = 'binary'): string
- System can be one of 'binary' or 'metric' and it determines the base/mod for the formatting.
- Updated tests to use PHPUnit's CoversClass and DataProvider attributes.
- Changed
$thistoself::in tests when calling PHPUnit methods
- Changed
- Updated composer.json to support PHP 8.2 - 8.4
- Added PHPStan strict rules to dev dependencies
- Updated workflows to introduce testing on PHP 8.4
- Bump copyright year.
- Updated
Strings::ascii(),Strings::slugify().- Added
voku/portable-asciias a dependency. - These functions now accept a new parameter:
$language. If a language specific set of characters exists, it will use those withinslugifyandascii.
- Added
Arrays::existsis nowArrays::keyExists- Updated
composer.jsonfor thetestscript, and moved all the phpunit command line options to the relevant options in thephpunit.xmlxml config. - Updated unit tests.
Arrays::exists()will be replaced withArrays::keyExists()
- Utility\Utility super class.
- Due to using
voku/portable-asciias a dependency,Strings::charMap()was removed.
1.3.0 - 2023-12-11
currentUrl()no longer has any parameters, and just returns the URL string.currentUrl(bool $parse = false)is now justcurrentUrl()- Just run
parse_url(Utility::currentUrl())if that functionality is needed.
- Code cleanup per PHPCS and PHPScrutinizer
- Small refactoring of some functions, such as
currentUrlandisReallyWritable
- Small refactoring of some functions, such as
- Attempt at increasing test coverage.
- Further cleanup to try and adhere to PSR-12.
- Adding information into
README.mdfor PHPDoc related guidelines, in an effort to adhere toPSR-5andPSR-19.
- Adding information into
serverHttpVars()deprecated, just use getallheaders() instead.
- Removed deprecated
statusHeader()- Added
ralouphie/getallheadersas a polyfill, for situations where the SAPI is not Apache serverHttpVars()will just return thegetallheaders()output
- Added
1.2.0 - 2023-09-22
- New function
arrayInterlace - New functions for temperature conversions:
fahrenheitToCelsius,celsiusToFahrenheit,celsiusToKelvin,kelvinToCelsius,fahrenheitToKelvin,kelvinToFahrenheitfahrenheitToRankine,rankineToFahrenheit,celsiusToRankine,rankineToCelsius,kelvinToRankine,rankineToKelvin
- Initial implementation of PHPUnit and the testing suite.
- Code cleanup per PHPStan (level: 9, strict, bleeding edge)
doesContain()anddoesNotContain()now uses the PHP 8 nativestr_contains()function.- No longer relies on
mbstringfor these two functions, as it does not appear to be necessary. - However, you can pass true to the
$multibyteparameter to usembstring - New signature:
(string $haystack, string $needle, bool $insensitive = false, bool $multibyte = false)
- No longer relies on
beginsWith()andendsWith()now uses the PHP 8 nativestr_starts_with()andstr_ends_with()functions.- No longer relies on
mbstringfor these two functions, as it does not appear to be necessary. - However, you can pass true to the
$multibyteparameter to use mbstring - New signature:
(string $haystack, string $needle, bool $insensitive = false, bool $multibyte = false)
- No longer relies on
- Reworked
arrayFlatten, now has new parameter$prepend validJson()should now return properly
- statusHeader() is now deprecated, you can use PHP's built-in http_response_code function instead.
1.1.2 - 2023-08-17
- Version bump
- Minor code cleanup
1.1.1 - 2023-08-11
- Version bump
- Cleaning up issues per PHPStan
1.1.0 - 2023-06-24
- Version bump
- Bumped PHP version requirement to 8.2
- Updated composer.json
- BC BREAK: randomBytes, randomInt, randomString and guid now throw \Random\RandomException
- FIX: Minor documentation improvements.
- FIX: Minor code improvements.
1.0.3 - 2023-06-03
- Updated copyright year(s) and version bump.
- Bumped PHP version requirement.
- Updated composer.json
- FIX: Minor documentation improvements.
- FIX: Minor code improvements.
- FIX: Some functions not defined/used properly.
- Updated copyright year(s) and version bump.
- FIX: Minor documentation improvements.
- FEAT: New functions - lcfirst, ucfirst, strcasecmp
- FIX: Minor documentation improvements.
- Initial release