mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
144bb37f76
When checking code like the following: ``` <?php function checkNegated(string $key): void { $arr = [ 0 => "foo", 1 => "bar", ]; if (!array_key_exists($key, $arr)) { printf("not found\n"); } } function check(string $key): void { $arr = [ 0 => "foo", 1 => "bar", ]; if (array_key_exists($key, $arr)) { printf("found\n"); } } ``` the `if` in `checkNegated` would cause: ``` ERROR: RedundantCondition - 9:10 - Type string for $key is never =int(0) ``` This happens when the array keys are all int literals, but the "needle" is a string. `array_key_exists()` uses a loose equality comparison, but the generated assertions for this specific case (`AssertionFinder::getArrayKeyExistsAssertions`) was generating strict equality clauses. This commit fixes it by changing the generated clause from `=` to `~`. |
||
---|---|---|
.circleci | ||
.github/workflows | ||
assets/psalm-phar | ||
bin | ||
build/phpunit | ||
dictionaries | ||
docs | ||
examples | ||
src | ||
stubs | ||
tests | ||
vendor-bin/box | ||
.appveyor.yml | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.scrutinizer.yml | ||
box.json.dist | ||
CODE_OF_CONDUCT.md | ||
composer.json | ||
config.xsd | ||
CONTRIBUTING.md | ||
infection.json.dist | ||
keys.asc.gpg | ||
LICENSE | ||
phpcs.xml | ||
phpunit.xml.dist | ||
psalm | ||
psalm-language-server | ||
psalm-plugin | ||
psalm-refactor | ||
psalm.xml.dist | ||
PsalmLogo.png | ||
psalter | ||
README.md | ||
scoper.inc.php |
Psalm
Psalm is a static analysis tool for finding errors in PHP applications.
Installation
To get started, check out the installation guide.
Live Demo
You can play around with Psalm on its website.
Documentation
Documentation is available on Psalm’s website, generated from the docs folder.
Interested in contributing?
Have a look at CONTRIBUTING.md.
Who made this
Built by Matt Brown (@muglug).
Maintained by Matt and Bruce Weirdan (@weirdan).
The engineering team at Vimeo have provided a lot encouragement, especially @nbeliard, @erunion and @nickyr.