All notable changes to this project will be documented in this file.
- The documentation overview shows six feature cards, adding Reference Mode and ArrayAccess & Countable.
The 8.5.x line now runs the rebuilt 8.x path engine, with results identical to 8.4.1. 8.5.0 still had the 2.x engine, so this patch changes results for 8.5.0 users: every change listed under 8.0.0 applies. Read UPGRADE.md before updating.
- Requires PHP
>=8.5 <8.6(8.5.0allowed^8.5). Use the8.4.xline on PHP 8.4. dot()acceptsnulland anotherDotArrayagain (8.5.0accepted arrays only).- Requires
pharaonic/php-readable~8.5.0, its PHP 8.5 line. - PHPStan analyses against PHP 8.5, and CI falls back to PHP 8.5 on branches that are not an
8.N.xline. - PHPStan
^2.1.22is required for development, the first release that analyses against PHP 8.5.
The 8.4.x line now runs the rebuilt 8.x path engine, with results identical to 8.3.0. 8.4.0 still had the 2.x engine, so this patch changes results for 8.4.0 users: every change listed under 8.0.0 applies. Read UPGRADE.md before updating.
- Requires PHP
>=8.4 <8.5(8.4.0allowed^8.4). Use the8.3.xline on PHP 8.3 and the8.5.xline on PHP 8.5. - Requires
pharaonic/php-readable~8.4.0, its PHP 8.4 line. dot()acceptsnulland anotherDotArrayagain (8.4.0accepted arrays only).- The test suite runs on PHPUnit 12, and deprecations still fail the run (
failOnDeprecation). - PHPStan
^2.1.18is required for development: 1.x cannot parse PHP 8.4 syntax, and earlier 2.x releases lose track of the path parser's list type. - The test suite calls methods on new instances without wrapping parentheses (
new DotArray([...])->get(...)). - PHPStan analyses against PHP 8.4, and CI falls back to PHP 8.4 on branches that are not an
8.N.xline.
The 8.3.x line targets PHP 8.3. Results are identical to 8.2.0. See UPGRADE.md.
- Requires PHP
>=8.3 <8.4. Use the8.2.xline on PHP 8.2. - Requires
pharaonic/php-readable~8.3.0, its PHP 8.3 line. - PHPStan analyses against PHP 8.3, and CI falls back to PHP 8.3 on branches that are not an
8.N.xline. - The
ArrayAccess,Countable,IteratorAggregateandJsonSerializablemethods are marked with#[\Override].
The 8.2.x line targets PHP 8.2. Results are identical to 8.1.0. See UPGRADE.md.
- Requires PHP
>=8.2 <8.3. Use the8.1.xline on PHP 8.1. - Requires
pharaonic/php-readable~8.2.0, its PHP 8.2 line. - PHPStan analyses against PHP 8.2, and CI falls back to PHP 8.2 on branches that are not an
8.N.xline.
The 8.1.x line targets PHP 8.1. Results are identical to 8.0.0. See UPGRADE.md.
- Requires PHP
>=8.1 <8.2. Use the8.0.xline on PHP 8.0. - Requires
pharaonic/php-readable~8.1.0, its PHP 8.1 line. - PHPStan analyses against PHP 8.1, and CI falls back to PHP 8.1 on branches that are not an
8.N.xline.
Rebuilt the path engine. get(), has(), set(), delete() and pull() now share one path parser and one set of wildcard matching rules, documented in docs/ and on pharaonic.dev.
The 8.0.x line targets PHP 8.0. The API is unchanged from 2.x, but some results are different: see UPGRADE.md.
- Depends on
pharaonic/php-readable(~8.0.1), which also requiresext-mbstring. The deprecated array inspection helpers now use itsArrclass. pull($path, $default = null)returns a value and deletes it, wildcards included.- Escaping:
\.is a literal dot inside a key (config.app\.name),\*a literal*key (items.\*.name), and\\a literal backslash. Any other backslash is kept as is, so keys such asApp\Models\Userstill work. set(),clear(),setArray()andsetReference()return the instance, so calls can be chained.- PHPStan (level max), PHP_CodeSniffer (PSR-12), Dependabot, and
composer test/analyse/lint/checkscripts. SECURITY.md,SUPPORT.md,CONTRIBUTING.md,CODE_OF_CONDUCT.md,UPGRADE.md,FUNDING.yml, and issue and pull request templates.- Versioned documentation in
docs/for pharaonic.dev.
- A value set to
nullexists.has(),delete()and integer keys treat it as present.get()still returns the default for it, as before. get()returns[]and arrays holding onlynulls instead of replacing them with the default. Only a missing path or anullvalue gives the default.- Wildcard reads return one entry per matched element.
get('users.*.profile')returns[['age' => 30], ['age' => 25]]; it used to merge the profiles into['age' => [30, 25]]. Array values are no longer merged or flattened either (get('a.*.tags')gives[[1, 2], [3]], was[1, 2, 3]). Nested wildcards still give one flat list:get('groups.*.users.*.name')is['A', 'B', 'C']as before. - A trailing
*means the elements themselves.delete('users.*')emptiesusers(it used to delete theuserskey),set('a.*', $v)sets every element (it used to replacea), andhas('users.*')isfalsefor an empty array.get('roles.*')returns a list of the elements, without their keys. - Wildcards never create elements.
set('users.*.active', true)on a missing or emptyusersused to create[['active' => true]]; it now does nothing. has()with a wildcard isfalsewhen nothing matches (it used to betruefor an empty array). When something matches, every matched element must still have the rest of the path, as before.delete()with a wildcard returnstruewhen at least one value was deleted (it used to returnfalseunless every element had the key).- Elements that don't reach the last wildcard, or aren't arrays when keys follow it, are skipped by every operation. They used to throw a
TypeError, andhas()returnedfalsewhen a branch lacked a key before the last wildcard (groups.*.users.*.namewith a group that has nousers). set()replaces a non-array value in the way of the path with an array (set('a.b', 1)on['a' => 'hello']gives['a' => ['b' => 1]]) instead of throwing anError.count($path)returns0for a missing path or a non-array value instead of throwing aTypeError.dot()accepts the same values as the constructor (an array, anotherDotArray, ornull).- The helper functions are declared only when no function with the same name exists.
isNumericKeys()/array_is_numeric()returntruefor an empty array (wasfalse), matching PHP'sarray_is_list().isMultidimensional()/array_is_multidimensional()returntruewhen a value is an empty array, such as['a' => []](wasfalse).toJson(0)encodes the element at key0; it used to encode the whole array.isEmpty('0')checks the element at key0; it used to check the whole array.*is a wildcard only as a whole segment:a.b*is the literal keyb*(the trailing*used to be stripped).- Requires PHP
>=8.0 <8.1. Each PHP version has its own release line (8.0.x,8.1.x, …).
delete('x.b')with a missingxdeleted the root keyb.delete($int)did not delete and raised warnings.- The path
'0'was treated as an empty path:get('0')returned the whole array, andset('0', $v)anddelete('0')did nothing. has($int)returnednullinstead of a boolean, for missing keys and for keys holdingnull.
isNumericKeys(),isMultidimensional(),isNulledValues(), and thearray_is_numeric(),array_is_multidimensional()andarray_is_null()helpers. They are not about dot-notation access and will be removed in a future major release. UsePharaonic\Readable\Arr::isList(),Arr::isMultidimensional()andArr::isNull()instead.- The third argument of
get(),has(),set()anddelete()(an array to work on instead of the stored one). Usedot($array)orsetReference()instead.
- Public method names, parameters and declared return types are unchanged, so subclasses keep working. Methods that had no declared return type still have none; the fluent
$thisreturns are documented in PHPDoc. delete()still returnsbool.toJson()still returns an empty string when encoding fails; passJSON_THROW_ON_ERRORto get aJsonException.get('')still returns the whole array andhas('')is stilltrue;set('')anddelete('')still do nothing.- Leading and trailing dots and spaces in a path are still ignored, and
a..bstill means an empty-string key. setArray()aftersetReference()still replaces the referenced array.
- Requires PHP
^8.5and PHPUnit 13. - Declared return types on
set(),setArray(),setReference(),clear()andall(), and explicit nullable parameter types. dot()takesarray $arr = [].
delete()with an integer key.
Same as 8.5.0, requiring PHP ^8.4.
isNumericKeys(),isNulledValues()andisMultidimensional().
- Requires PHP 8.0 and declares return types.
- Improved
get(),has(),set()anddelete(). - Renamed the helper functions to
array_is_numeric(),array_is_null()andarray_is_multidimensional().
- Added the missing
#[ReturnTypeWillChange]attributes on the internal interface methods.
- PHP 8.1 support.
- Test suite.
- First release.