-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
phan: Improve phpunit stub munging (#37164)
In Psalm, `@psalm-assert Foo $arg` asserts both that if the function doesn't throw then the argument is an instance of Foo _and_ that if the function does throw then the argument is not an instance of Foo. If you want only the first without the second, you do `@psalm-assert =Foo $arg` instead. Phan, on the other hand, never makes the inverse assumption. So effectively `@phan-assert Foo $arg` is equivalent to `@psalm-assert =Foo $arg`, and trying to `@phan-assert =Foo` is a syntax error. Thus, when we're munging the phpunit annotations, the `=` needs to be stripped when converting `@psalm-assert` to `@phan-assert`. This will allow Phan to infer correct types for `assertInstanceOf()` and `assertSame()`.
- Loading branch information
Showing
5 changed files
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
5 changes: 5 additions & 0 deletions
5
projects/packages/changelogger/changelog/fix-phan-phpunit-stubs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: fixed | ||
Comment: Suppress a Phan issue in a test now that Phan infers classes from assertInstanceOf(). No change to functionality. | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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