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
{{ message }}
Repository navigation
Commit bb7edee
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: NEWS.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
@@ -4,6 +4,7 @@ Phan 6.0.8-dev
4
4
--------------
5
5
6
6
Bug fixes:
7
+
- Constants declared with `define()` no longer have their real type erased, and `constant('NAME')` no longer returns `mixed` for them. This detects e.g. `PhanImpossibleTypeComparison` for `STRING_CONST === $int`. The real type is widened to the non-literal type (`false` becomes `bool`, `120` becomes `int`) so that conditions on configuration constants such as `if (DEBUG_MODE)` are still not reported as redundant/impossible. When the same constant is passed to `define()` in several places (e.g. both branches of an `if`/`else`), the types of all of them are now unioned instead of only using the first one seen ([#5542](https://github.com/phan/phan/issues/5542))
7
8
- Fix false positives (e.g. `PhanTypeMismatchArgumentNullable`, `PhanPluginNeverReturnMethod`) when a branch calls a `never`-returning instance method on a local variable assigned with `new ClassName()` — the branch is now correctly treated as unreachable ([#5553](https://github.com/phan/phan/issues/5553))
8
9
- Fix crash (`ArgumentCountError: Too few arguments to function Phan\Language\Type::isCallable()`) when `is_callable()` narrowing is applied to a value with an intersection type, e.g. `(callable&T)|null` ([#5555](https://github.com/phan/phan/issues/5555), [#5557](https://github.com/phan/phan/pull/5557))
9
10
- Fix `@var Foo<T>` losing its template parameter on properties that also have a native type declaration (e.g. `/** @var Box<A> */ private Box $box;` was inferred as `Box|Box<A>` instead of `Box<A>`, making method calls on `$box` return `mixed` instead of the template argument) ([#5556](https://github.com/phan/phan/issues/5556))
Copy file name to clipboardExpand all lines: src/Phan/Parse/ParseVisitor.php
+55-10Lines changed: 55 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@
9
9
useast\Node;
10
10
useInvalidArgumentException;
11
11
usePhan\Analysis\ScopeVisitor;
12
+
usePhan\AST\ASTHasher;
12
13
usePhan\AST\ASTReverter;
13
14
usePhan\AST\ContextNode;
14
15
usePhan\AST\UnionTypeVisitor;
@@ -1925,17 +1926,37 @@ public static function addConstant(
1925
1926
// define() is typically used to conditionally set constants or to set them to variable values.
1926
1927
// TODO: Could add 'configuration_constant_set' to add additional constants to treat as dynamic such as PHP_OS, PHP_VERSION_ID, etc. (convert literals to non-literal types?)
0 commit comments