Changelog - Version 7.0
Status: in development. This document tracks changes landing on the
7.0branch. Nothing here is released yet, and the contents may still change.
Breaking Changes
Enum cases renamed to PascalCase
Enum cases follow the ByJG standard and are written in PascalCase. JsonFieldDefinitionEnum is a
pure (non-backed) enum, so any code that names a case (or reads ->name) has to be updated.
| Enum | Before (6.x) | After (7.0) |
|---|---|---|
JsonFieldDefinitionEnum | STRING, INT, FLOAT, BOOL, ANY | String, Int, Float, Bool, Any |
ofTypeInt() validates the whole value
The integer check now uses FILTER_VALIDATE_INT instead of intval(). Values that used to be
silently truncated are now rejected with Field '...' must be an integer:
| Value | Before (6.x) | After (7.0) |
|---|---|---|
"12abc" | 12 | rejected |
"1.9", 1.9 | 1 | rejected |
true | 1 | rejected |
A whole-number string with leading zeros or surrounding spaces ("012", " 12") is still
accepted and read as decimal, as before.
getDefaultValue() returns mixed
JsonFieldDefinition::getDefaultValue() returned ?string and the default value was stored as a
string, so withDefaultValue(0) became "0". The default now keeps its type and the getter is
declared mixed. Code that relied on always getting a string back must cast it.
Bug Fixes
ofTypeInt() rejected zero
!intval($value) treated 0 and "0" as "not an integer", so a field holding zero could not be
read with ofTypeInt(). They are now valid (see the Breaking Changes entry for what the stricter
check rejects).
Typed fields could not be optional
A missing field arrives as its default value, null when none was set. null then failed every
type check, so ofTypeInt(), ofTypeFloat(), ofTypeBool() and ofTypeString() behaved as if
the field were required, with a misleading type error. A null value of a field that is not
required() is now returned as null without the type check.
Default value converted to a string
withDefaultValue(0) and withDefaultValue(false) were stored as "0" and "", which then failed
ofTypeInt() and ofTypeBool() on a missing field. The default now keeps its type.
Requirements
- PHP 8.3, 8.4, 8.5 and 8.6 are now supported:
"php": ">=8.3 <8.7". The previous<8.6upper bound excluded PHP 8.6, since<8.6is exclusive.
ByJG dependencies
byjg/anydatasetis now^7.0.
While 7.0 is unreleased these resolve to 7.0.x-dev from each component's
7.0 branch, via minimum-stability: dev with prefer-stable: true.
Toolchain
-
PHPUnit updated to
^12.5. -
Psalm is installed as
psalm/pharinstead ofvimeo/psalm.vimeo/psalmlists the PHP versions it supports and no published release includes 8.6, so as a dev dependency it madecomposer installfail on the 8.6 build job before any test ran.psalm/pharrequires onlyphp ^8.2and bundles its own dependencies, so it installs on every PHP version in the matrix and cannot conflict with the project's. Psalm itself still refuses to run on 8.6, which is why the Psalm job uses 8.5.composer psalmruns it. -
PHPUnit 13 is deliberately not used. It requires PHP
>=8.4.1, breaking the 8.3 floor.
Continuous Integration
- The build matrix now includes PHP 8.6.
- The Psalm job runs on PHP 8.5.
Housekeeping
phpunit.xml.distrenamed tophpunit.xml.