Repository navigation
Full PHP 8.6 support: deprecations, API types and capabilities - #14413
Conversation
- builtin functions, methods and constants PHP deprecates (is_double(), ArrayIterator::asort(), SORT_LOCALE_STRING, ...) as DeprecatedFunction, DeprecatedMethod and DeprecatedConstant, saying since when and what to use - deprecated arguments: an object for an array (array_walk(), http_build_query(), ...), define()'s third argument, is_a() with a class name, a session handler without create_sid() and validateId(), more than 16 php://filter filters, mysqli_stmt without a query - the names PHP 8.6 reserves (let, is, _, readonly) as ReservedWord - DeprecatedSyntax: return in finally, a value returned or yielded by a constructor or destructor, a nullable __debugInfo(), a class constant named namespace Also give a partial application of a callmap function with several signatures the one the arguments fit, and type stream_last_errors().
…hods - Io\Poll\Watcher is generic in its handle and data, which Context::add() keeps; StreamException::getErrors() and stream_last_errors() return list<StreamError> - capabilities of the new classes (poll API, builders, IntlNumberRangeFormatter, Openssl\Session, ...) and of the new functions with side effects (random sodium keys and nonces, XOF states, stream errors, snmp settings) - the new methods of ReflectionParameter, ReflectionProperty, ReflectionAttribute, mysqli and ZipArchive, which a class dated by an older @SInCE no longer makes available before PHP 8.6 - a polyfill no longer replaces the signature of a function native in the analysed version (grapheme_strrev() was mixed with symfony/polyfill-intl-grapheme installed) - the stub images use the PHP 8.6 release, with the extensions the release candidates couldn't build - require symfony/polyfill-php86
The syntax lint keeps the oldest supported PHP, which it checks the code parses on.
✅ Performance: regressed · Types: increased
How to read this table
✅ laravel: issues +9 −1Memory 1 768 → 1 757 MB (−0.6 %) · Wall 96.6 → 96.8 s (+0.3 %) Weighted 53 519 → 53 541 (+22, +0.04 %): L2 +8 · L4 −1 · always +1
Added (9)
Removed (1)
✅ symfony: issues +40 −8Memory 3 607 → 3 600 MB (−0.2 %) · Wall 202.9 → 206.5 s (+1.7 %) Weighted 98 402 → 98 508 (+106, +0.11 %): L1 +18 · L2 +9 · L3 −2 · L4 −1 · always +8
Added (40)
Removed (8)
✅ doctrine-orm: issues +15 −14Memory 393 → 381 MB (−3.1 %) · Wall 21.3 → 21.1 s (−1.2 %) Weighted 6 161 → 6 143 (−18, −0.29 %): L2 +14 · L4 −14 · always +1
Added (15)
Removed (14)
✅ psl: issues +76 −0Memory 632 → 617 MB (−2.5 %) · Wall 27.6 → 27.3 s (−1.0 %) Weighted 5 455 → 5 615 (+160, +2.93 %): L2 +75 · always +1
Added (76)
✅ php-parser: issues +0 −1Memory 237 → 226 MB (−4.9 %) · Wall 10.8 → 10.3 s (−5.0 %) Weighted 21 035 → 21 025 (−10, −0.05 %): always −1
Removed (1)
✅ tempest: issues +3 −0Memory 906 → 895 MB (−1.3 %) · Wall 27.7 → 27.6 s (−0.4 %) Weighted 10 551 → 10 557 (+6, +0.06 %): L2 +3
Added (3)
✅ guzzle-promises: issues +1 −0Memory 57 → 44 MB (−22.0 %) · Wall 1.9 → 1.2 s (−33.5 %) Weighted 427 → 434 (+7, +1.64 %): L7 +1
Added (1)
✅ monolog: issues +10 −0Memory 154 → 135 MB (−12.2 %) · Wall 4.8 → 4.2 s (−12.3 %) Weighted 2 403 → 2 479 (+76, +3.16 %): L2 +3 · always +7
Added (10)
✅ drupal: issues +64 −1Memory 4 852 → 4 841 MB (−0.2 %) · Wall 188.2 → 192.4 s (+2.2 %) Weighted 169 112 → 169 294 (+182, +0.11 %): L2 +56 · always +7
Added (64)
Removed (1)
composer.json changed in this PR, so head dependencies were re-resolved; memory and time deltas are informational. head b1c5c8a · base 419de43 (merge-base) · workflow run |
The return in finally, constructor and destructor, __debugInfo, name and argument checks run where Psalm already analyses those statements, instead of in a separate traversal and a separate call analyzer.
Functions, methods, constants, class constants, properties, ini settings and
mbstring encodings PHP 8.1 to 8.5 deprecate, the argument shapes they deprecate,
and the language deprecations: Serializable without __serialize(), static members
accessed on a trait, optional parameters before required ones, implicitly nullable
parameters, by-reference void returns, __sleep() not returning an array, "${var}"
interpolation, relative callables, raising 0 to a negative power, a class named _,
non-canonical casts, the backtick operator, case ending with a semicolon,
$http_response_header and __debugInfo() returning null. SID is a string.
The negated types of a ternary include the clauses that held before it, which the context already applied: an elseif after count($a) > 2 reported $a[0] ?? null as never has-at-least-3.
|
bugbot review |
759857f to
9dcd5ee
Compare
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 759857f. Configure here.
A function defined in Psalm's process, like the polyfills Psalm requires, counted as defined for the analysed project, so on an older runtime array_find() analysed for PHP 8.3 reported no UndefinedFunction. Such a function now counts only if the project depends on its package other than through Psalm, and Psalm no longer scans the autoloaded files of the other packages. Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
Runtimes before their version had no definition of these classes, so code analysed for their version reported UndefinedClass, and newer runtimes defined them for older analysed versions. The classes get @SInCE stubs, in PhpVersionedClasses.phpstub or their extension's stub, and the enums a new PhpVersionedEnums.phpstub loaded from PHP 8.1. The polyfills Psalm itself requires no longer count as the project's polyfills of a class. Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
…d password_hash() The key generators taking no argument counted as impure, and the others, like sodium_crypto_box_seal() and password_hash(), as pure. GMP's random functions use its global random state, like mt_rand(). Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
A class that has the replacement, __serialize() or __unserialize(), is exempt: serialize() and unserialize() don't call the old method, and a subclass may still call it as the parent's. A class with @psalm-cli-only-instances is now told to declare __unserialize(). Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
…h their version Incrementing an empty or non-alphanumeric string and decrementing an empty or non-numeric string are deprecated since PHP 8.3, but the first two were reported as deprecated since PHP 8.5 and the decrements as InvalidOperand. They are StringIncrement issues now, and a decremented string keeps the value PHP gives it: -1 for an empty string, the same non-numeric string. Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
A global constant declared with @deprecated, or with the #[\Deprecated] attribute PHP 8.5 allows on it, was used without DeprecatedConstant. Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
…des keep Overriding a PHP 8.3 typed constant without a docblock type, like const int LIMIT = 10 with const int LIMIT = 20, was reported as InvalidClassConstantType, as the parent's inferred literal type was taken as the contract. Aliased trait constants also lost their @SInCE version. Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
Functions like request_parse_body(), mysqli_execute_query(), pg_put_copy_data() and get_error_handler() counted as pure. Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
…endor directory A project with COMPOSER_VENDOR_DIR or a vendor-dir in its composer.json had its installed.json and autoload_files.php looked for in vendor/, so none of its packages counted as its own. Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
BinaryOperationTest's stand-in BcMath\Number now is the stubbed class, analysed for PHP 8.4; a CliOnlyCallTest case declares __wakeup() incidentally; the deprecated constant test matches any path. Claude-Session: https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo
* build: require Psalm 7.14 - Psalm 7.14 changes what the type fixtures report (PHP deprecations, unrequired-package functions, mixed-widened templates), and the fixtures updated in this PR no longer pass on 7.13. - Raise the floor in composer.json and in the Symfony Console job of tests.yml. * test: give the type and emission fixtures the composer.json Psalm 7.14 needs - Psalm 7.14 counts a vendor function as defined only if the composer.json next to the config requires its package (vimeo/psalm#14413); tests/Type and the EmissionApp fixture have none, so `now()`, `cache()`, `env()`, `trans()`, `route()` and `to_route()` became UndefinedFunction and `mixed` (22 type tests and `EmissionAppTest`). - The type tests select a differently named `composer.fixture.json` through `COMPOSER`, which leaves the plugin's project-root detection (a `composer.json` in the working directory) untouched. * test: expect the PHP deprecations Psalm 7.14 reports in collection callback fixtures - `is_a($string, Class::class)` is deprecated since PHP 8.6 (DeprecatedFunction) and an implicitly nullable parameter since PHP 8.4 (DeprecatedSyntax); Psalm reports both regardless of the analysed PHP version (vimeo/psalm#14413). - The fixtures keep those shapes because the narrowing of the two-argument `is_a()` and of a `= null` closure parameter is what they pin; the deprecation is now part of `--EXPECTF--`. * test: pin that an unbounded template given to getOrPut() and queued() now resolves to mixed - Psalm 7.14 no longer treats a bare template as decidably not a Closure for the `$value is callable` guard (vimeo/psalm#12672), so the result is widened with `mixed` and returning it as the template reports MixedReturnStatement; before, a possible Closure result stayed silent. - Rename GetOrPutClosureDefaultKnownLimitation.phpt to GetOrPutClosureDefaultUnboundedTemplateTest.phpt (positive coverage) and rewrite the three stub docblocks that cited the limitation. * test: pin the possibly-empty array-shape unpack of Paginator::fragment() as a known limitation - Psalm 7.14 unpacks `array{0?: string}` like a `list<string>` (vimeo/psalm#14415), so the call no longer resolves both the getter and the setter branch of `fragment()`; 7.13.2 did. - Rename PaginatorFragmentUnpackTest.phpt to PaginatorFragmentUnpackKnownLimitation.phpt and rewrite the docblocks of the stub and of RouteDomainKnownLimitation.phpt that cited the old behavior. * test: suppress Psalm 7.14's static-call false positive on a trait constructor in the Blade taint fixture - Psalm 7.14 analyses the synthetic constructor call for uninitialised properties as a static call on the parent's trait and reports InvalidStaticInvocation (a regression of vimeo/psalm#14413, reproducible without the plugin). - `BladeComponentTaintTest::the_bridge_adds_no_non_taint_issue` asserts no other issue, so the fixture class suppresses it. * fix: accept the value argument in Enumerable::when() and unless() callbacks - Laravel's Enumerable interface docblock types the callbacks as callable($this) and $value as bool, but Conditionable calls $callback($this, $value) and accepts any value - Psalm 7.13.2 keeps the concrete $this type in callable($this) (vimeo/psalm#14423), which surfaced the arity mismatch as InvalidScalarArgument - Stub Enumerable::when() and unless() with the Conditionable signature * docs: link the upstream Enumerable docblock fix from the when()/unless() stub * test: link the filed Psalm issues from the workarounds and known limitations - vimeo/psalm#14554 (trait constructor InvalidStaticInvocation), #14556 (array-shape unpack), #14555 (composer.json next to the config).
Builtins PHP 8.6 deprecates
Deprecated functions, methods and constants are not reported, whatever the analysed PHP version.
Before
After
Builtins PHP 8.1 to 8.5 deprecate
Before
After
Syntax PHP 8.1 to 8.5 deprecates
Before
After
Syntax PHP 8.6 deprecates
returninfinally, and the other deprecated declarations, are not reported.Before
After
Poll API types
The watcher a poll context returns loses the types of its handle and data.
Before
After
Partial application of a function with several signatures
Before
After
Polyfills of native functions
A polyfill replaces the signature of a function native in the analysed PHP version (
grapheme_strrev()ismixedwith symfony/polyfill-intl-grapheme installed).Before
After
Polyfills Psalm itself requires
Psalm's own
symfony/polyfill-php84/86defined functions and classes for the analysed project.Before (
--php-version=8.3, project without the polyfills)After
Classes PHP 8.3 to 8.5 add
Before (PHP 8.5 runtime)
After
Randomness and the impure functions PHP 8.1 to 8.5 add
Before
After
__sleep()and__wakeup(), which PHP 8.5 soft-deprecatesBefore
After
String increments and decrements PHP 8.3 deprecates
Before
After
Deprecated global constants
Before
After
Overrides of typed class constants
Before
After
https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo