1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00
Commit Graph

1327 Commits

Author SHA1 Message Date
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
Matthew Brown
fe25530cad Fix #1073 - relax constraints around missing reflected methods and PHP Parser version 2018-11-10 20:56:31 -05:00
Matthew Brown
12e3ab11ad Improve handling of breaks in switch statements 2018-11-10 20:34:53 -05:00
Matthew Brown
9056353b7f Fix #1065 - allow interface methods to be used in abstract classes 2018-11-10 19:05:51 -05:00
Matthew Brown
2ea58e2c0f Better assertions about non-empty known numbers 2018-11-10 17:56:22 -05:00
Matthew Brown
aa426aca03 Add better support for non-empty arrays when scanning constants 2018-11-10 17:15:37 -05:00
Matthew Brown
3664b0975c Make sure switch breaks don’t count as loop breaks 2018-11-10 16:26:03 -05:00
Matthew Brown
9f2fe748e8 Improve handling of vars set in always-entered for/foreach/while loops 2018-11-10 16:10:59 -05:00
Matthew Brown
03ea94e087 Improve handling of do blocks 2018-11-10 14:06:31 -05:00
Matthew Brown
461a9667b5 Split up LoopScopeTest into block-specific tests 2018-11-09 19:54:10 -05:00
Brown
b7099aaf3f Make sure array changes are noticed 2018-11-09 11:19:44 -05:00
Brown
15b412b10e Add checks for non-empty arrays 2018-11-09 10:56:27 -05:00
Brown
f2c013e45f Improve API for setting temporary file contents 2018-11-09 10:42:55 -05:00
Matthew Brown
1e32354386 Improve accuracy of MissingPropertyType 2018-11-09 00:59:13 -05:00
Matthew Brown
f2f8edef20 Fix #1062 - improve handling of baseline messaging 2018-11-09 00:47:43 -05:00
Matthew Brown
2065e0129e Fix #1069 - module arithmetic always returns ints 2018-11-07 08:45:26 -05:00
Matthew Brown
8354b6e055 Fix #1063 with removal of unnecessary code 2018-11-06 08:53:22 -05:00
Gabriel Caruso
abfceca3a9 Use dedicated assertContainsOnlyInstancesOf assertion 2018-11-04 19:27:21 -05:00
Brown
3fc67782a9 Fix #1055 - improve reconciliation of class-strings 2018-11-02 17:38:20 -04:00
Brown
07934b8333 Fix isString check for class strings 2018-11-02 17:03:49 -04:00
Matthew Brown
ccf5de0418 Improve array coercion checks 2018-11-01 23:31:40 -04:00
Matthew Brown
2413e745e2 Make tests platform-cross-compatible 2018-11-01 22:03:47 -04:00
Matthew Brown
7d12bfd2d1 Cache errors as well as info issues 2018-11-01 21:52:39 -04:00
Brown
ef671a14cc Fix issue in file diff offset 2018-11-01 19:11:00 -04:00
Brown
f017599b3f Fix how InvalidDocblock is treated
Fixes #1051 (hopefully)
2018-11-01 17:03:08 -04:00
Brown
019404d198 Fix resolving of classes after change 2018-11-01 16:04:37 -04:00
Erik Booij
635410ea41 Introduce issue baseline with --set-baseline and --with-baseline 2018-11-01 11:16:08 -04:00
Matthew Brown
8071465e8e Fix performance regression introduced with fix to #1039 2018-10-30 20:51:52 -04:00
Brown
727b0d3221 Add --disable-on-change option 2018-10-30 18:58:22 -04:00
Brown
aef9fecaa3 Fix #1045 - check intersection classes exist 2018-10-30 10:34:02 -04:00
Matthew Brown
d1baff4b92 Fix #1044 - allow templated params in assert 2018-10-30 09:20:34 -04:00
Brown
55b29e71a8 Fix issue where diffs span multiple functions 2018-10-29 17:12:20 -04:00
Brown
c4e540f1b9 Add more commonly-applicable test 2018-10-29 15:28:17 -04:00
Brown
d6392fbcba Added an HTML-escaped-string meta-type for functions to return
And a sample echo checker
2018-10-29 11:54:25 -04:00
Brown
05d1ce6dcd Move plugin tests into new file 2018-10-29 11:52:16 -04:00
Matthew Brown
1d77b61ff9 Fix #1039 by invalidating all use users 2018-10-26 23:04:38 -04:00
Brown
00b51627cc Fix tests 2018-10-26 16:29:16 -04:00
Brown
e286089eaa Add onchange events and symbol lookup with disabled completion 2018-10-26 16:17:15 -04:00
Brown
303d3ee6a2 Fix issue adjusting offsets after multiple file changes 2018-10-26 13:22:41 -04:00
Brown
89e91f6ae2 Force a rescan if adding an extra method 2018-10-26 11:48:21 -04:00
Matthew Brown
addaea2c1c Improve performance when parsing large files with few changes 2018-10-26 00:59:14 -04:00
Brown
496018f84a Fix #1024 - add support for filter_var 2018-10-23 14:38:36 -04:00
Brown
447739ede1 Fix #1033 - coerce -0 to a general int 2018-10-23 13:00:15 -04:00
Brown
53719447f5 Add tests for new functionality 2018-10-17 15:54:31 -04:00
Brown
e6cf9e96df Add support for class concats when checking for callables 2018-10-17 13:22:57 -04:00
Brown
1d5759a35c Improve test coverage of ProjectChecker 2018-10-17 11:03:32 -04:00
Brown
5a484901cd Improve the way that files are reloaded (server only) 2018-10-16 15:59:11 -04:00
Brown
67b114f3f7 Skip test broken by new scanning system 2018-10-15 09:16:11 -04:00
Matthew Brown
edc219facb Add test for #1017 2018-10-11 23:00:32 -04:00
Matthew Brown
03ed1a5135 Fix #1016 - load stdClass info when an object cast comes along 2018-10-11 09:14:34 -04:00