1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00
Commit Graph

211 Commits

Author SHA1 Message Date
Matthew Brown
260c25c930 Fix config 2019-09-21 22:56:40 -04:00
Matthew Brown
9c629414a7 Fix #2138 - complain when inheriting from immutable interfaces without annotation 2019-09-21 22:52:30 -04:00
Brown
c5ef2516b5 Fix #2150 - add detection for unnecessary @var annotations
And also remove them from codebase
2019-09-19 11:59:43 -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
dee2cf3281 Detect use of static inside pure function 2019-08-31 21:31:53 -04:00
Matthew Brown
6d07663d70 Annotate method getters more accurately 2019-08-30 16:40:32 -04:00
Brown
95c61db513 Add a PossibleRawObjectIteration issue 2019-08-20 12:06:02 -04:00
Matthew Brown
2a5e0d8f39 Fix #1444 - track unused suppressions 2019-08-18 14:27:50 -04:00
Brown
b5614d03f8 Add detection for unused function calls 2019-08-13 13:15:23 -04:00
Matthew Brown
b2c0993cdc Add framework for taint analysis to Psalm
Ref #611
2019-08-04 10:37:36 -04:00
Matthew Brown
3df248eea2 Add concept of purity to functions and methods 2019-07-18 01:31:48 -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
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
5a64e97f0f Fix #1793 - warn on deprecated function 2019-06-15 12:09:15 -04:00
Brown
9aeaf1a4ed Fix #1746 - allow DeprecatedInterface to be suppressed with referencedClass 2019-06-06 14:48:33 -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
0e4c8ce482 Split apart TypeCoercion issues, allowing more granular issue filtering 2019-04-25 18:02:19 -04:00
Brown
cf5fb43a66 Add missing config options 2019-04-22 11:32:06 -04:00
bugreportuser
2e147585a1 Allow ignoring exceptions only in global scope 2019-04-16 22:42:45 -04:00
Brown
af4d10cb63 Fix #1499 - use TraitMethodSignatureMismatch when dealing with trait methods 2019-03-29 14:09:06 -04:00
bugreportuser
976c2c5ef3 Add an error for throws in global scope 2019-03-24 23:03:37 -04:00
Matthew Brown
472ab29d74 Add PossiblyInvalidCast for more refined checks 2019-03-17 17:10:51 -04:00
Brown
b3a59d2638 Fix #1435 - prevent classes extending interfaces 2019-03-07 11:16:40 -05: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
cdae79b9fe Fix unnecessary params in Psalm codebase 2019-02-23 11:31:33 -05:00
Brown
3deea3980d Add checks for unitialized properties
Fixes #1328
2019-02-13 13:32:19 -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
Brown
b5059f45a0 Allow users to ignore missing ignorefiles 2019-01-28 11:50:18 -05:00
Brown
fcc9d1a979 Fix #1244 and fix #1243 - add template-extends checks 2019-01-25 15:31:17 -05:00
Brown
cd0a7441d9 Add warnings for extended template param counts off 2019-01-24 17:55:03 -05:00
Brown
fb28362fb9 Fix NoInterfaceProperties to allow referencedClass 2019-01-23 17:41:15 -05:00
Matthew Brown
bd9f2ec546 Add separate issue type for undefined interface method 2019-01-13 13:07:53 -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
214fd7d461 Add DuplicateFunction issue
Fixes #49
2019-01-06 16:40:44 -05:00
Brown
2b4b55fd33 Add support for @return no-return
Fixes #1155
2019-01-02 17:05:39 -05:00
Brown
1d300ec342 Fix #1150 2019-01-02 11:18:22 -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
b32000fa05 Fix #689 - add checks for @internal annotations 2018-12-01 18:37:49 -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
Erik Booij
635410ea41 Introduce issue baseline with --set-baseline and --with-baseline 2018-11-01 11:16:08 -04:00
Brown
13cc3b4751 Improve file hash reloading 2018-10-15 11:34:51 -04:00
Matt Brown
db3ddaa42c Allow InvalidCatch and InvalidThrow to be suppressed per-class
Ref #411
2018-09-21 11:35: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
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
Matt Brown
070e7903df Allow suppression of TooManyArguments by function/method id 2018-08-16 16:49:33 -04:00
Matt Brown
cb63f4f70f Add support for checking DeprecatedTrait and DeprecatedConstant 2018-08-10 13:25:25 -04:00
Matthew Brown
d41a9a8dcc Fix #806 - allow specification of functions and static methods that exit 2018-07-12 23:26:08 -04:00
Matthew Brown
e3ae1bf26f Fix #15 - check for uncaught throws if config flag is set 2018-06-22 01:13:49 -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
55fdef250e Add config to allow hoisting constants to the top of a file 2018-06-01 09:07:22 -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
Gabriel Ostrolucký
6c03be3193 #597 adjust XSD too and use more proper XML namespace 2018-04-21 18:55:42 -04:00
Matthew Brown
e8c96e52bc Fix config to allow element cc @rightfold 2018-04-21 16:52:33 -04:00
Matt Brown
a25a989c12 Prepare v2 dev release 2018-04-19 17:29:07 -04:00
Matt Brown
5a2f6ff0e0 Fix #624 - change some innaccurate issue names 2018-04-17 14:07:02 -04:00
Matthew Brown
b634e1a1b7 Add more refined treatment of InvalidIterator 2018-03-20 22:59:22 -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
Matthew Brown
d7a585160f Add more granular error messages for invalid operands 2018-03-18 16:39:34 -04:00
Matt Brown
b664c85642 Add new issue conditional on config flag 2018-03-06 12:19:50 -05:00
Matt Brown
357ad1aa82 Add config flags to allow stricter class invocation checks 2018-03-06 11:20:59 -05:00
Matthew Brown
a0ce8791d3 Detect fatal issues where property access is overridden
Fixes #547
2018-03-04 12:24:50 -05:00
Matthew Brown
59dc239c89 Fix #522 - prevent interface instantiation 2018-02-17 18:53:02 -05:00
Matthew Brown
09f86ceee7 Introduce MissingDependency issue, separate from UndefinedClass
Ref #511
2018-02-17 11:36:20 -05:00
Matt Brown
7f4be858c2 Fix #498 - add better issue type for docblock contradiction 2018-02-07 15:20:47 -05:00
Matt Brown
1df4c3d196 Add DocblockTypeContradiction to find possible issues with docblock types
Fixes #491
2018-02-06 18:44:53 -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
3482ee3b39 Split UntypedParam into MissingParamType and MissingClosureParamType 2018-01-28 20:03:47 -05:00
Matthew Brown
507007a2bf Add DeprecatedInterface and emit DeprecatedClass in more places
Fixes #463
2018-01-23 09:09:43 -05:00
Matthew Brown
e05a7c00cc Break FileScanner out from FileChecker 2018-01-21 12:44:46 -05:00
Matt Brown
4b4e09277c Fix #450 - add checks for duplicate array keys
And fix the embarassing errors in tests
2018-01-18 17:16:50 -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
fe96868e27 Add documentation 2018-01-07 17:25:23 -05:00
Matthew Brown
39685e1be6 Collapse Issue inheritance and rename new issues 2018-01-07 17:25:23 -05:00
Matt Brown
a76fde5b98 Break out mismatching param/return type issues from InvalidDocblock 2018-01-05 12:11:12 -05:00
Matthew Brown
6f5a214365 Allow param redefinition, but complain if it differs to parent class 2018-01-05 00:19:35 -05:00
Matthew Brown
003d37b6cd Add expected issues 2018-01-04 21:46:51 -05:00
Matthew Brown
7418d6685f Add PossibyInvalidFunctionCall, emitted when function call may not be valid 2018-01-01 12:00:02 -05:00
Matthew Brown
875bb8c072 Improve dead code detection, reducing false positives for params 2017-12-29 17:27:16 -05:00
Matthew Brown
b8c349166e Add InvalidCatch and InvalidThrow to prevent erroneous exceptions
Fix #411 and fix #412
2017-12-28 20:40:28 +01:00
Matthew Brown
2f5b05887b Promote CircularReference from exception to issue 2017-12-22 18:56:59 +01:00
Matthew Brown
5d9ce5433a Add config 2017-12-17 11:09:31 -05:00
Matt Brown
eca7351472 Add return-level issues as well as function-level ones
Fixes #379
2017-12-07 15:50:25 -05:00
Matthew Brown
0eedad4f6a Add UndefinedGlobalVariable issue and asssociated Possibly... one 2017-12-06 00:56:00 -05:00
Matt Brown
1f57881310 Break out PossiblyNullArrayOffset and NullArrayOffset from InvalidArrayOffset 2017-12-04 11:20:31 -05:00
Matthew Brown
52f9225356 Add separate issues for implemented return type mismatch 2017-11-30 00:01:41 -05:00