Oliver Hader
e457a7d5af
[FEATURE] Allow plugins to declare their custom scanner or analyzer ( #5883 )
...
* [FEATURE] Allow plugins to declare their custom scanner or analyzer
Related: #5882
* [TEST] Check plugin declaring own scanner/analyzer
* [TASK] Document plugins declaring scanner or analyzer
* [TEST] Clean up code
* [!!!][TASK] Extend Psalm\Plugin\RegistrationInterface
* add method `addFileTypeScanner(string $fileExtension, string $className): void`
* add method `addFileTypeAnalyzer(string $fileExtension, string $className): void`
* [TASK] Ignore IntelliJ/PhpStorm workspace folder in VCS
* [TASK] Remove superfluous class import
2021-06-04 15:32:53 -04:00
Fran Moreno
e89f7e3960
Add mongodb Cursor and CursorInterface stubs and fix WriteConcern::__construct ( #5813 )
...
* Add mongodb Cursor and CursorInterface stubs
* Use proper variable name
* Update WriteConcern constructor
Based on https://www.php.net/manual/es/mongodb-driver-writeconcern.construct.php
2021-05-22 19:03:07 -04:00
Matthew Brown
832a190dd4
Support enums ( #5699 )
...
* Add initial enum preparation
* Support cases method
* Ignore bad use error
cc @weirdan
* Fix type
2021-05-03 17:54:09 -04:00
Bruce Weirdan
105c6f3a1c
Remove (and prevent) unused uses ( #5704 )
...
* Updates `slevomat/coding-standard`
* Removes unused uses
* Prevents unused uses
* Fixes a number of symbol case mismatches
2021-05-03 17:22:15 -04:00
Matt Brown
ece138562f
Fix too-long line
2021-03-30 18:39:51 -04:00
Martin Gold
667568d925
Double directory separator on "Cannot resolve stubfile path" ( #5509 )
...
* fix: double directory separator on invalid stubfile path
* fix: non-existing stubfile error message
2021-03-30 11:55:33 -04:00
Matt Brown
d4377c0baf
Check upper bound too
2021-03-28 23:54:38 -04:00
Matt Brown
2d197e3e12
Allow older composer/semver cc @xurizaemon
2021-03-28 23:45:52 -04:00
Matt Brown
9f3f420a5b
Turn on unused variable detection by default on level 1
2021-03-22 09:44:40 -04:00
AndrolGenhald
45694d37d4
Fix composer major.minor version detection ( fixes #5415 ) ( #5416 )
...
* Fix composer major.minor version detection (fixes #5415 )
* Add PHP 8 polyfill dependency.
* Fix version check.
2021-03-18 09:42:01 -04:00
Matt Brown
c05a3ea073
Break up CoreGenericClasses
2021-03-06 16:05:14 -05:00
Vincent Langlet
a80d5b736b
Rename stub to avoid phpstorm conflict ( #5213 )
2021-02-13 18:42:34 -05:00
orklah
0e17a3354f
add stubs for standard iterators ( #4725 )
...
* add stubs for standard iterators
* Apply suggestions from code review cc @weirdan
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
* complete stub + delete code made redundant by stubs + fix some syntax in stubs
* fix parse error
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2021-01-07 10:07:07 -05:00
orklah
f9fccb2b2d
implement DTO for plugins ( #4881 )
...
* implement DTO for plugins
* introduce EventHandler + reintroduce legacy API for plugins
2021-01-06 09:05:53 -05:00
orklah
09fb141e49
Document lowercase-string when possible ( #4904 )
...
* document lowercase-string
* fix missing strtolower
2020-12-29 11:42:12 +00:00
Matt Brown
387ab14bda
Use better stubs for Serializable and SoapClient
2020-12-08 11:27:51 -05:00
Matt Brown
1a629ccc82
Fix a few issues
2020-12-01 18:26:15 -05:00
Matt Brown
b717356f95
Simplify more things
2020-11-27 17:48:39 -05:00
Markus Staab
d393b4a69d
Added PDOStatement->fetchObject() stub ( #4693 )
...
* Added PDOStatement->fetchObject() stub
* fix stub param
* fix Xdebug spelling
* Use extension_loaded check instead
Co-authored-by: Matthew Brown <github@muglug.com>
2020-11-25 12:08:04 -05:00
Markus Staab
3dc311fd45
fixed exception message ( #4692 )
2020-11-24 16:04:34 -05:00
Matt Brown
2c77424e16
Fix #4656 - separate UnusedConstructor from UnusedMethod
2020-11-22 11:48:17 -05:00
Matt Brown
23ab0f1ddb
Allow Psalm to run in taint analysis mode without a config
2020-11-20 19:02:44 -05:00
Matt Brown
854a5b2ec5
Allow TaintedInput to suppress all emitted issues
2020-11-17 16:08:05 -05:00
Matt Brown
b731b53d5e
Add debug stuff for code complexity
2020-11-10 12:49:42 -05:00
Matt Brown
388e804ed8
Allow opt-in to strict return type checking
2020-11-05 18:20:04 -05:00
Matt Brown
cbd09adb2a
Only load xdebug stub afterwards
...
Ref #4459
2020-10-30 15:11:40 -04:00
Matt Brown
579327a470
Detect when targets are incorrectly targeted
2020-10-30 13:28:45 -04:00
Matt Brown
82f35c1454
Ensure Stringable is always available to tests that need it
2020-10-29 19:41:10 -04:00
Matt Brown
2e95d1fb98
Use more robust check for Stringable stub
2020-10-29 14:15:35 -04:00
Matt Brown
0344ff6858
Add polyfill for Stringable interface
2020-10-28 00:55:53 -04:00
Matt Brown
d58642a982
Maintain old behaviour when file does not exist
2020-10-25 16:38:58 -04:00
Matt Brown
2ea41b245c
Fix output in tests (for non-existent files)
2020-10-25 16:31:42 -04:00
Matt Brown
b26983cc34
Fix #4410 - use better path normalisation
2020-10-25 16:18:05 -04:00
feek
cc684eeccd
feature: ensure universal object crate class exists ( #4375 )
2020-10-20 17:17:49 -04:00
orklah
ceaaa39ec3
improve phpdoc ( #4352 )
2020-10-17 12:36:44 -04:00
Matt Brown
f3b05f5ab5
Move static code out of src
2020-10-12 00:59:19 -04:00
feek
8d2db4e673
feature: universal object crates ( #3948 )
...
* feature: universal object crates
* docs: document universal object crate config option
Co-authored-by: Matthew Brown <github@muglug.com>
2020-10-07 09:56:21 -04:00
Matt Brown
377dc8da8f
4.x - change/remove some default config values
2020-10-05 10:08:41 -04:00
Matt Brown
d5f4fd5b9c
4.x - don’t skip checks on unresolvable includes
2020-10-05 09:57:54 -04:00
Saif Eddin G
0475f379aa
add support for 'COMPOSER' env variable for alternate name of 'composer.json' ( #4275 )
2020-10-03 02:26:37 -04:00
orklah
1a1b88bb5e
add visibilities to constants ( #4219 )
2020-09-20 12:54:46 -04:00
orklah
a9a364e363
Misc improvements ( #4216 )
...
* misc changes
* fix CI
2020-09-20 08:55:28 -04:00
orklah
b19f0a7034
Remove empty() and use strict comparison when safe ( #4211 )
...
* replace empty usage with stricter checks
* use strict comparison when safe
* replace is_null with === null for consistency
2020-09-19 18:26:51 -04:00
orklah
5db75dfbf2
align default value with documentation ( #4188 )
2020-09-17 21:40:19 -04:00
Bruce Weirdan
cd110c7e2f
Added @psalm-stub-override
for classlikes and methods ( #4177 )
...
Fixes vimeo/psalm#1252
2020-09-13 16:40:31 -04:00
orklah
da47588f91
replace return;
by return null;
in every non-void method, add return null;
when mising, add return types, remove redundant phpdoc ( #4176 )
2020-09-13 16:39:06 -04:00
orklah
ead107fa9e
More return types ( #4173 )
...
* add native return types
* redundant phpdoc
2020-09-12 11:24:05 -04:00
Brown
6ffe471525
Make new InvalidLiteralArgument issue for strpos refs
...
Ref #4070
2020-09-10 22:54:32 -04:00
Brown
fe4af8ff1a
Minor fixes
2020-09-07 17:22:43 -04:00
Brown
a83c0fe21a
Fix signature
2020-09-07 16:44:09 -04:00
Wouter Sioen
f3d3ef9074
Add consistent array type for predefined constants ( #4151 )
...
When running psalm through https://github.com/Roave/infection-static-analysis-plugin , you get a lot of warnings
```
Warning: array_key_exists() expects parameter 2 to be array, null given in /Users/woutersioen/Sites/madewithlove/htaccess/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Sta
tements/Expression/Fetch/ConstFetchAnalyzer.php on line 124
```
This is because the config is instantiated without calling the collectPredefinedConstants method, thus making this a null value.
By adding a default value, we make it not required to call this method before running psalm.
2020-09-07 10:54:29 -04:00
orklah
8c7423505a
add native param types ( #4137 )
...
* add native param types
* redundant phpdoc
* add more param types and adds "?" to nullable types
* remove redundant phpdoc
* add more param types and remove redundant phpdoc
* add more param types and remove redundant phpdoc
2020-09-06 19:36:47 -04:00
orklah
f66d57f19d
add native return types ( #4116 )
...
* add native return types
* remove redundant phpdoc
2020-09-04 16:26:33 -04:00
the-toster
e296abbabf
Add option to show link to source in console output ( #4085 )
...
* add option to change console output for PhpStorm suitable format, so filenames become links, closes #3271
* fix code style
* rename option to php-storm-format
* replace flag with new report format
* fix code style
2020-09-04 16:24:14 -04:00
Brown
6f92846fd6
Make reportInfo="false" flag better
2020-09-01 18:09:57 -04:00
orklah
c6ea274180
Config reportInfo to speed up analysis for big projects ( #4095 )
2020-09-01 09:22:05 -04:00
Bruce Weirdan
aa09a1c780
Use per-user cache folder ( #4098 )
...
Fixes vimeo/psalm#3869
2020-09-01 09:20:24 -04:00
Brown
92239add4d
Add some backwards-incompatible changes for 4.x
2020-08-30 11:44:14 -04:00
Brown
c13b0efd49
Improve understanding of negated count queries
2020-08-30 11:32:01 -04:00
Matthew Brown
ef0486ce35
Add some pure annotations
2020-08-23 13:52:31 -04:00
Michel Hunziker
3538fe1955
Add configuration attribute to find unused @psalm-suppress ( #4041 )
2020-08-22 10:01:26 -04:00
Matthew Brown
72ecb57def
Improve names of things
2020-08-14 00:27:33 -04:00
Brown
209d17c868
Fix #2891 - treat autoloaded constants better
2020-08-13 09:14:27 -04:00
Brown
6def99d653
Add ConstructorSignatureMismatch issue distinct from MethodSignatureMismatch
2020-08-10 12:26:25 -04:00
lhchavez
ab3016af6e
Fix File-related analysis plugin hooks ( #3970 )
...
This change does a few things:
* Renames `BeforeAnalyzeFileInterface` to `BeforeFileAnalysisInterface`.
* Adds a few more parameters to `BeforeFileAnalysisInterface`.
* Since the analysis was never called due to a bug, the above two
changes are safe to do.
* Fix the above-mentioned bug, and now adds the hooks to the config.
* Update the documentation about the File-related analysis plugin hooks.
* Add a test to ensure that this does not break again in the future.
Fixes : #3969
2020-08-10 10:49:53 -04:00
Matthew Brown
6085e42fc1
Detect mismatching param names effectively
2020-08-10 09:58:43 -04:00
Brown
488a899823
Fix Psalm issues
2020-08-05 19:49:09 -04:00
Nat Zimmermann
a1a403e046
make meta path optional ( #3833 )
2020-07-17 10:09:42 -04:00
kesselb
aaba3a08ec
Add option to supress a referenced but undefined global variable. ( #3827 )
2020-07-16 09:49:59 -04:00
Bruce Weirdan
931d35a703
Collect and scan files included by the autoloaders ( #3183 )
...
Refs vimeo/psalm#2861
2020-07-11 17:17:22 -04:00
Jon Ursenbach
6aca4c169e
feat: adding a runTaintAnalysis option into the config ( #3800 )
2020-07-10 13:22:03 -04:00
Joe Hoyle
0119cd09c1
Always deep scan stubs ( #3781 )
...
In many sitations, stub files will receive a shallow _and_ deep scan when project files require extra analysys on things like parent classes. This makes stub file scanning inconsistent (orders become much less predictable for example), and adds extra process time to scan the files twice. In the case of stubs providing classes and functions for large projects, this is a non-trivial amount of time.
As deep scanning stubs should take just about as long as a shallow scan, it makes sense to just always deep scan them.
Fixes #3568 .
2020-07-08 17:42:51 -04:00
Tyson Andre
bee10a2eb4
Add a --debug-emitted-issues flag ( #3637 )
...
And support --debug-by-line in psalter and psalm-refactor.
Those were previously not supported in getopt()
Fixes #3634
2020-06-22 18:16:47 -04:00
Brown
fbe3433edd
Use escape terminology
2020-06-21 11:43:08 -04:00
Brown
078b8b7b1a
Fix #3618 - add way to load non-analyzed files
2020-06-19 00:13:09 -04:00
Olle Härstedt
e1cc27f7a2
Add new config: sealAllMethods ( #3578 )
...
* Add new config: sealAllMethods
* Add some more tests
* Fix codesniffer issue with preg_quote
* Fix missing method in test
Co-authored-by: Olle <noemail>
2020-06-15 22:36:42 -04:00
orklah
76f5def268
Use scandir and glob flags to reduce their performance impact ( #3499 )
...
* Use scandir and glob flags to reduce their performance impact
* Order seem to impact Tests here
2020-05-30 17:02:35 -04:00
Brown
a266d4748b
Fix build
2020-05-26 07:50:11 -04:00
Brown
953be61cf2
Allow limiting connected taint paths
2020-05-25 23:28:11 -04:00
Matthew Brown
f3a6e1a48c
Fix ref
2020-05-10 16:01:45 -04:00
Matthew Brown
733da0e539
Fix #3311 - don’t erroneously mark a class as undefined
...
As they can sometimes only be obvious once an autoloader has been registered
2020-05-10 15:55:44 -04:00
orklah
8571746f8a
Add hook for plugins after FunctionLikeAnalysis ( #3258 )
2020-04-28 15:30:51 -04:00
Brown
4b36c4e4bf
Add stub for json_encode
2020-04-04 11:18:24 -04:00
Brown
f6759c3d16
Check return statement types for inherited docblocks
2020-03-24 17:59:48 -04:00
Brown
d1fcbf38ae
Fix #2956 - treat Exception::getMessage as final and mutation-free
2020-03-10 15:12:55 -04:00
Matthew Brown
6129d533d8
Fix #2879 - rename stubs to prevent issues in PHPStorm
2020-03-01 17:28:51 -05:00
Philip Hofstetter
d315822bfa
make skipping of checks after invalid includes configurable
...
as suggested in the PR it's best to make the setting configurable.
In order not to break existing installations, we default to keeping the
old behaviour, but in a later version of psalm, we might change the
default.
2020-02-27 18:49:23 -05:00
kolja
f189b25b99
Fixed stub files with absolute paths not being loaded.
2020-02-26 17:13:40 -05:00
Matthew Brown
2e4154d76e
Add better defaults and documentation
2020-02-18 20:30:37 -05:00
Matthew Brown
c9494c43a3
Hide mixed issues if totallyTyped="false"
2020-02-18 20:08:09 -05:00
Matthew Brown
23b9331f6d
Hide mixed errors if your error level is >= 3
2020-02-18 19:57:38 -05:00
Brown
520b646ef6
Add suppressMixedIssues config flag to hide mixed issues
2020-02-18 17:23:48 -05:00
Brown
6e8088776d
Use better return type for SimpleXMLElement::offsetGet
2020-02-18 10:58:56 -05:00
Brown
38cccb8aaf
Fix #2831 - use correct name for mapping
2020-02-18 10:39:24 -05:00
Matthew Brown
201d54f232
Convert to string before comparison
2020-02-18 09:40:21 -05:00
Matthew Brown
320f3ec863
Update level config name
2020-02-17 22:43:13 -05:00
Matthew Brown
aab8eed219
Fix Phar-scoped issue checks
2020-02-17 22:07:08 -05:00
Matthew Brown
0c2b10709e
If no level or totallyTyped is given, use level 2
2020-02-17 22:06:55 -05:00
Matthew Brown
f49c896f94
Allow totallyTyped to control level
2020-02-17 22:06:46 -05:00
Matthew Brown
ced092874a
Make config generation smarter
2020-02-17 22:05:58 -05:00