1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00
psalm/tests
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
..
DummyProject Improve test coverage of ProjectChecker 2018-10-17 11:03:32 -04:00
FileUpdates Improve API for setting temporary file contents 2018-11-09 10:42:55 -05:00
LanguageServer Improve API for setting temporary file contents 2018-11-09 10:42:55 -05:00
Loop Better assertions about non-empty known numbers 2018-11-10 17:56:22 -05:00
performance Improve performance when parsing large files with few changes 2018-10-26 00:59:14 -04:00
Provider Cache errors as well as info issues 2018-11-01 21:52:39 -04:00
stubs Plugin loading (#855) 2018-11-10 23:23:36 -05:00
Traits Fix how InvalidDocblock is treated 2018-11-01 17:03:08 -04:00
AnnotationTest.php Fix how InvalidDocblock is treated 2018-11-01 17:03:08 -04:00
ArgTest.php Fix sort test 2018-09-04 13:30:17 -04:00
ArrayAccessTest.php Fix #834 - warn about __toString in array offset 2018-08-31 20:24:50 -04:00
ArrayAssignmentTest.php Make sure array changes are noticed 2018-11-09 11:19:44 -05:00
AssertTest.php Fix #1045 - check intersection classes exist 2018-10-30 10:34:02 -04:00
AssignmentTest.php
BadFormatTest.php Improve performance when parsing large files with few changes 2018-10-26 00:59:14 -04:00
BinaryOperationTest.php Fix #1069 - module arithmetic always returns ints 2018-11-07 08:45:26 -05:00
bootstrap.php Improve handling of array_search and strstr, and restrict ini_set types 2018-08-29 13:58:07 -04:00
CallableTest.php Add support for class concats when checking for callables 2018-10-17 13:22:57 -04:00
ClassLoadOrderTest.php Fix #894 - check magic methods with given return types 2018-07-16 20:32:16 -04:00
ClassScopeTest.php
ClassStringTest.php Fix #1055 - improve reconciliation of class-strings 2018-11-02 17:38:20 -04:00
ClassTest.php Fix #1065 - allow interface methods to be used in abstract classes 2018-11-10 19:05:51 -05:00
ComposerLockTest.php Plugin loading (#855) 2018-11-10 23:23:36 -05:00
ConfigFileTest.php Plugin loading (#855) 2018-11-10 23:23:36 -05:00
ConfigTest.php Move plugin tests into new file 2018-10-29 11:52:16 -04:00
ConstantTest.php Fix issue merging class constants and inherited interface ones 2018-09-09 11:18:20 -04:00
DocumentationTest.php Improve provider architecture, upping test coverage 2018-09-30 11:34:51 -04:00
EmptyTest.php Fix #786 - improve treatment of array isset checks 2018-05-31 15:07:03 -04:00
EnumTest.php Fix #936 - add support for class constants in enums 2018-08-08 23:12:12 -04:00
ErrorBaselineTest.php Fix #1062 - improve handling of baseline messaging 2018-11-09 00:47:43 -05:00
FileDiffTest.php Cache errors as well as info issues 2018-11-01 21:52:39 -04:00
FileManipulationTest.php Improve provider architecture, upping test coverage 2018-09-30 11:34:51 -04:00
FileReferenceTest.php Make tests platform-cross-compatible 2018-11-01 22:03:47 -04:00
ForbiddenCodeTest.php
FunctionCallTest.php Make sure array changes are noticed 2018-11-09 11:19:44 -05:00
IncludeTest.php Skip test broken by new scanning system 2018-10-15 09:16:11 -04:00
InterfaceTest.php Fix #981 - allow interfaces to be equal 2018-09-09 12:20:49 -04:00
IssetTest.php Fix #977 - improve handling of orred expressions 2018-09-10 00:13:59 -04:00
IssueSuppressionTest.php
JsonOutputTest.php Port over cleanup from server branch 2018-10-06 20:11:19 -04:00
ListTest.php
MagicMethodAnnotationTest.php Fix #984 - allow magic methods to be invoked on $this->xxx 2018-09-09 11:45:52 -04:00
MagicPropertyTest.php Fix #894 - check magic methods with given return types 2018-07-16 20:32:16 -04:00
MethodCallTest.php Fix #1073 - relax constraints around missing reflected methods and PHP Parser version 2018-11-10 20:56:31 -05:00
MethodMutationTest.php
MethodSignatureTest.php Type according to parent param types, if no type is given 2018-10-06 14:00:45 -04:00
NamespaceTest.php
Php40Test.php
Php55Test.php
Php56Test.php Fix syntax errors in tests 2018-09-17 12:15:45 -04:00
Php70Test.php Fix #970 - improve handling of yield from statements 2018-09-04 13:29:35 -04:00
Php71Test.php Improve handling of vars set in always-entered for/foreach/while loops 2018-11-10 16:10:59 -05:00
PluginListTest.php Plugin loading (#855) 2018-11-10 23:23:36 -05:00
PluginTest.php Plugin loading (#855) 2018-11-10 23:23:36 -05:00
ProjectCheckerTest.php Improve test coverage of ProjectChecker 2018-10-17 11:03:32 -04:00
PropertyTypeTest.php Fix #1015 with maybe slightly hacky solution? It’s an edge case, though 2018-10-10 11:45:56 -04:00
PsalmPluginTest.php Plugin loading (#855) 2018-11-10 23:23:36 -05:00
RedundantConditionTest.php Fix syntax errors in tests 2018-09-17 12:15:45 -04:00
ReferenceConstraintTest.php Add better checks on increment/decrement operators 2018-06-18 13:16:51 -04:00
ReportOutputTest.php Improve provider architecture, upping test coverage 2018-09-30 11:34:51 -04:00
ReturnTypeTest.php Fix syntax errors in tests 2018-09-17 12:15:45 -04:00
ScopeTest.php Fix #378 - improve handling of InvalidScope 2018-06-09 11:50:17 -04:00
StubTest.php Improve provider architecture, upping test coverage 2018-09-30 11:34:51 -04:00
SwitchTypeTest.php Improve handling of breaks in switch statements 2018-11-10 20:34:53 -05:00
TemplateTest.php Fix syntax errors in tests 2018-09-17 12:15:45 -04:00
TestCase.php Improve provider architecture, upping test coverage 2018-09-30 11:34:51 -04:00
TestConfig.php
ToStringTest.php Fix buggy handling of class with __toString being passed to string|object 2018-10-04 15:29:01 -04:00
TraitTest.php Fix #897 - understand static class comparisons in is_a 2018-07-17 22:50:30 -04:00
TryCatchTest.php Fix #889 - allow variables defined in try to avoid isset issues 2018-07-13 14:06:01 -04:00
TypeAlgebraTest.php Filter conditions better when encountering parent instanceof 2018-05-16 11:47:39 -04:00
TypeCombinationTest.php Move TypeCombination logic into its own class 2018-05-19 19:44:03 -04:00
TypeParseTest.php Fix #1063 with removal of unnecessary code 2018-11-06 08:53:22 -05:00
TypeReconciliationTest.php Use dedicated assertContainsOnlyInstancesOf assertion 2018-11-04 19:27:21 -05:00
TypeTest.php Use individual type objects for each string (#757) 2018-05-18 11:02:50 -04:00
UnusedCodeTest.php Improve provider architecture, upping test coverage 2018-09-30 11:34:51 -04:00
UnusedVariableTest.php Fix #1065 - allow interface methods to be used in abstract classes 2018-11-10 19:05:51 -05:00
ValueTest.php Improve handling of do blocks 2018-11-10 14:06:31 -05:00
VariadicTest.php