Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make array shapes strict by default #8701

Merged
merged 2 commits into from Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions UPGRADING.md
Expand Up @@ -29,13 +29,13 @@

- [BC] The parameter `$php_version` of `Psalm\Type\Atomic::create()` renamed
to `$analysis_php_version_id` and changed from `array|null` to `int|null`.
Previously it accepted PHP version as `strict-array{major_version, minor_version}`
Previously it accepted PHP version as `array{major_version, minor_version}`
while now it accepts version ID, similar to how [`PHP_VERSION_ID` is
calculated](https://www.php.net/manual/en/reserved.constants.php#constant.php-version-id).

- [BC] The parameter `$php_version` of `Psalm\Type::parseString()` renamed to
`$analysis_php_version_id` and changed from `array|null` to `int|null`.
Previously it accepted PHP version as `strict-array{major_version, minor_version}`
Previously it accepted PHP version as `array{major_version, minor_version}`
while now it accepts version ID.

- [BC] Parameter 0 of `canBeFullyExpressedInPhp()` of the classes listed below
Expand Down Expand Up @@ -805,7 +805,7 @@
- [BC] Class `Psalm\Type\TaintKind` became final
- [BC] Class `Psalm\Type\Union` became final
- [BC] Property `Psalm\Config::$universal_object_crates` changed default value
from `strict-array{'stdClass','SimpleXMLElement','SimpleXMLIterator'}` to `null`
from `array{'stdClass','SimpleXMLElement','SimpleXMLIterator'}` to `null`

## Removed
- [BC] Property `Psalm\Codebase::$php_major_version` was removed, use
Expand Down
2 changes: 1 addition & 1 deletion bin/test-with-real-projects.sh
Expand Up @@ -32,7 +32,7 @@ collections)
psl)
git clone git@github.com:psalm/endtoend-test-psl.git
cd endtoend-test-psl
git checkout 1.9.x
git checkout 1.9.x-array
composer require --dev php-standard-library/psalm-plugin:^1.1.4 --ignore-platform-reqs
cd vendor/php-standard-library/psalm-plugin
patch -p1 < $SCRIPT_DIR/psl-psalm-plugin.diff
Expand Down
224 changes: 112 additions & 112 deletions dictionaries/CallMap.php

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dictionaries/CallMap_73_delta.php
Expand Up @@ -26,18 +26,18 @@
'JsonException::getLine' => ['int'],
'JsonException::getMessage' => ['string'],
'JsonException::getPrevious' => ['?Throwable'],
'JsonException::getTrace' => ['list<strict-array{file?:string,line?:int,function:string,class?:class-string,type?:\'::\'|\'->\',args?:array<mixed>}>'],
'JsonException::getTrace' => ['list<array{file?:string,line?:int,function:string,class?:class-string,type?:\'::\'|\'->\',args?:array<mixed>}>'],
'JsonException::getTraceAsString' => ['string'],
'SplPriorityQueue::isCorrupted' => ['bool'],
'array_key_first' => ['int|string|null', 'array'=>'array'],
'array_key_last' => ['int|string|null', 'array'=>'array'],
'fpm_get_status' => ['array|false'],
'gc_status' => ['strict-array{runs:int,collected:int,threshold:int,roots:int}'],
'gc_status' => ['array{runs:int,collected:int,threshold:int,roots:int}'],
'gmp_binomial' => ['GMP|false', 'n'=>'GMP|string|int', 'k'=>'int'],
'gmp_kronecker' => ['int', 'num1'=>'GMP|string|int', 'num2'=>'GMP|string|int'],
'gmp_lcm' => ['GMP', 'num1'=>'GMP|string|int', 'num2'=>'GMP|string|int'],
'gmp_perfect_power' => ['bool', 'num'=>'GMP|string|int'],
'hrtime' => ['strict-array{0:int,1:int}|false', 'as_number='=>'false'],
'hrtime' => ['array{0:int,1:int}|false', 'as_number='=>'false'],
'hrtime\'1' => ['int|float|false', 'as_number='=>'true'],
'is_countable' => ['bool', 'value'=>'mixed'],
'net_get_interfaces' => ['array<string,array<string,mixed>>|false'],
Expand Down
6 changes: 3 additions & 3 deletions dictionaries/CallMap_80_delta.php
Expand Up @@ -1214,8 +1214,8 @@
'new' => ['string', 'password'=>'string', 'algo'=>'int|string|null', 'options='=>'array'],
],
'proc_get_status' => [
'old' => ['strict-array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}|false', 'process'=>'resource'],
'new' => ['strict-array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}', 'process'=>'resource'],
'old' => ['array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}|false', 'process'=>'resource'],
'new' => ['array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}', 'process'=>'resource'],
],
'session_set_cookie_params' => [
'old' => ['bool', 'lifetime'=>'int', 'path='=>'string', 'domain='=>'string', 'secure='=>'bool', 'httponly='=>'bool'],
Expand Down Expand Up @@ -1681,7 +1681,7 @@
'ReflectionType::isBuiltin' => ['bool'],
'SplFileObject::fgetss' => ['string|false', 'allowable_tags='=>'string'],
'create_function' => ['string', 'args'=>'string', 'code'=>'string'],
'each' => ['strict-array{0:int|string,key:int|string,1:mixed,value:mixed}', '&r_arr'=>'array'],
'each' => ['array{0:int|string,key:int|string,1:mixed,value:mixed}', '&r_arr'=>'array'],
'gmp_random' => ['GMP', 'limiter='=>'int'],
'gzgetss' => ['string|false', 'zp'=>'resource', 'length'=>'int', 'allowable_tags='=>'string'],
'image2wbmp' => ['bool', 'im'=>'resource', 'filename='=>'?string', 'threshold='=>'int'],
Expand Down