sn1054 / psalm-for-moodle
A fork of vimeo/psalm for Moodle
Installs: 6 196
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0
- ext-ctype: *
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-mbstring: *
- ext-simplexml: *
- ext-tokenizer: *
- amphp/amp: ^2.4.2
- amphp/byte-stream: ^1.5
- composer/package-versions-deprecated: ^1.10.0
- composer/semver: ^1.4 || ^2.0 || ^3.0
- composer/xdebug-handler: ^2.0 || ^3.0
- dnoegel/php-xdg-base-dir: ^0.1.1
- felixfbecker/advanced-json-rpc: ^3.1
- felixfbecker/language-server-protocol: ^1.5.2
- fidry/cpu-core-counter: ^0.4.0
- netresearch/jsonmapper: ^1.0 || ^2.0 || ^3.0 || ^4.0
- nikic/php-parser: ^4.13
- sebastian/diff: ^4.0 || ^5.0
- spatie/array-to-xml: ^2.17.0
- symfony/console: ^4.1.6 || ^5.0 || ^6.0
- symfony/filesystem: ^5.4 || ^6.0
Requires (Dev)
- ext-curl: *
- bamarni/composer-bin-plugin: ^1.4
- brianium/paratest: ^6.0
- mockery/mockery: ^1.5
- nunomaduro/mock-final-classes: ^1.1
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpdoc-parser: ^1.6
- phpunit/phpunit: ^9.5
- psalm/plugin-mockery: ^1.1
- psalm/plugin-phpunit: ^0.18
- slevomat/coding-standard: ^8.4
- squizlabs/php_codesniffer: ^3.6
- symfony/process: ^4.4 || ^5.0 || ^6.0
Suggests
- ext-curl: In order to send data to shepherd
- ext-igbinary: ^2.0.5 is required, used to serialize caching data
Provides
- psalm/psalm: dev-master
This package is not auto-updated.
Last update: 2024-12-13 00:52:16 UTC
README
Psalm is a static analysis tool that attempts to dig into your program and find as many type-related bugs as possible.
It has a few features that go further than other similar tools:
-
Mixed type warnings
If Psalm cannot infer a type for an expression then it uses amixed
placeholder type.mixed
types can sometimes mask bugs, so keeping track of them helps you avoid a number of common pitfalls. -
Intelligent logic checks
Psalm keeps track of logical assertions made about your code, soif ($a && $a) {}
andif ($a && !$a) {}
are both treated as issues. Psalm also keeps track of logical assertions made in prior code paths, preventing issues likeif ($a) {} elseif ($a) {}
. -
Property initialisation checks
Psalm checks that all properties of a given object have values after the constructor is called. -
Taint analysis
Psalm can detect security vulnerabilities in your code. -
Language Server
Psalm has a Language Server that’s compatible with a range of different IDEs. -
Automatic fixes
Psalm can fix many of the issues it finds automatically. -
Automatic refactoring
Psalm can also perform simple refactors from the command line.
Example output
Given a file implode_strings.php
:
<?php $a = ['foo', 'bar']; echo implode($a, ' ');
> ./vendor/bin/psalm implode_strings.php ERROR: InvalidArgument - somefile.php:3:14 - Argument 1 of implode expects `string`, `array` provided (see https://psalm.dev/004)
Inspirations
There are two main inspirations for Psalm:
- Etsy's Phan, which uses nikic's php-ast extension to create an abstract syntax tree
- Facebook's Hack, a PHP-like language that supports many advanced typing features natively, so docblocks aren't necessary.
Index
- Running Psalm:
- Annotating code:
- Manipulating code: