Skip to content

Commit

Permalink
Squash
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Dec 4, 2022
1 parent 16d81aa commit 499c6b7
Show file tree
Hide file tree
Showing 106 changed files with 2,067 additions and 1,517 deletions.
9 changes: 9 additions & 0 deletions UPGRADING.md
@@ -1,3 +1,12 @@
# Upgrading from Psalm 5 to Psalm 6
## Changed

- [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.
Nothing will change for users: the `list<T>` and `non-empty-list<T>` syntax will remain supported and its semantics unchanged.
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.

- [BC] The only optional boolean parameter of `TKeyedArray::getGenericArrayType` was removed, and was replaced with a string parameter with a different meaning.

# Upgrading from Psalm 4 to Psalm 5
## Changed

Expand Down
6 changes: 2 additions & 4 deletions docs/running_psalm/plugins/plugins_type_system.md
Expand Up @@ -165,8 +165,6 @@ if (true === $first) {

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

`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)

`TNonEmptyArray` - as above, but denotes an array known to be non-empty.

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

This type is also used to represent lists (instead of the now-deprecated `TList` type).

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.

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

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

`TCallableList` - denotes a list that is _also_ `callable`.

`TCallableKeyedArray` - denotes an object-like array that is _also_ `callable`.

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

0 comments on commit 499c6b7

Please sign in to comment.