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

2538 Commits

Author SHA1 Message Date
Matthew Brown
b32000fa05 Fix #689 - add checks for @internal annotations 2018-12-01 18:37:49 -05:00
Matthew Brown
bbdd20bfd6 Fix #490 - warm about unknown @psalm- annotations 2018-12-01 15:29:14 -05:00
Brown
ef49e3984b Fix #945 - allow ...$foo in docblock for non-user files to inform variadic 2018-11-30 19:21:14 -05:00
Brown
9e4765663d Fix #999 - respect @method annotations to redefine parent methods 2018-11-30 15:13:25 -05:00
Brown
1b740aebb5 Fix #1104 - allow multiple trait method aliases to map to same method 2018-11-30 13:45:49 -05:00
Brown
b6446824be Fix #1107 - emit PossiblyUndefinedArrayOffset where applicable 2018-11-30 13:27:21 -05:00
Matthew Brown
9efd40e321 Fix #1095 - prevent complex assertion redundant condition 2018-11-29 23:25:30 -05:00
Matthew Brown
21f29e7385 Fix #1108 - add support for referencedFunction to UndefinedFunction 2018-11-29 23:19:33 -05:00
Bruce Weirdan
f84224b7e9 fixed collator method return types 2018-11-29 09:45:02 -05:00
Matthew Brown
21f4a2c7f2 Save referenced classlike for cache 2018-11-29 01:46:12 -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
04b3fd2bb5 Fall through after more Possibly* issues 2018-11-28 11:45:54 -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
f5e788ec1f Increase limits of literal strings to 50 characters 2018-11-27 17:48:23 -05:00
Brown
2e7a75ba0a Prevent Psalm-specific types leaking into PHPDoc 2018-11-27 12:20:06 -05:00
Matthew Brown
a83387b187 Fall through after RawObjectIteration 2018-11-27 09:34:54 -05:00
Brown
3bcbd9d659 Don’t emit errors when iterating over array|iterator 2018-11-26 16:50:47 -05:00
Brown
97c0a94b42 Prevent type coercion from get_class output 2018-11-26 16:39:59 -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
8eca864e98 Use composer class loader for source project to avoid plugin overwriting
cc @weirdan
2018-11-25 10:41:22 -05:00
Matthew Brown
047b096227 Add better support for intersection properties and mocks 2018-11-24 18:31:08 -05:00
Matthew Brown
e811ff5498 Allow generic types to be included in static return type 2018-11-23 13:24:35 -05:00
Matthew Brown
786ac6c4eb Allow static to carry intersection types 2018-11-22 01:03:32 -05:00
Matthew Brown
1f3fab4cad Make sure method call return type is passed by ref 2018-11-22 00:40:22 -05:00
Matthew Brown
68af217892 Add missing arg to static call hook 2018-11-22 00:25:38 -05:00
Matthew Brown
8d488345ce Fix #1036 - at least the part I care about 2018-11-21 18:38:09 -05:00
Matthew Brown
9f79bdb86e Allow iteration over iteratoraggregate directly 2018-11-21 18:35:41 -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
3ccd9f4c01 Fix arg type 2018-11-21 14:08:47 -05:00
Tyson Andre
6ab59209d6 Fix usage of substr_count($haystack, $needle)
Detected via a check that literals and variables occur in the most
typical order for a global function.
2018-11-21 13:59:22 -05:00
Matthew Brown
6ef79a0432 Improve handling of byref vars passed into functions
Fixes #1066
2018-11-21 12:38:51 -05:00
Vasily Kartashov
fe6713d561 Adding false to ftell result type,
Adding properties to `stream_get_meta_data` result array
2018-11-21 08:28:44 -05:00
Matthew Brown
f35a550774 Remove redundant clause 2018-11-20 22:24:53 -05:00
Matthew Brown
740aa895e9 Fix #1074 - allow switching from Phar analysis to regular analysis 2018-11-20 22:21:00 -05:00
Brown
b5f0159cdf Add backup hover analysis when file isn’t analysed 2018-11-20 16:32:40 -05:00
Brown
7df0361fb9 Remove unnecessary error log 2018-11-20 15:53:24 -05:00
Brown
ca602f8e17 Fix language server crash after editing trait method names 2018-11-20 15:51:47 -05:00
Matthew Brown
39310573d1 Use socket client mode by default when starting tcp language server 2018-11-19 22:53:11 -05:00
Matthew Brown
0f90309819 Do all normalisation on / before conversion to \ 2018-11-18 17:18:05 -05:00
Matthew Brown
fa2e7f1f70 More finagling of windows file names 2018-11-18 17:06:11 -05:00
Matthew Brown
2a3c3ed223 Fix #1071 - improve resolution of include paths 2018-11-18 16:53:46 -05:00
Matthew Brown
23ec0e037b Fix windows-only constant issue 2018-11-18 16:05:36 -05:00
Matthew
b52f9cbcd2 Fix windows file path includes 2018-11-18 20:56:56 +00:00
Matthew Brown
59b9b5d65b Move more classes into Internal namespace 2018-11-18 12:41:47 -05:00
Matthew Brown
37dedee7b6 Fix memory leak issues and disable garbage collection 2018-11-18 11:39:14 -05:00
Matthew Brown
c2e546facb Fix #531
Well, it’s basically fixed already, but this adds @TysonAndre’s suggestions (and some of the relevant implementation from Phan)
2018-11-17 18:01:27 -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
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
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
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
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
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
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
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
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
Brown
ead7d62d48 Continue checking after method deprecation warning 2018-11-09 14:18:46 -05:00
Brown
71800770b1 Fix delimiter 2018-11-09 12:59:17 -05:00
Brown
ea62387cae Strip out leading slashes before reflecting 2018-11-09 12:34:52 -05:00