Add PHP 8.5 partitioned cookie attribute to session_get_cookie_params() and the cookie option shapes - #6004
Merged
staabm merged 1 commit intoJul 5, 2026
Conversation
…ams()` and the cookie option shapes
- Add `partitioned: bool` to the `session_get_cookie_params()` return array shape in the PHP 8.5 signature delta (`functionMap_php85delta.php`), so `array_key_exists('partitioned', session_get_cookie_params())` is no longer inferred as always-false on PHP 8.5.
- Apply the same CHIPS RFC change to the sibling cookie functions: add `partitioned?:bool` to the options-array shapes of `setcookie`, `setrawcookie`, and `session_set_cookie_params` (their `'1'` variants).
- Record the pre-8.5 signatures in the delta `old` section so the mapping stays reversible.
- Add nsrt regression test `session-get-cookie-params-php85.php` asserting the full return shape and that the `partitioned` key exists.
VincentLanglet
approved these changes
Jul 4, 2026
staabm
approved these changes
Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PHP 8.5 adds the
partitionedcookie attribute (CHIPS RFC).session_get_cookie_params()now returns apartitionedkey, but PHPStan's signature map didn't know about it, soarray_key_exists('partitioned', session_get_cookie_params())was inferred as always evaluating tofalseon PHP 8.5 — a false positive. This addspartitionedto the affected cookie function signatures for PHP 8.5.Changes
resources/functionMap_php85delta.php:newsection: addpartitioned: boolto thesession_get_cookie_params()return array shape.newsection: addpartitioned?:boolto the options-array parameter shape ofsetcookie'1,setrawcookie'1, andsession_set_cookie_params'1(the CHIPS RFC added the attribute to all four cookie functions).oldsection: record the pre-8.5 signatures for the same functions so the 8.5↔8.4 conversion stays reversible.tests/PHPStan/Analyser/nsrt/session-get-cookie-params-php85.php: new PHP 8.5 (// lint >= 8.5) regression test asserting the full return shape and thatarray_key_exists('partitioned', session_get_cookie_params())istrue.Root cause
The base
functionMap.phpreflects PHP 8.4, where thepartitionedcookie attribute does not exist. PHP 8.5 signature differences are layered on viafunctionMap_php85delta.php, but the delta hadn't been updated for the CHIPS RFC. As a result, on PHP 8.5 the return shape ofsession_get_cookie_params()was missing thepartitionedkey, and the input option shapes of the sibling cookie setters were missing it too.The parallel-construct axis here is the four cookie functions the CHIPS RFC touched:
session_get_cookie_params()(return shape) andsetcookie/setrawcookie/session_set_cookie_params(options-array parameter shapes). The reported bug was only observable on the return-shape function (the option shapes are not sealed against extra keys, so they didn't produce a visible false positive), but all four are updated together for accuracy and to match php.net / the RFC.Test
tests/PHPStan/Analyser/nsrt/session-get-cookie-params-php85.phpasserts the return type ofsession_get_cookie_params()includespartitioned: booland thatarray_key_exists('partitioned', session_get_cookie_params())narrows totrueon PHP 8.5.bin/phpstan analysewithphpVersion: 80500that thepartitionedkey is present (and absent withphpVersion: 80400), and that reading$params['partitioned']yieldsbool.Fixes phpstan/phpstan#14922