forked from vimeo/psalm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support type annotations for class consts (fixes vimeo#942).
- Loading branch information
1 parent
65783c7
commit 52c2558
Showing
16 changed files
with
330 additions
and
59 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
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,22 @@ | ||
# UnresolvableConstant | ||
|
||
Emitted when Psalm cannot resolve a constant used in `key-of` or `value-of`. Note that `static::CONST` is considered | ||
unresolvable for `key-of` and `value-of`, since the literal keys and values can't be resolved due to the possibility | ||
of being overridden by child classes. | ||
|
||
```php | ||
<?php | ||
|
||
class Foo | ||
{ | ||
public const BAR = ['bar']; | ||
|
||
/** | ||
* @return value-of<self::BAT> | ||
*/ | ||
public function bar(): string | ||
{ | ||
return self::BAR[0]; | ||
} | ||
} | ||
``` |
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,23 @@ | ||
<?php | ||
namespace Psalm\Exception; | ||
|
||
use Exception; | ||
|
||
class UnresolvableConstantException extends Exception | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $class_name; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $const_name; | ||
|
||
public function __construct(string $class_name, string $const_name) | ||
{ | ||
$this->class_name = $class_name; | ||
$this->const_name = $const_name; | ||
} | ||
} |
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
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
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
Oops, something went wrong.