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

3368 Commits

Author SHA1 Message Date
Brown
d94a7519f5 Fix bad docblock in test 2018-11-16 11:15:40 -05:00
Brown
425b6321aa Add better understanding of when floats and ints can be equal 2018-11-16 11:04:45 -05:00
Brown
08d9940259 Change ^ to = when annotating assertions 2018-11-16 10:13:52 -05:00
Matthew Brown
e8716f636e Prevent templated assertions on union types with > 1 atomic 2018-11-16 00:56:57 -05:00
Tyson Andre
951e28d608 Fix typos noticed in docs 2018-11-15 21:54:25 -05:00
Brown
029b6e5ac4 Allow assertions to be made on template params 2018-11-15 18:50:08 -05:00
Brown
74a8dde1bb Fix build 2018-11-15 18:39:59 -05:00
Brown
766f33d6e4 Fix add in missing property in LSP mode 2018-11-15 18:10:10 -05:00
Matthew Brown
50cb2bb92a Make compatible with PHP 7.0-1 2018-11-14 19:15:07 -05:00
Brown
cd1e1f40a0 Remove void return type 2018-11-14 18:23:20 -05:00
Brown
db6a9d5b6f Try to preserve more formatting in config file when adding plugin
cc @weirdan - I searched in vain for a proper format-preserving XML parser - if I feel desperate I might make my own, but this is a good enough solution
2018-11-14 18:10:45 -05:00
Brown
d9440c7bb0 Make sure assertions always have a $ in var id 2018-11-14 15:40:56 -05:00
Brown
f8ea3567d3 Include $ in asserted var id 2018-11-14 15:12:55 -05:00
Brown
9f523fab8b Only store really simple-looking code for assertions 2018-11-14 13:53:57 -05:00
Brown
254a14f621 Allow assertion redundant conditions to be suppressed 2018-11-14 13:44:20 -05:00
Brown
46cbd0de8d Add phpunit psalm plugin 2018-11-14 13:19:38 -05:00
Brown
3ba2510096 Prevent bleeding of assert vars into context 2018-11-14 13:12:31 -05:00
Brown
4904ffe8ea Complain about redundant conditions on custom asserts 2018-11-14 12:25:17 -05:00
Bruce Weirdan
3fb0a2f336 reinstate extra.psalm "namespace"
Existing plugins have been updated as well (skeleton, doctrine-collections)

Also fixed path to echo-checker plugin so that it's once again directly
installable from the psalm distribution.
2018-11-14 08:31:02 -05:00
Matthew Brown
c86f8e1aef Fix redundant defs 2018-11-14 01:32:29 -05:00
Matthew Brown
dede120fde Remove Psalm prefix to match psalm plugin skeleton composer.json
cc @weirdan - ran into this when trying to install a plugin
2018-11-14 01:02:26 -05:00
Matthew Brown
695f37e6c8
Add detail to ALE linter 2018-11-13 15:28:39 -05:00
Brown
06974221df Change DependencyFinderVisitor name to ReflectorVisitor and update docs 2018-11-13 14:09:43 -05:00
Matthew Brown
a4507b068e Fix #1081 - allow PDO::prepare to return false 2018-11-13 00:38:14 -05:00
Bruce Weirdan
563eb3183b Mark psalm-plugin as a cli binary
So that it's available in `vendor/bin`
2018-11-12 17:43:58 -05:00
Bruce Weirdan
7cc472c2f1 Don't choke on non-existing composer.lock
It's useful to see enabled plugins and be able to disable them even if
no composer files are found.
2018-11-12 17:43:31 -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
d0c245eff3 Fix #1077 - queue property types 2018-11-12 13:01:16 -05:00
Brown
dc834fdb01 Default allowStringToStandInForClass to true and fix errors found 2018-11-12 12:03:55 -05:00
Brown
f10714e6f8 Add a --no-reflection-cache option for plugin use 2018-11-12 11:20:59 -05:00
Brown
110ca66692 Namespace test providers under Internal cc @TysonAndre 2018-11-12 11:20:59 -05:00
Brown
0254322bed Migrate Codebase-namespaced and FileManipulation-namespaced classes to internals 2018-11-12 11:20:59 -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
8b0f2579a5 Update plugin docs 2018-11-12 11:20:59 -05:00
Matthew Brown
c276ad2bb8 Fix scoper paths 2018-11-12 11:20:59 -05:00
Matthew Brown
6ed8bb871d Fix codecoverage refs 2018-11-12 11:20:59 -05:00
Matthew Brown
9709263b8d Make many PropertyAnalyzer properties private 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
Matthew Brown
c7016d9232 Unset new var if it doesn’t appear in break vars 2018-11-11 22:03:08 -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
Matthew Brown
a3dde47374 Fix issues with build 2018-11-10 20:56:52 -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
e36d7c7d5e Fix $key overwriting 2018-11-10 20:40:34 -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
c136974f4d Allow loop breaks to take precedence over case breaks 2018-11-10 17:29:59 -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
1d64f299e9 Make sure only immediate case breaks are detected 2018-11-10 16:29:40 -05:00