You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,6 +107,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
107
107
108
108
### Fixed
109
109
110
+
-**`array_filter()` reports the type the filter leaves behind.** A callback that tests the value it is handed proves something about every entry that survives, but the result kept whatever element type went in, so `array_filter($values, fn ($v) => $v !== null)` still looked like it could hold `null` and returning it from a function declared `int[]` was reported as a type error. The surviving values are now narrowed the way the body of an `if` narrows the variable it guards, whether the test is written as an `is_…()` call, a comparison against `null`, an `instanceof` check, or a callable string such as `'is_int'`. The keys were already narrowed this way in the modes that hand the callback a key, and both halves narrow together under `ARRAY_FILTER_USE_BOTH`. Closes #376.
110
111
-**A deprecation warning belongs to the variable it is written on.** The deprecated-usage check typed its subject from a cache keyed by variable name and class, so two methods of the same class that reuse a parameter name shared one entry and whichever type was bound first won. A Laravel controller with a `Request $request` method above a `PendingRequest $request` method reported `Illuminate\Http\Request::get is deprecated` on the HTTP client call, where `get()` is the ordinary way to make a request, and renaming either parameter made the warning vanish. Every subject is now typed in the scope it is written in, so each method, closure, and `instanceof` branch gets its own answer, and a genuine deprecation is still reported no matter which order the methods appear in.
111
112
-**A generic argument left out takes the default its `@template` declares.**`@template TAsync of bool = false` says that a use of the class without a generic argument means `false`, but the parameter was widened to its upper bound instead, so a conditional return keyed on it always picked the else branch. Laravel's HTTP client is where this shows up: `PendingRequest` declares synchronous mode as its default, so an ordinary `Http::get()` looked like it returned a promise rather than a `Response`, and `json()` along with the rest of the response API appeared to be missing on it. A plain request now resolves to `Response` whether it is made through `PendingRequest`, the client factory, or the `Http` facade, and `async()` still resolves to `PromiseInterface` through all three. Contributed by @shuvroroy (#377).
112
113
-**A conditional assertion narrows the value the call was written on.**`if (filled($search))` left a `?string` nullable inside the branch, so passing it on to something that expects a `string` was reported as an error. Two things stood in the way, and Laravel's `filled()` and `blank()` hit both. An asserted type written as a union (`!=null|''`, which is how the pair is annotated) matched no type guard at all and narrowed nothing; ruling one out now rules out each of its members on its own. And a tag written in the equality form was being inverted into the branch it does not name, which typed every filled value as `numeric|bool`. Those tags promise something in one direction only, so they are now left out of the opposite branch, while the subtype form (`!null`) keeps narrowing both. Closes #375.
Copy file name to clipboardExpand all lines: docs/todo.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,7 @@ unlikely to move the needle for most users.
102
102
| T10 |[Ternary expression as RHS of list destructuring](todo/type-inference.md#t10-ternary-expression-as-rhs-of-list-destructuring)| Low | Medium |
103
103
| T11 |[Nested list destructuring](todo/type-inference.md#t11-nested-list-destructuring)| Low | Medium |
104
104
||**[Bugs](todo/bugs.md)**|||
105
+
| B181 |[`array_filter()` reports a `list` the filter cannot preserve](todo/bugs.md#b181-array_filter-reports-a-list-the-filter-cannot-preserve)| Low-Medium | Medium |
105
106
||**[Diagnostics](todo/diagnostics.md)**|||
106
107
| D6 |[Unreachable code diagnostic](todo/diagnostics.md#d6-unreachable-code-diagnostic)| Low-Medium | Medium |
0 commit comments