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

1370 Commits

Author SHA1 Message Date
Matthew Brown
21f29e7385 Fix #1108 - add support for referencedFunction to UndefinedFunction 2018-11-29 23:19:33 -05:00
Matthew Brown
1eb11a43b0 Fix #1102 by supporting class_alias properly 2018-11-29 00:46:34 -05:00
Matthew Brown
26947888f6 Add some basic support for class_alias 2018-11-29 00:05:56 -05:00
Matthew Brown
47f5f309ad Remove support for get_class($a) === "somestring"
But it works with class constants
2018-11-28 23:59:43 -05:00
Matthew Brown
4040626853 Add support for special *::someMethod syntax for referencedMethod
Fixes #1105
2018-11-28 20:09:20 -05:00
Brown
c378079db8 Make the length of possible string unions unlimited in conditionals
Fixes #1103
2018-11-28 15:12:08 -05:00
Brown
e7b63a86a6 Differentiate between types merged in a write context vs types merged in return 2018-11-28 10:41:49 -05:00
Brown
63ea9d5c8e Remove test with variable results 2018-11-27 18:34:32 -05:00
Brown
f5e788ec1f Increase limits of literal strings to 50 characters 2018-11-27 17:48:23 -05:00
Matthew Brown
af041abdcb Fix #1093 - add exception type to list of scanned classes 2018-11-25 16:14:50 -05:00
Matthew Brown
d90cff8f10 Add support for overriding method visibility too 2018-11-25 11:11:33 -05:00
Matthew Brown
047b096227 Add better support for intersection properties and mocks 2018-11-24 18:31:08 -05:00
Matthew Brown
8d488345ce Fix #1036 - at least the part I care about 2018-11-21 18:38:09 -05:00
Matthew Brown
ef7298c62c Improve treatment of getIterator calls
Fixes #991
2018-11-21 17:56:04 -05:00
Matthew Brown
116cbfd349 Fix #1090 - re-fix support for magic get properties 2018-11-21 16:57:54 -05:00
Matthew Brown
6ef79a0432 Improve handling of byref vars passed into functions
Fixes #1066
2018-11-21 12:38:51 -05:00
Brown
b5f0159cdf Add backup hover analysis when file isn’t analysed 2018-11-20 16:32:40 -05:00
Brown
ca602f8e17 Fix language server crash after editing trait method names 2018-11-20 15:51:47 -05:00
Matthew Brown
59b9b5d65b Move more classes into Internal namespace 2018-11-18 12:41:47 -05:00
Brown
1ada15f6c6 Allow numeric-string to be identical to string 2018-11-16 13:31:53 -05:00
Brown
c8240cea77 Fix bug where int(0)|float was treated as float in some assertions 2018-11-16 12:26:55 -05:00
Brown
f3599a8b6c Allow assertSame(null, ...) 2018-11-16 11:50:07 -05:00
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
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
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
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
Brown
06974221df Change DependencyFinderVisitor name to ReflectorVisitor and update docs 2018-11-13 14:09:43 -05:00
Brown
dc834fdb01 Default allowStringToStandInForClass to true and fix errors found 2018-11-12 12:03:55 -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
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
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