1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-13 17:57:37 +01:00
Commit Graph

1753 Commits

Author SHA1 Message Date
Matthew Brown
73fadab0b5 Make Phar more robust to object namespace changes 2018-03-12 00:01:52 -04:00
Bruce Weirdan
a1f481d8a2 commented out code cleanup 2018-03-08 19:14:06 -05:00
Bruce Weirdan
12488ea8ed dropped commented out code, added file_exists() checks for stubs 2018-03-08 19:14:06 -05:00
Bruce Weirdan
32884774e4 build psalm.phar using humbug/box 2018-03-08 19:14:06 -05:00
Matt Brown
b54fb06552 Handle variable paths in a less naive fashion
Fixes #564
2018-03-08 15:57:46 -05:00
Matt Brown
19ee843d6c Emit InvalidOperand if both sides are not numeric 2018-03-08 14:30:40 -05:00
Matt Brown
56bdb924f5 Fix #563 - improve error message and ignore falsable issues for strtotime 2018-03-08 14:04:00 -05:00
Matt Brown
4873228e52 Fix #561 - add all the do-defined vars before checking loop 2018-03-08 11:17:27 -05:00
Matthew Brown
67312be2a9 Fix #562 - allow if/else blocks to initialise vars 2018-03-08 09:30:31 -05:00
Matt Brown
cd521e7ba5 Also flesh out object like array types 2018-03-07 13:54:46 -05:00
Matt Brown
79c373c121 Add more LessSpecificReturnTypeTests 2018-03-07 13:11:36 -05:00
Matt Brown
692edd44c9 Use properly namespaced generic object 2018-03-07 12:00:33 -05:00
Matt Brown
e5ccdc7fa0 Make sure php string from TClassString is accurate 2018-03-07 11:35:48 -05:00
Matt Brown
4bf652863b Also check for non-false returns on LessSpecificReturnType 2018-03-07 11:16:56 -05:00
Matt Brown
d185253396 Don’t throw exception if classloader hasn’t been set 2018-03-06 17:30:54 -05:00
Matt Brown
4248cacbaf Flesh out template type before replacing 2018-03-06 14:23:41 -05:00
Matt Brown
6d767de043 Ignore nullable class strings where appropriate 2018-03-06 14:11:32 -05:00
Matt Brown
fac5554e13 Fix errors around static class constants in template vars 2018-03-06 13:59:59 -05:00
Matt Brown
b664c85642 Add new issue conditional on config flag 2018-03-06 12:19:50 -05:00
Matt Brown
357ad1aa82 Add config flags to allow stricter class invocation checks 2018-03-06 11:20:59 -05:00
Matthew Brown
4074b3fff0 Fix ctype_xdigit 2018-03-05 23:20:55 -05:00
Matthew Brown
123f70fc52 All the ctype functions con take a string or an int 2018-03-05 23:19:12 -05:00
Matt Brown
57bbdc8034 Replace classlike name with more accurate context self 2018-03-05 18:05:12 -05:00
Matt Brown
7c5986de01 Add return type checks for missing classes 2018-03-05 17:46:13 -05:00
Matt Brown
aff689deea Add support for __CLASS__ in template types 2018-03-05 17:36:08 -05:00
Matt Brown
57c2adb923 Fix #558 - add extra tests around functionality 2018-03-05 17:10:52 -05:00
Matt Brown
850998ed1a Add class-string type for enforcing use of ::class constants 2018-03-05 16:06:06 -05:00
Matt Brown
d8825701f5 Fix #556 - closure params with defaults can still accept extra 2018-03-05 10:29:19 -05:00
Matthew Brown
a0be2e390a Fix case of mapping function before analysis 2018-03-05 09:05:38 -05:00
Matthew Brown
67cad2063d Fix #555 - fix function name mapping class 2018-03-05 09:01:24 -05:00
Matthew Brown
806b032b13 Downgrade UndefinedMethod to PossiblyUndefinedMethod issue when one type has __call defined 2018-03-04 13:23:40 -05:00
Matthew Brown
5f03d08cb2 Remove unused variable 2018-03-04 12:54:00 -05:00
Matthew Brown
a0ce8791d3 Detect fatal issues where property access is overridden
Fixes #547
2018-03-04 12:24:50 -05:00
Matthew Brown
9d48585b0e Fix #552 - fix path that stubs are loaded from 2018-03-03 19:05:15 -05:00
Matthew Brown
3b48f43fdc Throw exception if function doesn’t exist 2018-03-03 16:52:48 -05:00
Matthew Brown
ecef628e21 Prevent iterating over undefined class 2018-03-03 16:52:04 -05:00
Matthew Brown
6458aa2e91 Remove unused methods 2018-03-03 15:29:13 -05:00
Matthew Brown
b90a58533b Fix tests and return types 2018-03-03 15:25:35 -05:00
Matthew Brown
ade9e03c85 Use composer autoloader for class resolution where possible 2018-03-03 15:19:05 -05:00
Matthew Brown
9fe4a97851 Fix issue with do 2018-03-03 13:21:52 -05:00
Matthew Brown
e419a8fe01 Exit early when there’s an issue in block-level elements
Fixes #550
2018-03-03 13:20:41 -05:00
Matthew Brown
9fd009a61d Add more debug output for composer classmaps 2018-03-03 12:15:22 -05:00
Matt Brown
276c1a785d Allow underscores to be ignored by UnusedParam checks 2018-03-02 11:32:34 -05:00
Matthew Brown
d94abc42e8 Fix array location 2018-03-02 08:38:16 -05:00
Matthew Brown
ee6a9b98fb Allow arrays to be called (ugh) 2018-03-02 00:49:53 -05:00
Matthew Brown
154341577d Give expected/actual argument counts 2018-03-02 00:07:19 -05:00
Matthew Brown
799e81bc96 Improve callable issue message 2018-03-02 00:03:07 -05:00
Matthew Brown
6fbd8753d5 Fix $function_id when checking for method existence 2018-03-01 23:52:11 -05:00
Matthew Brown
cc19f50c04 Prevent missing classes from confounding callable arg checks 2018-03-01 23:43:52 -05:00
Matthew Brown
6660aa8a00 Fix #548 - check array_map/array_filter args for param matches 2018-03-01 23:33:21 -05:00
Matt Brown
2846e549dd Fix #546 - allow iterable phpstorm generics 2018-03-01 11:19:23 -05:00
Matt Brown
80864b1ce8 Don’t be concerned about unused params named $_
Fixes #540
2018-02-27 11:39:26 -05:00
Matt Brown
1f358e36ef Fix #544 - remove possibly assigned try vars from catch initialisations 2018-02-27 11:25:27 -05:00
Matthew Brown
115e647c3c Fix #543 - register static vars properly so their references can be caught 2018-02-26 19:32:26 -05:00
Matt Brown
30c6aa5c68 Add missing spaces 2018-02-26 11:09:17 -05:00
Matt Brown
93b714d7c8 Fix #541 - make array_map on object-like more accurate 2018-02-26 11:01:30 -05:00
Matt Brown
9d165bee7b Fix generic return type for array_map
Ref #541
2018-02-26 10:39:48 -05:00
Matthew Brown
42965bff65 Bust Psalm statements cache when upgrading Psalm version 2018-02-25 11:35:43 -05:00
Matthew Brown
2be2769008 Don’t adhere to assert rules with ored truths 2018-02-25 11:30:45 -05:00
Matthew Brown
47cb74ddd1 Fix issue where namespaced function could be treated as root 2018-02-25 11:13:00 -05:00
Matthew Brown
956972b4a4 Fix #539 - evaluate global variable usage 2018-02-25 10:43:54 -05:00
Matt Brown
ad3fe0974f Fix indentation 2018-02-23 15:41:07 -05:00
Matt Brown
441506ad6f Fix #216 - scan assert* functions for assertions, then apply to current context 2018-02-23 15:39:33 -05:00
Matthew Brown
cb1fd308f6 Don’t rescan files when afterVisitClassLike plugin method is active 2018-02-22 22:52:22 -05:00
Matthew Brown
8f2ef50947 Ensure that ClassLikeStorage exists when running plugin method 2018-02-22 22:35:48 -05:00
Matthew Brown
6d658ef934 Fix #535 - always run afterVisitClassLike plugin if given 2018-02-22 22:22:31 -05:00
Matt Brown
95642aafb4 Fix #339 - when a class is also in the callmap, use the user-defined behaviour 2018-02-22 13:42:34 -05:00
Matt Brown
25400e8010 Simplify logic to avoid Psalm bug 2018-02-22 11:57:15 -05:00
Matt Brown
1f7d95dde0 Add better typing rules for generic objects 2018-02-22 11:20:03 -05:00
Matt Brown
09d708981a Add mixed checks to property __set calls 2018-02-21 19:34:21 -05:00
Matt Brown
5471b89391 Make array coercion an error 2018-02-21 18:59:31 -05:00
Matt Brown
a81c73301b Warn early if the file being analysed has not been properly scanned 2018-02-21 13:54:11 -05:00
Matt Brown
316dd78e6a Fix #509 - don’t complain about a missing param type when system parent has one 2018-02-21 11:57:52 -05:00
Matt Brown
e04c4f866c Fix #524 - prevent fatal error when checking stubbed function from namespace 2018-02-21 11:32:52 -05:00
Matt Brown
9dce508689 Always rescan traits 2018-02-20 13:20:31 -05:00
Matt Brown
cd60786ced Always use class file path in the cache key to prevent duplicate clashes 2018-02-20 10:56:18 -05:00
Matthew Brown
ec74b82587 Fix #532 - register anonymous classes declared in file too 2018-02-20 09:02:51 -05:00
Matthew Brown
d10212b393 Fix perpetual diff builds 2018-02-19 23:36:36 -05:00
Tyson Andre
cdcec69536 Support the pylint output format
This is a compact output format that is easy to write scripts that parse.
(And errors fit on a single line)

