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
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
Andrii Dembitskyi
9b6b79728e Fixes #1222 - incorrect config value used for allowStringToStandInForClass
Please make attention, that `allowCoercionFromStringToClassConst` are mentioned in docs, but not used now in config
2019-01-21 09:00:57 -05:00
Roland Franssen
9a827c48ae Tweak error message 2019-01-16 09:02:45 -05:00
Matthew Brown
b43a6a31f1 Enable casing plugin and fix issues it found 2019-01-12 10:52:23 -05:00
Matthew Brown
6e585008f2 Fix #1183 - add hook for class analysis 2019-01-09 08:28:12 -05:00
Matthew Brown
195cb289ed Add float-checking plugin, and support for custom plugin issues 2019-01-07 08:38:56 -05:00
Matthew Brown
36a1fe07da Allow plugins to have more than one class
Ref #536
2019-01-06 17:32:19 -05:00
Brown
1d300ec342 Fix #1150 2019-01-02 11:18:22 -05:00
Matthew Brown
c4d024a72d Check variable static calls
Fixes #1142 and #1160
2019-01-02 09:00:45 -05:00
Matthew Brown
901596281c Fix #1143 - check some variable new calls 2019-01-02 06:58:49 -05:00
Brown
f02fdeddf3 Fix spelling 2018-12-19 18:03:02 -05:00
Brown
87993bad3b Fix attribute names 2018-12-19 17:56:29 -05:00
Brown
fb848d62e9 Add checks for if (count($a)) and if (count($a) [operator] [number]) 2018-12-19 16:15:19 -05:00
Matthew Brown
ea89a6ba29 Revert "First pass"
This reverts commit 9ed047234f.
2018-12-19 08:45:14 -05:00
Matthew Brown
9ed047234f First pass 2018-12-19 01:59:14 -05:00
Matthew Brown
ca6149ed17 Improve treatment of templated params within function analysis 2018-12-17 23:29:27 -05:00
Brown
9e4765663d Fix #999 - respect @method annotations to redefine parent methods 2018-11-30 15:13:25 -05:00
Matthew Brown
8eca864e98 Use composer class loader for source project to avoid plugin overwriting
cc @weirdan
2018-11-25 10:41:22 -05:00
Bruce Weirdan
512d07c93a Re-enable plugin autoloading
Plugins are supposed to be autoloaded when they are referenced by class
names.
2018-11-12 17:42:36 -05:00
Brown
dc834fdb01 Default allowStringToStandInForClass to true and fix errors found 2018-11-12 12:03:55 -05:00
Bruce Weirdan
a338e76ef6 Plugin interface segregation (#1076)
* Split Plugin into PluginApi\Hook\* interfaces

* dropped Psalm\Plugin

* updated docs

* s/PluginApi/Plugin/g
2018-11-12 11:20:59 -05:00
Matthew Brown
4d79b61e93 Change _checker to _analyzer 2018-11-12 11:20:59 -05:00
Matthew Brown
4688b25fd9 Move internal classes to own namespace 2018-11-12 11:20:59 -05:00
Bruce Weirdan
052d4f6217 Plugin loading (#855)
* add ability to load plugins by class names

- Plugins need to implement `__invoke(PluginFacade $psalm):void` method
- Plugins are enabled by adding `<pluginClass
class="Qualified\Class\Name"/>`
- `PluginFacade` provides a single point of contact with Psalm, so that
plugins cannot become coupled to Psalm internals

* added `psalm-plugin` cli tool to manage plugins

Available commands:
 `psalm-plugin list` - lists available and enabled plugins
 `psalm-plugin enable 'Plugin\Class\Name'` - enables plugin (modifies `psalm.xml`)
 `psalm-plugin disable 'Plugin\Class\Name'` - disables plugin (modifies `psalm.xml`)

Plugin installation:
 `composer install plugin-vendor/plugin-package-name`

Plugin authoring:
 Plugins are identified by package `type` field, which should contain
 `psalm-plugin` string.
 `extra.pluginClass` should refer to the name of the class implementing
 `__invoke(PluginFacade $psalm):void` function

Todo:
 - better config file search
 - better output for `psalm-plugin`
 - better formatting for modified xml file
 - composer skeleton project for plugins
 - ability to refer to plugins by package name (cli only)
 - composer plugin to (optionally) enable plugin upon installation
 - documentation on plugin installation and authoring
 - interfaces for plugin dependencies
 - interface for plugin entry point
 - migration path for legacy plugins

* documented previously undocumented plugin methods

* split legacy plugin registration into a wrapper class

also added `PluginApi` namespace and `RegistrationInterface`

* reuse psalm's config search algorithm

* enable/disable plugins by composer package name

* allow specifying alternative config file name

* whitelist PluginApi namespace

three times, but well, it works now

* interface for plugin entry points

* psalm-plugin as a symfony console app

* fixed errors found by psalm

* suppressed false positive UnusedMethods

* cs fix

* better psalm-plugin output

* don't leave empty `plugins` node to avoid old schema violation

* removed junk file that shouldn't be there

* cs fix

* fixed phpunit failure (constant redefinition)

* work around missing docblock in on symfony console

* php 7.0 compatibility

* allow `pluginClass` child elements as plugin configuration

* decouple console commands from undelying implementation

- introduce PluginListFactory
- add `PluginList::enable(string $class)` and `PluginList::disable(string $class)`

* PluginList tests

* ComposerLock test

* droppped debugging statement

* added part of console command tests

* added tests for EnableCommand

* added DisableCommand tests

* ignore unused args

* ConfigFile test

* disable travis cache in attempt to fix builds

* nah, that didn't work

* update for upstream changes

* rebase fixes

* namespaced `extra` entry for entry point

* s/PluginFacade/PluginRegistrationSocket/g

* Added $config parameter to PluginEntryPointInterface::__invoke()

* cs fixes

* entry point interface php7.0 compatibility

* cleaned up old cruft

- dropped todos I'm not going to pursues
- locked entry point to be a class implementing entry point interface

* fixed legacy plugins docs

* Added RegistrationInterface::registerHooksFromClass()

It mimics the way old plugins were registered in Psalm\Config, so
handler classes extending Psalm\Plugin should be fully compatible with
it.

Since Psalm\Plugin-style plugin registration was moved to
RegistrationSocket, LegacyPlugin now only load file-based plugins, so it
was renamed to FileBasedPluginAdapter.

* Converted EchoChecker plugin to composer-based format

- Its subfolder is registered as a local composer package in the root
composer.json, so it's directly installable with
	```
	composer require psalm/echo-checker-plugin
	```
- Migration is trivial: drop the plugin into a separate folder, then add
simple composer.json and the entry point class.

* Updated docs

* Don't reject hook handlers that inherit handling methods

* strip void return type in stub file
2018-11-10 23:23:36 -05:00
Brown
df8b0a1fc5 Bust cache when config changes, don’t rely on > modified time 2018-11-01 17:42:48 -04:00
Brown
1d7ea1292e Add Psalm\Config::locateConfigFile method for easier path fetching 2018-11-01 13:05:33 -04:00
Erik Booij
635410ea41 Introduce issue baseline with --set-baseline and --with-baseline 2018-11-01 11:16:08 -04:00
Brown
4da1fd0e40 Change psalm --server to psalm-language-server 2018-10-18 14:34:46 -04:00
Brown
13cc3b4751 Improve file hash reloading 2018-10-15 11:34:51 -04:00
Matthew Brown
92e11fd51b Port over cleanup from server branch 2018-10-06 20:11:19 -04:00
Brown
67c90edadf Don’t check methods we’ve already checked 2018-09-30 11:34:51 -04:00
Matt Brown
4d4e84e6e9 Add specific ForbiddenEcho issue if a config flag is set 2018-09-18 17:08:32 -04:00
Matt Brown
414057e281 Fix #938 - allow forbiddenFunctions to be specified in the config 2018-09-18 16:42:51 -04:00
Matt Brown
add7c14b44 Fix #965 - invalidate cache when changing plugins 2018-09-04 15:28:03 -04:00
Matt Brown
17ea48eda4 Add ability to pretend that a file has declare(strict_types=1) 2018-08-29 15:10:56 -04:00
Matt Brown
2599d8bd62 Allow some folders to be excluded from type stats collection 2018-08-24 17:46:13 -04:00
Matthew Brown
d41a9a8dcc Fix #806 - allow specification of functions and static methods that exit 2018-07-12 23:26:08 -04:00
Tyson Andre
a3b1bebb5b Fix misuse of preg_quote (#869)
1. Variable ids can contain slashes or dots, e.g. for `${'my/var'} = 2`
   or psalm's local representation of properties or array indexes
   (I forget which)
2. preg_quote's escape character should **always** be the same as the
   pattern starting character.
   Using DIRECTORY_SEPARATOR will fail to escape '/' on windows.
2018-07-06 19:16:31 -04:00
Matt Brown
4a4d091c02 Fix #858 - scan files before autoloading them 2018-07-03 11:17:52 -04:00
Matthew Brown
16e270f0ee Improve loading of stub file and autoload file information
Ref #849
2018-06-30 15:29:37 -04:00
Matt Brown
89cc63846f Improve handling of autoloaded files
Fixes #848
2018-06-29 15:28:45 -04:00
Matthew Brown
e1d922e9df Add support for ignoredExceptions 2018-06-22 01:26:10 -04:00
Matthew Brown
e3ae1bf26f Fix #15 - check for uncaught throws if config flag is set 2018-06-22 01:13:49 -04:00
Matthew Brown
3670f066bb Improve dead code detection 2018-06-16 20:01:41 -04:00
Matt Brown
f030f4f40d Allow docblock types to be merged with param default ones 2018-06-07 12:23:21 -04:00
Matthew Brown
53bfafa02a Make sure that ignoreFiles files never appear in errors 2018-06-04 00:15:28 -04:00
Matthew Brown
55fdef250e Add config to allow hoisting constants to the top of a file 2018-06-01 09:07:22 -04:00
Matthew Brown
ee9fef050a Add support for function checking plugins 2018-05-31 22:00:11 -04:00
Matt Brown
68dbe509a8 Fix #731 - report issues in files required by the source 2018-05-30 12:23:53 -04:00
Matthew Brown
c217849737 Improve handling of projects that use include/require heavily 2018-05-22 23:39:01 -04:00
Matthew Brown
b0733254bb
Use individual type objects for each string (#757)
* Experiment with individual types for each string

* Fix bunch of errors

* Fix a few more issues

* Fix a whole bunch of bugs

* Fix most remaining bugs

* Fix isset warnings

* Fix psalm errors in psalm

* Limit big string size

* Fix falsiness of ints

* Fix issue with type widening, allowing value set in nested if to be altered

* Don’t complain if type is mixed

* Add skipped-for-now test

* Add specific test to address issue
2018-05-18 11:02:50 -04:00
Matthew Brown
a33d52d935 Add support for referencedProperty error restrictions 2018-05-11 00:07:41 -04:00
Matthew Brown
da6209276f Allow ability to memoize empty method calls based on config 2018-04-28 13:05:43 -04:00
Matthew Brown
1c7568e612 Fix #642 - allow @method to override existing methods
behind usePhpDocMethodsWithoutMagicCall="true"
2018-04-21 23:08:08 -04:00
Matthew Brown
8b50cdf315 Fix #632 - add support for @method annotations when method can’t be found 2018-04-21 22:44:54 -04:00
Matthew Brown
da69e60cf3 Don’t error on existing Psalm configs cc @ostrolucky 2018-04-21 19:05:26 -04:00
Matt Brown
a25a989c12 Prepare v2 dev release 2018-04-19 17:29:07 -04:00
Radosław Kowalewski
eab7f7b68b Suppress MixedArgument 2018-04-14 10:45:05 -04:00
Radosław Kowalewski
88bf8e284c Configuration fallback to psalm.xml.dist file
Closes vimeo/psalm#644
2018-04-14 10:45:05 -04:00
Matt Brown
21b74ae725 Turn useAssertForType on by default (was off) 2018-04-13 17:35:56 -04:00
Matt Brown
8fdd827e0d Fix scope leaking from autoloader 2018-04-13 10:32:08 -04:00
Matthew Brown
75e59f29ea Check as many autoloaded files as possible
and ignore reflected function docblocks - fixes #629
2018-03-30 20:03:56 -04:00
Matthew Brown
5384f193d1 Allow class and method issues to be suppressed by their identifiers
Ref #603
2018-03-20 22:36:03 -04:00
Bruce Weirdan
a1f481d8a2 commented out code cleanup 2018-03-08 19:14:06 -05:00
Bruce Weirdan
12488ea8ed dropped commented out code, added file_exists() checks for stubs 2018-03-08 19:14:06 -05:00
Bruce Weirdan
32884774e4 build psalm.phar using humbug/box 2018-03-08 19:14:06 -05:00
Matt Brown
d185253396 Don’t throw exception if classloader hasn’t been set 2018-03-06 17:30:54 -05:00
Matt Brown
357ad1aa82 Add config flags to allow stricter class invocation checks 2018-03-06 11:20:59 -05:00
Matthew Brown
9d48585b0e Fix #552 - fix path that stubs are loaded from 2018-03-03 19:05:15 -05:00
Matthew Brown
6458aa2e91 Remove unused methods 2018-03-03 15:29:13 -05:00
Matthew Brown
b90a58533b Fix tests and return types 2018-03-03 15:25:35 -05:00
Matthew Brown
ade9e03c85 Use composer autoloader for class resolution where possible 2018-03-03 15:19:05 -05:00
Matthew Brown
9fd009a61d Add more debug output for composer classmaps 2018-03-03 12:15:22 -05:00
Matt Brown
5471b89391 Make array coercion an error 2018-02-21 18:59:31 -05:00
Matt Brown
a81c73301b Warn early if the file being analysed has not been properly scanned 2018-02-21 13:54:11 -05:00
Matthew Brown
724e72af58 Don’t get statements from cache if file hasn’t changed 2018-02-19 11:53:30 -05:00
Matthew Brown
634375ae94 Make igbinary the default serializer
Fix #484 and fix #527
2018-02-19 11:14:07 -05:00
Tyson Andre
aea3779c96 Fix unused imports in psalm, wrong param order doc comments (#523)
(Some of the imports appear as strings elsewhere in the same file)
2018-02-18 17:55:11 -05:00
Matthew Brown
affcaebc3d Use classes, not full method ids, for plugin execution 2018-02-11 22:49:19 -05:00
Matthew Brown
e862e4ddb1 Make all plugin methods static
cc @TysonAndre
2018-02-11 20:56:34 -05:00
Matt Brown
fc58655963 Make logic more Psalm-compatible 2018-02-06 13:52:59 -05:00
Matthew Brown
8e0998e081 Break apart the Codebase class 2018-02-03 18:56:54 -05:00
Matthew Brown
8d2baf584e Fix #479 - allow PhpStorm generic syntax behind a config flag 2018-02-01 01:10:27 -05:00
Matthew Brown
fb300baa6d Move a bunch of code into Codebase 2018-02-01 00:50:01 -05:00
Matthew Brown
cf8734a480 Add support for generic classes 2018-01-31 23:27:25 -05:00
Matthew Brown
dd32452d90 Remove more dead code found by Psalm 2018-01-28 12:43:19 -05:00
Matt Brown
1a2d13ae32 Ignore falsable issues from core functions 2018-01-25 13:07:36 -05:00
Matt Brown
d67f1e3c28 Fix #252 - allow custom vendor directory 2018-01-25 11:32:54 -05:00
Matt Brown
cf7c5c2a0d Fix #470 - follow vendor directory symlinks 2018-01-25 11:07:16 -05:00
Matt Brown
b0f3992f36 Remove stopOnFirstError config option, because it hasn’t worked for a while
Fixes #248
2018-01-24 16:22:54 -05:00
Matthew Brown
bc9761f6c9 Create Codebase out from ProjectChecker 2018-01-21 13:45:33 -05:00
Matthew Brown
e05a7c00cc Break FileScanner out from FileChecker 2018-01-21 12:44:46 -05:00
Matthew Brown
9b6b03ff9f Create Config before ProjectChecker, and remove test-specific code from FileChecker 2018-01-21 10:22:04 -05:00
Tyson Andre
77b41f4e9f Bring phpdoc @param up to date 2018-01-18 16:07:48 -05:00
Matthew Brown
6e6c20b968 Remove unused property 2018-01-13 00:45:28 -05:00
Matthew Brown
d61829adde Allow the use of property docblocks without all docblocks 2018-01-13 00:32:20 -05:00
Matthew Brown
fb9f20f4b8 Find unused properties with dead code checks
Fixes #424
2018-01-10 23:29:18 -05:00
Matt Brown
72848477c2 Add all Possibly* issues to more lenient config
And add granularity to InvalidPropertyAssignment* issues
2018-01-10 10:56:43 -05:00
Matthew Brown
c9173c7da3 Add more specific issues for falsable/nullable invalid return types 2018-01-04 21:36:16 -05:00
Matthew Brown
8da23605bb Add unqualifier plugin test to remove unnecessary namepaces 2018-01-02 09:46:50 -05:00
Matthew Brown
cc81d78dfd Add code replacement api to allow Psalm to update arbitrary parts of the codebase
Fixes #264
2018-01-02 09:46:50 -05:00
Matthew Brown
72b127e061 Allow plugins to be run via the command line 2018-01-02 09:46:50 -05:00
Matthew Brown
5afe3b10fa Scan compoer autoload files before any sweep of code 2018-01-01 11:47:03 -05:00
Matthew Brown
8efc939a5f Move Psalm execution code into PHP file that Psalm can analyse 2017-12-29 17:02:56 -05:00
Matthew Brown
becce4ae36 Use composer classmap where available to remove need for reflection of vendor classes 2017-12-28 00:56:10 +01:00
Matthew Brown
942bc0a663 Add new MixedTypeCoercion issue, fixes #320 2017-11-19 13:42:48 -05:00
Matthew Brown
1a39224abc Fix issues that improved array checks found 2017-11-19 12:14:02 -05:00
Matthew Brown
b618bd798d Add new issues for missing required files 2017-10-29 14:39:23 -04:00
Matthew Brown
295792d550 Fix #235 - add psalm.xml option to support igbinary serializer 2017-10-15 12:38:47 -04:00
Matt Brown
8f9fdcb637 Create storage for plugins before scanning 2017-08-08 11:03:45 -04:00
Matthew Brown
4175295113 Isolate where we load static storage objects (#195)
* Move FileChecker::$storage calls to provider

* Add ClassLikeStorageProvider

* Use ClassLikeStorageProvider everywhere

* Move storage arrays into providers
2017-07-29 15:05:06 -04:00
Matt Brown
76ba419330 Group unused tests together 2017-07-25 17:04:58 -04:00
Matthew Brown
e29dd140e3 Refactor scanning and analysis, introducing multithreading (#191)
* Add failing test

* Add visitor to soup up classlike references

* Move a whole bunch of code into the visitor

* Move some methods back, move onto analysis stage

* Use the getAliases method everywhere

* Fix refs

* Fix more refs

* Fix some tests

* Fix more tests

* Fix include tests

* Shift config class finding to project checker and fix bugs

* Fix a few more tests

* transition test to new syntax

* Remove var_dump

* Delete a bunch of code and fix mutation test

* Remove unnecessary visitation

* Transition to better mocked out file provider, breaking some cached statement loading

* Use different scheme for naming anonymous classes

* Fix anonymous class issues

* Refactor file/statement loading

* Add specific property types

* Fix mapped property assignment

* Improve how we deal with traits

* Fix trait checking

* Pass Psalm checks

* Add multi-process support

* Delay console output until the end

* Remove PHP 7 syntax

* Update file storage with classes

* Fix scanning individual files and add reflection return types

* Always turn XDebug off

* Add quicker method of getting method mutations

* Queue return types for crawling

* Interpret all strings as possible classes once we see a `get_class` call

* Check invalid return types again

* Fix template namespacing issues

* Default to class-insensitive file names for includes

* Don’t overwrite existing issues data

* Add var docblocks for scanning

* Add null check

* Fix loading of external classes in templates

* Only try to populate class when we haven’t yet seen it’s not a class

* Fix trait property accessibility

* Only ever improve docblock param type

* Make param replacement more robust

* Fix static const missing inferred type

* Fix a few more tests

* Register constant definitions

* Fix trait aliasing

* Skip constant type tests for now

* Fix linting issues

* Make sure caching is off for tests

* Remove unnecessary return

* Use emulative parser if on PHP 5.6

* Cache parser for faster first-time parse

* Fix constant resolution when scanning classes

* Remove test that’s beyond a practical scope

* Add back --diff support

* Add --help for --threads

* Remove unused vars
2017-07-25 16:11:02 -04:00
Matthew Brown
4a590000a6 Fix whitespace issue 2017-06-26 20:14:58 -04:00
Matthew Brown
678b6113d5 Fix #127 - allow Psalm to analyse composer autloaded files 2017-06-26 20:13:10 -04:00
Matthew Brown
f9b16c9a2d Explicitly cast mock class to string 2017-06-13 00:51:16 -04:00
Matthew Brown
22a716f4da Improve formatting of phpdocs 2017-05-26 20:16:18 -04:00
Matthew Brown
d6909193ea Add additional formatting changes 2017-05-26 20:05:57 -04:00
Matthew Brown
4fd46e1752 Improve formatting 2017-05-24 22:07:49 -04:00
Matthew Brown
754a4d9950 Allow Psalm to be run outside of the directory it's installed in (#154)
* Add --root option when not running Psalm from root directory

* Add informative error when running Psalm outside of its project directory

* Add better message in help

* Fix autoloader precedence
2017-05-04 14:25:58 -04:00
Jon Ursenbach
f65c618b2e PSR-2 adjustments and adding PHPCS checks into the Travis config. (#149)
* PSR-2 adjustments and adding PHPCS checks into the Travis config.

* Reverting some CallChecker changes and no longer casting vars to null.
2017-04-28 00:31:55 -04:00
Matthew Brown
ce6ca58291 Fix #114 - add optional Hack-like checks calls 2017-04-14 21:32:14 -04:00
Matthew Brown
a89018d9ae Only warn about issues in files that we’re trying to scan 2017-03-24 18:34:46 -04:00
Matt Brown
cbb8252125 Don’t be sensitive to casing differences in file paths 2017-02-27 12:02:13 -05:00
Matthew Brown
cd5f727d2e Collect explicit references to classes/methods 2017-02-26 23:09:18 -05:00
Matt Brown
0049e4deb4 Fix #105 and also the issues found in its wake 2017-02-23 19:36:51 -05:00
Matthew Brown
45577f123c Don’t add Symony and Composer to predefined (Reflectable) classes 2017-02-21 02:07:43 -05:00
Matthew Brown
f32fabd798 Remove dead code 2017-02-11 19:30:06 -05:00
Matthew Brown
8ff6634e7b Add issue for possibly unused variables in public/private methods
also changed a lot of access
2017-02-11 18:56:38 -05:00
Matt Brown
c0a6fc9125 Fix #90 - add genericised stubs for common array functions 2017-02-10 18:12:59 -05:00
Matt Brown
34980fc718 Remove dead code and fix config.xsd 2017-02-07 18:27:28 -05:00
Matt Brown
ba4f47a41c Config for caching file hashes during run 2017-02-02 12:39:39 -05:00
Matthew Brown
0fbf8b5619 Remove more dead code 2017-02-02 00:45:23 -05:00
Matthew Brown
bf042772bd Get config constants after autoload script 2017-02-01 14:56:10 -05:00
Matthew Brown
a0711de023 Update config key to be more accurate ref #85 2017-02-01 10:13:37 -05:00
Matthew Brown
eeccf791ad Add unused method & unused class analysis ref #80 2017-01-31 20:47:16 -05:00
Matt Brown
004fd42062 Fix #83 - add support for stubbing 2017-01-31 19:21:33 -05:00
Matthew Brown
cc500e8228 Eliminate dead code 2017-01-30 00:25:16 -05:00
Matthew Brown
1ece3071f9 Add reference counting for methods and remove dead code 2017-01-29 23:44:05 -05:00
Matthew Brown
a9203b63f8 Allow phan-like use of assert 2017-01-28 15:17:14 -05:00
Matthew Brown
7e7743d6fb Do not complain about missing void return types if config set 2017-01-25 17:07:28 -07:00
Matt Brown
875717bb96 Fix #63 by adding directory separators 2017-01-17 22:10:21 -05:00
Matthew Brown
4073986844 Merge pull request #65 from Fleshgrinder/feature/auto-creation-of-cache-directory
Auto-create cache directory
2017-01-16 18:39:48 -05:00
Matthew Brown
b3726c9de5 Use getcwd() for the project’s base, not the config file parent directory 2017-01-16 18:33:04 -05:00
Richard Fussenegger
42fee8d3a6 Auto-create cache directory
Signed-off-by: Richard Fussenegger <fleshgrinder@users.noreply.github.com>
2017-01-16 21:58:35 +01:00
Matthew Brown
69e185eb17 Use absolute cache directory paths everywhere ref #63 2017-01-16 15:32:03 -05:00
Matthew Brown
98454f8644 Remove anti-windows exception 2017-01-16 14:17:47 -05:00
Matthew Brown
e3a9cb98c3 Add extra issue for invalid clone and fix issue reporting; 2017-01-16 12:59:09 -05:00
Matthew Brown
856870cf37 Fix #62 - die quickly and explicitly if files cannot be located 2017-01-16 11:41:57 -05:00
Matthew Brown
f614944b63 Add predefined functions to avoid throwing errors 2017-01-15 20:11:02 -05:00
Matthew Brown
f4676dae1d Fix #60 - use sys_get_temp_dir() for cache dir unless user-supplied 2017-01-15 17:20:54 -05:00
Matthew Brown
df941bd575 Improve resilience of typechecker::isContainedBy 2017-01-05 00:14:34 -05:00
Matthew Brown
7609ca02c0 Fix #32 by evaluating all class references in files lazily 2017-01-04 23:42:58 -05:00
Matthew Brown
93c1366bd8 Tighten up what array assignments can happen 2017-01-02 01:07:44 -05:00
Matthew Brown
e662c420b7 Add schema to verify new config format against 2016-12-29 22:11:10 -05:00
Matthew Brown
685eaeb4fe Reimagine XML schema, fixes #21 2016-12-29 20:10:06 -05:00
Matthew Brown
b79ce904d2 Fix #23 - allow exclusion in projectFiles 2016-12-29 18:33:03 -05:00
Matthew Brown
749735a3ec Update config file API still further 2016-12-29 10:24:10 -05:00
Matthew Brown
ff466b7992 Change config API 2016-12-29 08:42:39 -05:00
Matthew Brown
1007d1682c Fix mixed operand issues 2016-12-24 18:29:11 +00:00
Matthew Brown
c51d8f5220 Implement MixedOperand and InvalidOperand issues 2016-12-24 18:29:11 +00:00
Matthew Brown
9a32b5fd40 Hide Mixed* issues under a totallyTyped config flag 2016-12-18 19:17:39 -05:00
Matthew Brown
9746c8972f Fix MixedAssignment errors 2016-12-17 00:48:31 -05:00
Matt Brown
6ee8d473a0 Fix support for includeFiles 2016-12-14 12:53:11 -05:00
Matt Brown
154d023a9d Add more robust config testing 2016-12-14 12:28:38 -05:00
Matt Brown
ce3b24bf5f Fix #8 - defer always to call map if function not user-defined 2016-12-09 12:07:47 -05:00
Matthew Brown
39d08cd4b4 Add method to set custom error level programatically 2016-12-08 22:37:59 -05:00
Matt Brown
af1a932655 Make code location more accurate 2016-12-06 18:27:22 -05:00
Matthew Brown
c0a3211f66 Support disabling file includes via the config 2016-12-06 16:41:42 -05:00
Matthew Brown
23334700f6 Add config option to determine whether or not to use a property default value for its type 2016-12-04 18:43:07 -05:00
Matthew Brown
4f95c67e1c Emit issues for null/mixed array access 2016-11-21 19:07:56 -05:00
Matthew Brown
55a3ffa773 Add missing return types 2016-11-20 23:45:10 -05:00
Matthew Brown
5a9f99c24e Fix namespacing issues in PHP 5.6 2016-11-20 21:49:06 -05:00
Matthew Brown
7df4d74a7b Fix Psalm errors 2016-11-04 21:14:04 -04:00
Matthew Brown
ea4daa7b7e Move cache dir into better config 2016-11-04 17:47:11 -04:00
Jon Ursenbach
27c2db1d1d PSR-2 2016-11-02 17:50:54 -04:00
Matthew Brown
34af24a2b4 Add all the properties 2016-11-01 00:39:41 -04:00
Matthew Brown
604c875d0c Fix more errors caught by Psalm 2016-10-30 12:46:18 -04:00
Matthew Brown
bd173f8840 Fix #21 - stopOnFirstError now handled properly 2016-10-23 23:32:17 -04:00
Matthew Brown
ce95275878 Fix more Psalm bugs found by Psalm 2016-10-23 12:24:53 -04:00
Matthew Brown
ca3dfe6e39 Fix Psalm errors in Psalm 2016-10-15 00:12:57 -04:00
Matthew Brown
f68280488c Remove custom error levels 2016-10-09 17:55:21 -04:00
Matthew Brown
49baa62224 Fix doblocks and invalid refs 2016-10-03 11:38:59 -04:00
Matthew Brown
8c5adf477a Add support for key/value array typing 2016-09-09 16:21:49 -04:00
Matthew Brown
47f66bf4dd Add support for exposing errors in external files 2016-08-31 23:12:35 -04:00
Matthew Brown
0e68179bb4 Pass in the right context 2016-08-24 00:22:38 -04:00
Matthew Brown
7d1a106fd5 Big file reorg with ClassLikeChecker as new ClassChecker 2016-08-13 14:20:46 -04:00
Matthew Brown
7a1cded329 Add better class visibiity checks 2016-08-07 12:23:29 -04:00
Matthew Brown
d254bc0aa2 Improve type checking of properties 2016-08-06 20:27:13 -04:00
Matthew Brown
81c72f2900 Evaluate parent classes proper-like 2016-08-05 15:11:20 -04:00
Matthew Brown
bff796ceb7 Add TooManyArguments to default suppressed list 2016-07-30 19:54:53 -04:00
Matthew Brown
6b3fe14f1e Allow specification of custom autoloaders 2016-07-26 15:03:43 -04:00
Matthew Brown
7701a2ec23 Change config filename 2016-07-25 18:39:36 -04:00
Matthew Brown
df28d24803 Change name to Psalm 2016-07-25 18:37:44 -04:00