1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-12 17:27:28 +01:00
Commit Graph

543 Commits

Author SHA1 Message Date
sasezaki
5a01c8d601 Added phpcs SelfMemberReference rule, and applied 2021-11-07 15:47:39 +09:00
orklah
3503f198a6 add deprecated tags to the array 2021-11-04 00:39:09 +01:00
orklah
1288d49130 add SimpleXMLIterator to universalObjectCrates 2021-10-18 21:59:17 +02:00
orklah
ef7e6cdf01 allow Psalm to choose PHP8.1 if it's the lower PHP version allowed 2021-10-14 16:54:27 +02:00
orklah
8660f68007
Merge pull request #6519 from gmessier/advanced-issue-handlers
Add support for advanced IssueHandler in plugins
2021-10-04 09:47:59 +02:00
orklah
430fd619ec cleanup 2021-10-04 00:23:53 +02:00
orklah
ab6efe49b2 fix CS 2021-09-26 23:41:26 +02:00
orklah
38dac34846 unnecessary null initialization 2021-09-26 23:34:32 +02:00
orklah
c91bdfb689 old casts 2021-09-26 23:34:32 +02:00
orklah
72eab30a3a coalesce operator 2021-09-26 23:34:31 +02:00
orklah
46801c4b98 clearer string operations 2021-09-26 23:34:31 +02:00
Guillaume Messier
c9db2dfb53 Merge branch 'master' of https://github.com/gmessier/psalm into advanced-issue-handlers 2021-09-24 12:48:12 +00:00
orklah
c74e81ca8f fix build 2021-09-23 19:29:15 +02:00
Guillaume Messier
666367fbd5 Add unit test 2021-09-23 15:30:30 +00:00
Guillaume Messier
97a3f54164 Add support for advanced IssueHandler in plugins 2021-09-22 14:56:07 +00:00
Tyson Andre
3486490080 Use different psalm cache for different error levels
Fixes #4952
2021-08-06 12:46:15 -04:00
orklah
58dd3f6f94 change wording 2021-07-20 23:53:04 +02:00
orklah
acfdb82856 Basic implementation 2021-07-20 23:34:38 +02:00
Joshua Behrens
0c6031f7f2
Use same working directory for preparing cache directory as it used in running analysis 2021-07-17 01:55:41 +03:00
Bruce Weirdan
e552925af6
Emit separate type of issue when foreach value is unused (#5932)
* Emit separate type of issue when foreach value is unused

Fixes vimeo/psalm#5929

* Fixed var name case sensitivity
2021-06-17 00:40:24 -04:00
Matt Brown
47bf5ed567 Fix #5918 - add new issue to detect unquoted strings 2021-06-10 17:43:04 -04:00
Bruce Weirdan
6abce3525a
Enforce use sort (#5900) 2021-06-07 22:55:21 -04:00
Matthew Brown
7301e3a35f Fix redundant cast 2021-06-07 13:19:00 -04:00
Bruce Weirdan
86050df4d0
Formally deprecate allowCoercionFromStringToClassConst (#5897)
* Mark allowCoercionFromStringToClassConst as deprecated in xml schema

* Emit deprecation warning for `allowCoercionFromStringToClassConst`
2021-06-07 10:46:26 -04:00
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
Philip Hofstetter
395cf587d3 add plugin hook to be called after every function call
compared to AfterFunctionCallAnalysisInterface which gets only called
after a call to a function declared within the project, a plugin
implementing AfterEveryFunctionCallAnalysisInterface will get called for
every function call, including calls of PHP builtins.

On the other hand, this interface doesn't allow modification of the code
nor tweaking the return type, but it's still useful for accounting
purposes and for depreacting calls to PHP builtins

this fixes #2804
2020-02-13 09:10:24 -05:00
Matthew Brown
8d7fb2b415 Add config flag to support properties without a magic getter 2020-02-02 14:23:38 -05:00
Philip Hofstetter
f6983fd883 allow setting php version from config or composer.json
if a composer.json is present and a PHP version requirement is
configured, we set the php version to the minimal PHP version that
satisfies the composer requirement.

Additionally, this adds a `phpVersion` attribute to the <psalm> tag. If
that's set, it takes precedence over what has been detected in
composer.json.

And finally, the --php-version command line flag continues to work and
takes precedence over the setting in the <psalm> tag

this fixes #2628
2020-01-30 08:48:53 -05:00
SignpostMarv
dc80880a80 check if phpstorm meta path is a file or directory (#2643)
* check if phpstorm meta path is a file or directory, making a note if it was a directory, re: #2640

* import is_file()

* overcautiously glob into meta directory
2020-01-22 11:06:06 -05:00
Bruce Weirdan
17857163fc Modular config files (#2635)
This change introduces an option to have the configuration split across
several files using standard XInclude tags. This may be useful for more
complex configs, or to include auto-generated parts into a manually
written config file.
2020-01-16 15:57:52 -05:00
Brown
bd2cbf28e3 Add parent issue type for UndefinedMagicMethod 2020-01-06 14:24:20 -05:00
Matthew Brown
867511d7fd Use more specific error magic properties 2020-01-05 21:07:26 -05:00
Matthew Brown
a154191922 Fix #2380 - prevent string docblock for callable param 2019-11-27 09:18:47 -05:00
Brown
af5f83602e Break out more specific possibly defined offset errors 2019-11-11 09:59:56 -05:00
Brown
89752b8574 Support ext-ds and fix offset count 2019-10-18 11:35:24 -04:00
Brown
b0aaede9e1 Add support for checking integer array offsets 2019-10-04 11:08:08 -04:00
Matthew Brown
9ad6c36d9b
Conditionally verify that array offsets exist (#2147)
* Check array offsets idea

* Clean up some issues

* Add a few light fixes

* Add docs
2019-09-18 14:21:06 -04:00
SignpostMarv
943705ce0e load an xdebug stub when required, re: vimeo/psalm#2118 (#2133)
* load an xdebug stub when required, re: vimeo/psalm#2118

* correcting case sensitivity of XDebug to Xdebug

* only load the Xdebug stub when needed
2019-09-14 10:13:39 -04:00
Matthew Brown
51e552665e Fix #2061 - add config to allow suppression of string increment issues 2019-09-01 17:49:37 -04:00
Matthew Brown
6ad5d31132 Fix how hideExternalErrors behaves to match expectation
Fixes #2074
2019-09-01 10:56:55 -04:00
Brown
95c61db513 Add a PossibleRawObjectIteration issue 2019-08-20 12:06:02 -04:00
Matthew Brown
c5f62d261d Remove redundant @psalm-suppress in Psalm’s codebsae 2019-08-18 16:10:12 -04:00
Matthew Brown
5d94e340ee Remove unused suppressions in tests 2019-08-18 15:34:32 -04:00
Matthew Brown
2146f73782 Prepare for tracking unused suppressions
Ref #1444
2019-08-18 12:25:48 -04:00
Tyson Andre
ce03be2dc0 Add BeforeAnalyzeFileInterface (#2034)
This is a prerequisite of the plugin I mentioned in #378

This may be useful for other types of plugins
(e.g. checking raw file contents or file names)
2019-08-18 10:40:07 -04:00
Matthew Brown
c5d1c9aa54 Add slash 2019-07-21 16:22:04 -04:00
Matthew Brown
3f098bafbc Also convert \\ to / when scanning windows configs on macs 2019-07-21 11:34:32 -04:00
Matthew Brown
39c437a54a Fix file path weirdness when scanning config files 2019-07-21 11:32:49 -04:00
SignpostMarv
9ac78b5d10 add psalm config attribute re: #1804 (#1936)
* add psalm config attribute for controlling the default inclusion of php & php extension version info in the error baseline

* using method recommended by @bdsl in https://github.com/vimeo/psalm/pull/1936#discussion_r302727993
2019-07-12 10:31:12 -04:00
Bruce Weirdan
173a40e769 Deprecated Psalm\isAbsolutPath in favor of Webmozart\PathUtil\Path::isAbsolute (#1921) 2019-07-07 21:20:12 -04:00
Barney Laurance
ea83068deb Allow resolving directories from config file location (continued) (#1910)
* Extract function getPsalmHelpText() from psalm.php

* Extract initialiseConfig from psalm.php

* Add -c as valid short option for psalter and psalm-refactor

* Use initialiseConfig in psalter, psalm-refactor and psalm-language-server as well as psalm

* Rely on psalm --alter resolving directory from config file in test

* Remove erronous condition for config file path

This code was based on me wrongly thinking that the config file location
was seprated from the argument name with a space instead of an equals
sign

* Use config dir as current dir in psalm and psalm-refactor, as with psalter and psalm-language-server

* Remove redundant duplicated code

* Refactor: move calls to \Psalm\Config::setComposerClassLoader inside initialiseConfig

* PHPCS fix

* Extract function get_path_to_config from command scripts

* Refactor - extract functions from \Psalm\Config::loadFromXML

* Refactor - reduce verbosity of config loading code

* Allow running e2e tests on windows

* Fix testCompactReport on Windows

* convert line endings to make testCompactReport pass on Windows
2019-07-07 08:55:53 -04:00
Barney Laurance
94f934627c Work in progress - resolve directories from config file location (#1904)
* Add resolveFromConfigFile config option

Treats all paths as relative to the location of the config file, not
the current working directory of the process.

This commit just changes psalm, further commits will be needed to
apply the change to psalter and the LSP server.

* Copy asset xml files into project root for testing, delete during teardown

Needed since paths are now resolved relative to the position of the
file.

Not sure why I only saw a test failre for 1.xml - would have expected it
for all eight files.

* Fix following rebase

* Move psalm --init handly code above working directory setting code

If there's no psalm.xml yet we can't use the location of psalm.xml to
set our working directory

* Move Psalm version output code above working directory resolution

Working directory doesn't need to be known to output version constant

* Rely on new config file based working directory in end to end test

* Dont use rely on config dir for --alter - not currently working

* Fix code style error

* Add failing test for supporting config without `resolveFromConfigFile="true"`

* Don't treat config directory as a path to check

* Document resolveFromConfigFile setting
2019-07-06 12:21:39 -04:00
Matthew Brown
da42be175f Apply PHPCS fixes
Fixes #1880
2019-07-05 16:27:53 -04:00
LeSuisse
f29826b958 Fully qualify constants and function calls (#1849)
This should give a small performance boost.
Part of #1837.

The change is enforced via phpcs and can be autofixed
with phpcbf.
2019-06-26 16:52:29 -04:00
Matthew Brown
7fc11af49e Fix docblocks with @andrew-demb’s suggestions 2019-06-16 09:12:32 -04:00
Matthew Brown
389c196566 Fix #1779 - non-zero exit code when config not found 2019-06-13 19:34:57 -04:00
Brown
c21e9917fa Add config flag to prevent inferring property types from constructor 2019-06-10 14:41:21 -04:00
Matthew Brown
b5cbc84351 Fix #1617 - add option to only show errors in reports 2019-06-09 12:37:28 -04:00
Matthew Brown
ad4e2f72e2 Add means to guess PSR4 file path 2019-06-05 08:50:24 -04:00
Bruce Weirdan
8534955572 Namespace autoloaded functions (#1724)
Since functions defined in files referenced in 'files' section in
composer autoload config are automatically loaded when composer
autoloader is included (for example when Psalm is installed into project
vendors), it's good idea to keep them namespaced. Otherwise it would
prevent dependents to declare their own functions in the global
namespace with the same names.
2019-06-02 11:23:25 -04:00
Bruce Weirdan
169121b6fd Fall back to autoload when loading plugin classes (#1717)
* Fall back to autoload when loading plugin classes

This allows to use plugins installed alongside Psalm (when it's not
installed in the project being analyzed).

This fixes (partially) vimeo/psalm#1710

* cs fix
2019-06-01 08:53:42 -04:00
Bruce Weirdan
1b0158ad72 Fixed vimeo/psalm#1714 (#1715)
* Fixed vimeo/psalm#1714

Moved `isAbsolutePath()` into a functions file (`src/functions.php`)
that is now automatically loaded by composer autoload.

/cc: @jwage

* Dropped redundant bootstrap
2019-06-01 08:26:22 -04:00
Ilija Tovilo
5a14e4b1cf Progress bar (#1709)
* Revert "Revert "Implement better progress""

This reverts commit 4302596654.

* Revert "Revert "Implement dots progress bar""

This reverts commit e41733d789.

* Revert "Revert "Switch to VoidProgress by default""

This reverts commit 304ffeb0a3.

* Revert "Revert "Pass success flag to progress""

This reverts commit 62a690ee4e.

* Improve socket communication

* Use an underscore

* Add means to disable progress

* Add extra newline before progress bar
2019-05-30 10:30:41 -04:00
Matthew Brown
4302596654 Revert "Implement better progress"
This reverts commit 042070d0fd.
2019-05-27 13:07:02 -04:00
Matthew Brown
304ffeb0a3 Revert "Switch to VoidProgress by default"
This reverts commit 63b46be361.
2019-05-27 13:04:38 -04:00
Ilija Tovilo
63b46be361 Switch to VoidProgress by default 2019-05-26 23:18:48 -04:00
Ilija Tovilo
042070d0fd Implement better progress 2019-05-26 23:18:48 -04:00
Matthew Brown
a1eb191f57 Remove TSqlSelectString and related dependency 2019-05-20 23:14:41 -04:00
Brown
4a434d9a2f Add separate issue for undefined classes in docblocks 2019-05-15 18:41:26 -04:00
Brown
30cbcb6c36 Add ImplementedParamTypeMismatch issue
Fixes #1633
2019-05-14 15:44:46 -04:00
Brown
1db0e38b08 Invalidate cache when Psalm version changes 2019-05-08 11:58:34 -04:00
Jonathan H. Wage
ecb7a6c069 Add support for absolute plugin paths. 2019-05-05 16:44:36 -04:00
Brown
dd40987187 Consolidate location of issue handling 2019-05-03 17:12:20 -04:00
Brown
b9bece4cbc Allow MixedArrayTypeCoercion to be properly suppressed by default 2019-04-29 12:19:51 -04:00
Brown
f760ab6707 Add better reporting for errors 2019-04-29 12:07:34 -04:00
Brown
1413ccd111 Prevent phar path rejiggering 2019-04-29 11:33:13 -04:00
Matthew Brown
e08944cae0 Allow diff mode with --find-dead-code 2019-04-27 17:38:24 -04:00
Brown
0e4c8ce482 Split apart TypeCoercion issues, allowing more granular issue filtering 2019-04-25 18:02:19 -04:00
Brown
d1f4622a80 Fix #1542 - disable SQL parsing by default 2019-04-22 10:01:25 -04:00
Matthew Brown
79ae72d553 Fix #935 - allow Phar to run without composer files 2019-04-20 16:37:27 -04:00
bugreportuser
2e147585a1 Allow ignoring exceptions only in global scope 2019-04-16 22:42:45 -04:00
Matthew Brown
c297b91d6f Fix possibly null property 2019-04-14 13:04:25 -04:00
Brown
7f8b47c5cf Fix buggy behaviour around callable tests 2019-04-09 18:09:57 -04:00
Matthew Brown
bd48ba858e Add @SignpostMarv’s fixes for Windows tests 2019-03-31 19:08:55 -04:00
SignpostMarv
83d8e7f03c swapping order of mkdir & is_dir, as per #1467 2019-03-31 14:21:15 -04:00
Matthew Brown
326249e13b spirit => shepherd 2019-03-31 14:02:30 -04:00
bugreportuser
976c2c5ef3 Add an error for throws in global scope 2019-03-24 23:03:37 -04:00
Matthew Brown
ba603acd7b Send build information to remote server 2019-03-23 12:49:37 -04:00
Matthew Brown
9d4ebe6b6b Add plugin hook for post-analysis stuff 2019-03-23 12:47:46 -04:00
Matthew Brown
ee56419fd6 Improve accuracy and durability of mixed counts 2019-03-23 09:50:47 -04:00
Matthew Brown
472ab29d74 Add PossiblyInvalidCast for more refined checks 2019-03-17 17:10:51 -04:00
bugreportuser
e31cfa503d Allow reconciling superglobal types 2019-03-16 12:49:38 -04:00
bugreportuser
056e5a5b1e Allow setting globals in config 2019-03-06 15:59:41 -05:00
Brown
bd372e93af Add config flags for findUnusedVariables and findUnusedCode 2019-03-05 15:45:09 -05:00
Matthew Brown
317f790bde
New plugin hooks (#1405)
* Add a bunch of new hooks

* Add more integrations

* Add some broken tests

* Add more things

* Fix remaining interfaces

* Suppress proper issue

* UndefinedMethod should not stop analysis

* Add handlers for two custom method return types
2019-03-01 08:57:10 -05:00
Bruce Weirdan
24a71be425 Added Hook\AfterCodebasePopulatedInterface 2019-02-26 01:16:22 -05:00
Bruce Weirdan
8408effe57 Dropped unused uses 2019-02-17 13:17:45 -05:00
Matthew Brown
356a45a155 Improve ergonomics of PHPStorm meta parsing 2019-02-16 18:50:25 -05:00
Matthew Brown
0739d017ac Use information from .phpstorm.meta.php files in stubs 2019-02-16 11:16:52 -05:00
Matthew Brown
c58100e3af Fix #1313 - don’t allow mixed function calls 2019-02-10 16:15:52 -05:00
Brown
3f289731bb Add ability to check descendants in ignored exceptions 2019-01-31 18:40:40 -05:00