1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-14 18:36:58 +01:00
Commit Graph

244 Commits

Author SHA1 Message Date
Matt Brown
58b306b6e3 Ensure class template types are mapped to static methods where necessary
Ref #4733
2020-11-29 17:40:52 -05:00
Matt Brown
ea314cc1c0 Simplify calling of replacer methods 2020-11-29 16:27:00 -05:00
Matt Brown
15a5bd5e29 Simplify storage and retrieval of extended template params 2020-11-29 15:05:32 -05:00
Matthew Brown
60ac109c01
Add RedundantPropertyInitializationCheck (#4732)
* Add RedundantPropertyInitializationCheck

* add documentation for RedundantPropertyInitializationCheck (#4734)

Co-authored-by: orklah <orklah@users.noreply.github.com>
2020-11-29 11:57:20 -05:00
Matt Brown
0efd4ebd7d Detect some erroneous issets 2020-11-29 09:26:39 -05:00
orklah
e2030b4a1e
fix #3282 (#4724) 2020-11-28 09:03:03 -05:00
Matt Brown
5f065d3d74 Turn template bound tuples into object
Ref #4714
2020-11-27 11:43:30 -05:00
Matt Brown
60b3086b9a Fix #4609 - add more attribute rules 2020-11-22 01:15:52 -05:00
Matt Brown
1fc1cae1d5 Fix #4615 - ensure promoted properties are not treated as uninitialized 2020-11-22 00:32:02 -05:00
orklah
6b72599ec5
allow static return type in PHP8 (#4641) 2020-11-20 18:46:35 -05:00
Matt Brown
ff3fff56d4 Simplify assertion negations, centralising as much as possible
Now the flag passed to scrapeAssertions just determines the errors emitted
2020-11-19 14:32:49 -05:00
Matt Brown
4bb84f7f0a Add more attributes to fake PhpParser generated expressions
Ref #4600
2020-11-18 10:16:41 -05:00
Matt Brown
579327a470 Detect when targets are incorrectly targeted 2020-10-30 13:28:45 -04:00
Matt Brown
f8eee22f77 Add basic support for PHP attributes
Ref #4367 - supports creation and argument checks
2020-10-24 00:10:22 -04:00
Niclas van Eyk
0261024aa6
Initial proposal for psalm-require-{extends, implements} (#4361)
* initial implementation of psalm-require-extends

* Added @psalm-require-implements

* Added shortcode for ExtensionRequirementViolation

* Docs & cofig entries for @pasalm-require-{implements,extends}

* Added requirement violations to issues.md
2020-10-19 15:08:18 -04:00
orklah
10f2966dcb
return types (#4311)
* return types

* remove willReturn for void methods
2020-10-12 15:02:52 -04:00
Matt Brown
8b7657f379 Fix #4297 - use correct property id for each different MissingConstructor error 2020-10-07 17:54:00 -04:00
orklah
37a2f8a33d
unused use statements (#4228) 2020-09-22 01:10:46 -04:00
orklah
cb7065ae07
replace deprecated methods with their equivalent (#4217) 2020-09-20 08:56:49 -04:00
Brown
f180fb23bc Fix #4178 - always detect missing property types 2020-09-13 16:50:50 -04:00
orklah
da47588f91
replace return; by return null; in every non-void method, add return null; when mising, add return types, remove redundant phpdoc (#4176) 2020-09-13 16:39:06 -04:00
orklah
ead107fa9e
More return types (#4173)
* add native return types

* redundant phpdoc
2020-09-12 11:24:05 -04:00
Brown
eda426a594 Improve unique issue solution 2020-09-10 22:54:30 -04:00
Brown
2100dbd8aa Fix #4167 - allow many issues for the same position 2020-09-10 17:41:45 -04:00
orklah
8c7423505a
add native param types (#4137)
* add native param types

* redundant phpdoc

* add more param types and adds "?" to nullable types

* remove redundant phpdoc

* add more param types and remove redundant phpdoc

* add more param types and remove redundant phpdoc
2020-09-06 19:36:47 -04:00
Brown
4d82d3ddad Fix #4128 - improve understanding of preg_match_all 2020-09-04 18:10:14 -04:00
Brown
cf3e92410c Prevent crash when suppressing UndefinedTrait
Fixes #4130
2020-09-04 16:50:10 -04:00
orklah
f66d57f19d
add native return types (#4116)
* add native return types

* remove redundant phpdoc
2020-09-04 16:26:33 -04:00
orklah
73f6fcde48
Short list syntax (#4102)
* Short list syntax

* revert unrelated CS
2020-09-02 00:17:41 -04:00
Bruce Weirdan
ffb316a9e6
Converted MissingPropertyType to property issue (#4099)
Fixes vimeo/psalm#2200
2020-09-01 09:21:03 -04:00
Brown
4e10a0ed6f Fix #4036 - add immutable annotations automatically too 2020-08-24 19:29:00 -04:00
Brown
cdef4ec351 Alter docblock params too 2020-08-14 16:26:55 -04:00
Brown
dbcf154036 Add fixer for mismatching param names 2020-08-14 15:25:21 -04:00
Brown
1533debe86 Fix style thinggs 2020-08-10 12:43:19 -04:00
the-toster
5bdc9723ff
fix for DeprecatedClass suppress on property (#3962)
* add test case for DeprecatedClass suppress on property

* fix test case for DeprecatedClass suppress on property - suppress MissingConstructor also

* ugly way to fix - double analyze propery statement to get dockblock + fix in TypeChecker - respect given suppressed_issues in checkNamedObject

* replace double analyze propery with direct DocBlock manipulation

* replace double analyze propery with direct DocBlock manipulation

* add exception handler to keep original addContextProperties behavior

* correct way to unwrap value from array
2020-08-10 10:50:37 -04:00
Daniel Melchior
fa73c7c9d9
Fix #3757 - allow multiple mixins (#3772) 2020-08-05 15:49:19 -04:00
Matthew Brown
ab714a40c4 Allow binding of static to current final class
Ref #3892
2020-07-25 17:26:07 -04:00
Brown
3687d34a5a Detect bad class constants more explicitly 2020-07-24 15:38:56 -04:00
Barney Laurance
ff432ff73d
Simplify error messages and implementation for internal errors (#3881)
* Use more consistent language for Internal errors

There's no meaningful distinction between something being internal and
being 'marked as internal'.

* Rename property psalm_internal to internal in all storage classes

This property holds metadata that can be set using either @internal
or @psalm-internal in docblocks

* Change types of internal properties in storage from ?string to string

Simpler type is easier to handle. Non-internal methods can be considered
to be internal to the entire universe of PHP code, i.e. that code whose
namespace starts with the empty string. It's not a special case.
2020-07-24 09:32:54 -04:00
Barney Laurance
3bc91b9944
Fix multiple issues with @internal and @psalm-internal (#3841)
* Add passing tests for property fetch on an @internal class

I'm trying to work out why the equivilent InvalidCodeParse test is
failing for PsalmInternal

* Treat all properties of a psalm-internal class as psalm-internal

* Remove all $internal properties from storage - use psalm_internal instead

@internal can be represented as internal to the namespace root, avoiding
the need to check for both properties in storage later.

* Raise InternalClass issue when an internal class is used with e.g. instanceOf

* fix docs and tests

* Add return type declartion to code example in doc

* Don't allow class psalm-internal to overide a tighter method psalm-internal

* Break up long line

* Code style - move && from EOL to SOL

* Restore misplaced &&

* Fix code style

* Fix namespace fetching so it works

Co-authored-by: Matthew Brown <github@muglug.com>
2020-07-22 19:27:35 -04:00
Brown
76bd5b6278 Refactor type comparison 2020-07-21 19:40:35 -04:00
Brown
295adb5763 Fix #3860 - use correct trait element positions for nested error 2020-07-21 14:17:07 -04:00
Brown
2afbf58324 Prevent adding trait property types 2020-07-10 19:11:06 -04:00
Brown
33a834bb0b Fix some property inference bugs 2020-07-08 14:43:36 -04:00
Brown
619c384509 Add indentation as necessary between property docblocks 2020-07-08 14:32:16 -04:00
Brown
cf67b9eef1 Fix #435 - add psalter fix for MissingPropertyType 2020-07-08 12:03:12 -04:00
Brown
6bdff42cda Add support for potentially-assigned properties 2020-07-08 11:46:55 -04:00
Brown
0034f2e4bd Don’t manipulate property storage during analysis 2020-07-07 19:32:44 -04:00
Brown
5da29955ee Use better replacement when analysing potentially-inherited templated type 2020-07-03 12:25:33 -04:00
Brown
fca350c498 Prevent a few crashes with really bad code 2020-07-01 10:30:10 -04:00
Brown
bcd7478352 Reduce memory footprint a little 2020-06-25 19:12:30 -04:00
Andrei Petre
3497ca07b6
Extending final class is prohibited #3037 (#3576) 2020-06-13 00:29:59 -04:00
Brown
d04e21ee5a Define mixin declaring classname 2020-05-26 23:32:07 -04:00
Brown
240b2f898c Add some negative test cases for @mixin
Also fix #3452
2020-05-25 00:19:52 -04:00
Brown
0b2da18f1e Break up StatementsAnalyzer 2020-05-19 12:56:30 -04:00
Matthew Brown
8c236f411a Fix #3353 - allow extending nested when nested as type is mixed 2020-05-12 15:07:16 -04:00
Brown
8f2f2617d4 Improve refactor 2020-05-10 22:45:01 -04:00
Brown
5f4d162dd5 Break out type expander into separate class 2020-05-10 22:39:18 -04:00
Matthew Brown
1b752d06ab Fix #3201 - add additional constraints on constructor initialisation 2020-04-21 00:04:47 -04:00
Brown
5ef82b53f6 Fix #3137 - support nested templates in class definitions 2020-04-17 01:16:15 -04:00
Matthew Brown
6f28ee684a Fix #3156 - only override existing property types with @property suggestions 2020-04-16 00:22:00 -04:00
Matthew Brown
82197f1761 Add many slashes 2020-03-29 15:56:45 -04:00
Matthew Brown
ce3532490c Add profiling for analysing slow methods 2020-03-29 15:42:00 -04:00
Matthew Brown
5395183837 Use more accurate means of determining whether function did return 2020-03-28 23:37:42 -04:00
Matthew Brown
93735712f0 Fix #3032 - always replay docblock issues when analysing files 2020-03-28 19:54:55 -04:00
Matthew Brown
47c1470e3b Refactor reference checks to use more appropriate properties 2020-03-28 16:30:56 -04:00
Brown
cc548a45fa Improve detection of unused classes 2020-03-28 14:45:58 -04:00
Brown
056f4aaac6 Fix #3027 - inherited properties should be templated properly 2020-03-27 18:31:48 -04:00
Brown
031c5be8e6 Check trait methods better 2020-03-27 00:37:33 -04:00
Brown
971ae50bea Do prep work for #3024 - improve handling of absent class references 2020-03-26 12:35:27 -04:00
Matthew Brown
f94ab22a5f Be better about strict inference 2020-03-25 09:18:49 -04:00
Matthew Brown
26694345d6 Fix unknown variable 2020-03-21 20:53:46 -04:00
Matthew Brown
6746f1c047 Fix #3004 - reset property types inside a closure defined in a class 2020-03-21 20:46:38 -04:00
Matthew Brown
96fbcd5a64 Break out more methods 2020-03-11 23:38:49 -04:00
Matthew Brown
973703e396 Break out template param collection 2020-03-11 23:15:15 -04:00
Matthew Brown
bfb919d26a Break out methods into their own classes 2020-03-11 23:04:52 -04:00
Brown
2c8688dd97 Don’t crash when conditionally defining classes with properties 2020-03-09 14:24:19 -04:00
Matthew Brown
c0c878cc9d Don’t cache all traits 2020-03-02 22:27:54 -05:00
Matthew Brown
e0d555e203 Allow function names to passed in as strings for callable template resolution 2020-02-29 15:43:45 -05:00
Matthew Brown
a706f4d722 Fix #2242 - warn when using mutable dependencies 2020-02-22 10:04:46 -05:00
Matthew Brown
653353709a Use MethodIdentifier object instead of string 2020-02-14 20:54:26 -05:00
Matthew Brown
07a53f6b81 Fix #2789 - Numeric should not be a reserved class name 2020-02-11 22:34:34 -05:00
Brown
f141f7c526 Improve --diff checks by including trait-using classes in dependents 2020-02-11 16:39:33 -05:00
Brown
d8f5ad190b Improve invalidation of inherited properties 2020-02-10 17:03:51 -05:00
Matthew Brown
da541dbb51 Remove some unnecessary errors 2020-02-06 23:10:18 -05:00
Brown
6116b457ed Port over more fixes from template match refactor 2020-02-06 15:07:57 -05:00
Brown
4c83ca75b3 Fix #2738 - clear out property issues when modifying constructors 2020-02-03 16:43:25 -05:00
Matthew Brown
d0b87b6cb0 Fix #2723 - use magic method return type where necessary 2020-02-01 18:21:32 -05:00
Matthew Brown
8202af957d Index issues by file to reduce some lookups 2020-01-21 21:07:44 -05:00
Brown
0132b3789b Fix #2665 - warn about abstract class interface inheritance issues 2020-01-21 11:46:51 -05:00
Matthew Brown
9fa2db1b6c Move Union::getTypes to Union::getAtomicTypes 2020-01-04 12:20:26 -05:00
Matthew Brown
3d03da271d Fix tests to give more accurate locations 2019-12-20 18:18:26 +00:00
Matthew Brown
a4191171bf Fix #2483 - treat intersecting PHPDocs from interfaces better 2019-12-20 01:42:57 +00:00
Brown
6d02aa86e8 Reconcile string emptiness a bit better 2019-12-13 15:51:54 -05:00
Matthew Brown
04879af105 Be less forgiving when extending builtin generic classes 2019-11-30 09:32:21 -05:00
Bruce Weirdan
33142e7637 Use unalised trait name when importing aliased trait (#2393)
Fixes vimeo/psalm#2392
Refs vimeo/psalm#2278
2019-11-29 01:21:00 -05:00
Matthew Brown
d1fbd1fa26 Add working arrow-functions implementation 2019-11-26 23:52:26 -05:00
Brown
0bcb7863f3 Use better system for storing inferred types and assertions 2019-11-25 11:44:54 -05:00
Brown
895737d8be Fix style 2019-11-08 12:49:53 -05:00
Brown
ac6256e645 Fix #2312, improve understanding of template replacement 2019-11-08 11:56:41 -05:00