Skip to content

Commit cca2767

Browse files
authored
List refactoring v5 (#8820)
* Squash * Remove BC break * Suppress * Possibly fix * Fixes * Fix test * Trigger build * Update psl * Update psl * Fixes * Fixes * Cleanup * fix * Fix build * Do not consider never when getting the max count * Add assertion * Cleanup * Fix * Cleanup
1 parent 794ca93 commit cca2767

File tree

104 files changed

+2094
-1681
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+2094
-1681
lines changed

UPGRADING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Upgrading from Psalm 5 to Psalm 6
2+
## Changed
3+
4+
- [BC] Switched the internal representation of `list<T>` and `non-empty-list<T>` from the TList and TNonEmptyList classes to an unsealed list shape: the TList, TNonEmptyList and TCallableList classes were removed.
5+
Nothing will change for users: the `list<T>` and `non-empty-list<T>` syntax will remain supported and its semantics unchanged.
6+
Psalm 5 already deprecates the `TList`, `TNonEmptyList` and `TCallableList` classes: use `\Psalm\Type::getListAtomic`, `\Psalm\Type::getNonEmptyListAtomic` and `\Psalm\Type::getCallableListAtomic` to instantiate list atomics, or directly instantiate TKeyedArray objects with `is_list=true` where appropriate.
7+
8+
- [BC] The only optional boolean parameter of `TKeyedArray::getGenericArrayType` was removed, and was replaced with a string parameter with a different meaning.
9+
110
# Upgrading from Psalm 4 to Psalm 5
211
## Changed
312

bin/psl-psalm-plugin.diff

Lines changed: 0 additions & 138 deletions
This file was deleted.

bin/test-with-real-projects.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ collections)
3030
;;
3131

3232
psl)
33+
# For circleCI
34+
export PHP_EXTENSION_INTL=1
35+
export PHP_EXTENSION_BCMATH=1
36+
3337
git clone [email protected]:psalm/endtoend-test-psl.git
3438
cd endtoend-test-psl
35-
git checkout 1.9.x-array
36-
composer require --dev php-standard-library/psalm-plugin:^1.1.4 --ignore-platform-reqs
37-
cd vendor/php-standard-library/psalm-plugin
38-
patch -p1 < $SCRIPT_DIR/psl-psalm-plugin.diff
39-
cd ../../../
40-
cd tools/phpbench && composer install --ignore-platform-reqs && cd ../..
41-
"$PSALM" --monochrome --config=tools/psalm/psalm.xml
39+
git checkout 2.3.x
40+
composer install
41+
"$PSALM" --monochrome -c config/psalm.xml
42+
"$PSALM" --monochrome -c config/psalm.xml tests/static-analysis
4243
;;
4344

4445
laravel)
@@ -47,6 +48,7 @@ laravel)
4748
composer install
4849
"$PSALM" --monochrome
4950
;;
51+
5052
*)
5153
echo "Usage: test-with-real-projects.sh {phpunit|collections|laravel|psl}"
5254
exit 1

docs/running_psalm/plugins/plugins_type_system.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ if (true === $first) {
165165

166166
`TArray` - denotes a simple array of the form `array<TKey, TValue>`. It expects an array with two elements, both union types.
167167

168-
`TList` - Represents an array that has some particularities: its keys are integers, they start at 0, they are consecutive and go upwards (no negative int)
169-
170168
`TNonEmptyArray` - as above, but denotes an array known to be non-empty.
171169

172170
`TKeyedArray` represents an 'object-like array' - an array with known keys.
@@ -176,6 +174,8 @@ $x = ["a" => 1, "b" => 2]; // is TKeyedArray, array{a: int, b: int}
176174
$y = rand(0, 1) ? ["a" => null] : ["a" => 1, "b" => "b"]; // is TKeyedArray with optional keys/values, array{a: ?int, b?: string}
177175
```
178176

177+
This type is also used to represent lists (instead of the now-deprecated `TList` type).
178+
179179
Note that not all associative arrays are considered object-like. If the keys are not known, the array is treated as a mapping between two types.
180180

181181
``` php
@@ -185,8 +185,6 @@ foreach (range(1,1) as $_) $a[(string)rand(0,1)] = rand(0,1); // array<string,in
185185

186186
`TCallableArray` - denotes an array that is _also_ `callable`.
187187

188-
`TCallableList` - denotes a list that is _also_ `callable`.
189-
190188
`TCallableKeyedArray` - denotes an object-like array that is _also_ `callable`.
191189

192190
`TClassStringMap` - Represents an array where the type of each value is a function of its string key value

0 commit comments

Comments
 (0)