- E.g. jenkins violation plugin works reliably with pylint.

The multi-line details are deliberately omitted.
An application can output 'console' to stdout and to
a pylint file at the same time.

Files with the extension .pylint will use this format.

Document the emacs and pylint output formats in `psalm --help`

An optional followup task would be to create unique issue codes,
I don't have any use cases for that.
2018-02-19 22:35:48 -05:00
Matthew Brown
a99e89495b Add end line/column data for LSP support 2018-02-19 18:16:09 -05:00
Matthew Brown
04a1583783 Fix bad iterator 2018-02-19 17:01:55 -05:00
Tyson Andre
7aeacebba4 Fix possible typos in comments and issue messages 2018-02-19 15:35:13 -05:00
Matthew Brown
82fe241831 Add included files when scanning cached storage 2018-02-19 15:17:28 -05:00
Matthew Brown
d8b9bcba4d Normalise file path for cache 2018-02-19 12:06:13 -05:00
Matthew Brown
724e72af58 Don’t get statements from cache if file hasn’t changed 2018-02-19 11:53:30 -05:00
Matthew Brown
634375ae94 Make igbinary the default serializer
Fix #484 and fix #527
2018-02-19 11:14:07 -05:00
Matthew Brown
81fd016120 Fix #193 - allow caching of storages 2018-02-19 00:27:39 -05:00
Tyson Andre
aea3779c96 Fix unused imports in psalm, wrong param order doc comments (#523)
(Some of the imports appear as strings elsewhere in the same file)
2018-02-18 17:55:11 -05:00
Matthew Brown
ec5c9c862c Add missing file 2018-02-17 20:45:09 -05:00
Matthew Brown
59dc239c89 Fix #522 - prevent interface instantiation 2018-02-17 18:53:02 -05:00
Matthew Brown
108ca54867 Fix #516 - make sure --find-references-to doesn’t output missing references 2018-02-17 17:45:30 -05:00
Matthew Brown
a0e88cb16f Fix #518 - improve dead code detection to cover variable method calls 2018-02-17 17:23:57 -05:00
Matthew Brown
b041797cd0 Fix #519 - warn about variable calls on non-objects 2018-02-17 17:16:22 -05:00
Matthew Brown
af1155239e Fix bug when assigning nested arrays with variable offsets 2018-02-17 12:32:19 -05:00
Matthew Brown
c87204acbf Don’t check for unused vars when checking for initialiasations
Fixes #517
2018-02-17 12:02:31 -05:00
Matthew Brown
09f86ceee7 Introduce MissingDependency issue, separate from UndefinedClass
Ref #511
2018-02-17 11:36:20 -05:00
Matthew Brown
88ca7d2fa7 Fix #515 - make Psalm aware of variable array keys 2018-02-17 11:24:08 -05:00
Matthew Brown
f56edd3c04 Fix issue found by better analysis 2018-02-17 11:21:45 -05:00
Matthew Brown
7940268a13 Fix #512 - check for undefined constant in param default 2018-02-15 20:27:42 -05:00
Matthew Brown
a6b54a3607 Fix #513 - make sure numeric is treated like a number 2018-02-15 19:50:50 -05:00
Matt Brown
279b0bc16e Fix #511 - check all class references for missing dependencies 2018-02-14 13:34:16 -05:00
Matt Brown
be75c143d4 Fix #510 - check that constructor parent classes and interfaces exist 2018-02-14 11:21:43 -05:00
Matt Brown
d0a2258806 Fix #508 - make sure trait missing property checks happen on correct file 2018-02-12 10:46:45 -05:00
Matthew Brown
affcaebc3d Use classes, not full method ids, for plugin execution 2018-02-11 22:49:19 -05:00
Matthew Brown
f159cd5146 Add declaring/appearing method ids to method check plugin 2018-02-11 21:07:19 -05:00
Matthew Brown
e862e4ddb1 Make all plugin methods static
cc @TysonAndre
2018-02-11 20:56:34 -05:00
Matthew Brown
f17ba65731 Fix #438 - assign both sides of by-ref vars to mixed 2018-02-11 10:39:21 -05:00
Matthew Brown
217233472c Fix #457 - fix objectlike property isset check 2018-02-10 23:30:40 -05:00
Matthew Brown
24416feb62 Improve handling of unset calls with possibly undefined variables 2018-02-10 10:30:08 -05:00
Nicky Robinson
8e77ff1ce9 Throw error if magic getter or setter called for undefined property or invalid type specified with annotations (#500)
* Fix path to psalm

* If a magic getter or setter is used to access a property on a class
that is not defined but a `@property` annotation for the property
exists, throw an error. If no `@property` annotation exists, it's not
an error because you're allowed to make magic getters and setters do
crazy things.

Fixes #480

* Move logic to a better place to avoid duplicate checks

* Move logic into function

* Remove some nesting

* Check psalm-seal-properties and property type correctly
2018-02-09 19:37:09 -05:00
Matt Brown
55c12cd01c Add a bit of documentation 2018-02-09 17:51:49 -05:00
Tyson Andre
eb69d55b29 Update documentation of void types in CallMap (#504)
The empty string is treated more like mixed
2018-02-09 00:31:25 -05:00
Matthew Brown
40efa9e8aa Fix #503 - make sure mixed array type is set for MixedMethodCall 2018-02-08 23:22:29 -05:00
Matt Brown
283e0a6af2 Migrate class constant handling into codebase classes 2018-02-08 18:18:34 -05:00
Matt Brown
6f7903716d Move property lookup api into codebase class 2018-02-08 18:14:28 -05:00
Matt Brown
78cc1786c8 Don’t check newly-scoped vars in conditional 2018-02-08 14:46:06 -05:00
Matt Brown
30ca2ad65f Fix issues with mixed assignments inside loop 2018-02-08 14:02:32 -05:00
Matt Brown
72675cb5a0 Be more rigorous about atomic docblock type reconciliation 2018-02-08 13:01:39 -05:00
Matthew Brown
6955f77e2e Fix #493 - add support for multiple @var lines per docblock 2018-02-07 23:33:31 -05:00
Matthew Brown
24e03edefa Fix #485 when return type is a generator 2018-02-07 22:29:32 -05:00
Matthew Brown
1ae58f0386 Fix #501 - allow analysis to continue after bad constant check 2018-02-07 20:26:26 -05:00
Matt Brown
7f4be858c2 Fix #498 - add better issue type for docblock contradiction 2018-02-07 15:20:47 -05:00
Matt Brown
685ea29ebe Move asserted var creation after conditional reconciliation 2018-02-07 14:13:57 -05:00
Matt Brown
b4281748bc Remove redundant code found by Psalm 2018-02-07 13:57:45 -05:00
Tyson Andre
7bfd782d90 Make call map types slightly more specific (manually) (#495)
* Make call map types slightly more specific (manually)

* Address review comments
2018-02-07 10:17:18 -05:00
Tyson Andre
c7f3a3c445 Make types in the call map more specific (#496)
fix a few incorrect types.
2018-02-06 23:46:22 -05:00
Matthew Brown
1288915aba Change number return type to numeric
cc @TysonAndre
2018-02-06 22:22:50 -05:00
Matthew Brown
970ceab396 Check loop context var exists
This can happen if the parent has been reassigned
2018-02-06 21:03:36 -05:00
Tyson Andre
0bc7ac11f1 Improve callmap with information from docs.php.net (#494)
* Update CallMap.php with information from docs.php.net

* Undo possibly inaccurate information from docs.php.net

* Fix bug in ReflectionMethod::invoke*() signature

http://php.net/manual/en/reflectionmethod.invoke.php had a misleading
method signature description section
2018-02-06 20:50:32 -05:00
Matt Brown
1df4c3d196 Add DocblockTypeContradiction to find possible issues with docblock types
Fixes #491
2018-02-06 18:44:53 -05:00
Matt Brown
fc58655963 Make logic more Psalm-compatible 2018-02-06 13:52:59 -05:00
Matt Brown
1d46124bab Fix issues found by detecting docblock type inconsistencies 2018-02-06 13:40:28 -05:00
Matt Brown
4b87612bb4 Add better issue message for bad array offset
Fixes #492
2018-02-06 11:27:01 -05:00
Matt Brown
d88eadbb0e Fix #486 - skip first reconciliation in loop checker for do stmts 2018-02-06 11:07:52 -05:00
Matthew Brown
beb4993736 Add more text feedback when running from command line 2018-02-06 01:11:33 -05:00
Matt Brown
8747d78c39 Suppress RedundantCondition when analysing first loop of do
Ref #486
2018-02-05 17:29:13 -05:00
Tyson Andre
5ac01abbe5 Fix a few signatures of Iterator classes for void
This was done automatically via sed.
Other types can be added in separate PRs
2018-02-05 17:16:49 -05:00
Matt Brown
5d25edf80c Deal with overlapping docblock types and typehints better 2018-02-05 16:57:33 -05:00
Matt Brown
2e443dce85 Revert "Fix private constructor check"
This reverts commit 684eb7923b, because it introduces more problems than it solves
2018-02-05 15:53:39 -05:00
Matt Brown
684eb7923b Fix private constructor check 2018-02-05 13:06:03 -05:00
Matthew Brown
0c23c59820 Improve formatting of end message 2018-02-04 12:34:22 -05:00
Matthew Brown
e6c0fbf3b8 Create PropertyMap handler class 2018-02-04 12:34:08 -05:00
Matthew Brown
473a174f23 Memoise type tokenisation and move functions to more logical locations 2018-02-04 12:23:32 -05:00
Matthew Brown
7d6dc7252a Allow methods that extend nullable callmap methods to not return a value 2018-02-04 09:22:24 -05:00
Matthew Brown
645602a38e Properly namespace @property types 2018-02-03 23:10:22 -05:00
Matthew Brown
77a0720b65 Break up Populator method 2018-02-03 20:03:31 -05:00
Matthew Brown
8e0998e081 Break apart the Codebase class 2018-02-03 18:56:54 -05:00
Matthew Brown
e5bc0e6129 Fix #431 - report invalid return types before invalid nullable/falsable ones 2018-02-02 19:08:10 -05:00
Matthew Brown
c05baf47ce Fix more Reflection return types 2018-02-02 16:35:40 -05:00
Matthew Brown
b771658821 Fix Reflector::export return types in callmap 2018-02-02 15:28:39 -05:00