AndrolGenhald
cc2334f40d
More class const improvements.
...
Add InvalidClassConstType issue as alternative to LessSpecificClassConstType when type isn't contravariant.
Handle final class consts (#6395 ).
Use double quotes for types in class const issues.
2022-02-13 17:19:25 -06:00
Bruce Weirdan
11e60fa261
Merge branch '4.x' into upstream-master
2022-02-11 03:51:48 +02:00
adrew
121a801616
Fix object constant inference
2022-01-31 23:03:34 +03:00
AndrolGenhald
282518ce5f
Fix failing case in ClassConstAnalyzer and add test.
2022-01-27 21:50:36 -06:00
AndrolGenhald
0b81f46bb1
Fixes after rebasing.
2022-01-25 15:31:09 -06:00
AndrolGenhald
0edf260d8b
Improve class constant static analysis.
...
Add class const covariance support (fixes #5589 ).
Add check for overriding const from interface in PHP < 8.1 (fixes #7108 ).
Add check for ambiguous const inheritance.
2022-01-25 15:20:17 -06:00
AndrolGenhald
7d256975e4
Fix cs/psalm errors after rebase.
2022-01-22 17:06:54 -06:00
AndrolGenhald
1686f28a37
Default to using inferred type unless in late static binding context.
2022-01-22 17:06:54 -06:00
AndrolGenhald
0fb0632e0d
Infer type from known ternary condition.
2022-01-22 17:06:54 -06:00
AndrolGenhald
558208e44e
Add type checking for class const assignments, fix several other const issues.
2022-01-22 17:06:54 -06:00
AndrolGenhald
c877ce031e
Use inferred type instead of annotated type where possible.
2022-01-22 17:06:54 -06:00
AndrolGenhald
c18a155f77
Support type annotations for class consts ( fixes #942 ).
2022-01-22 17:06:53 -06:00
orklah
0e891f25ad
refactor description of types in Atomic
2022-01-22 19:34:57 +01:00
Matthew Brown
b49682a485
Simplify issue suppression in tests
2022-01-13 14:38:17 -05:00
Matthew Brown
f439d6550b
Ensure that all entries in test arrays have explicit keys ( #7386 )
...
* Transformation that updates assertions
* Simplify transformation
* Ensure that all tests have keys
* Fix a few remaining keys
2022-01-13 13:49:37 -05:00
Bruce Weirdan
ff9b214f65
Merge branch '4.x' into upstream-master
2022-01-04 10:07:18 +02:00
orklah
6f9cbc698b
resolve type alias and class const on UnionTypeComparator
2022-01-04 00:14:08 +01:00
orklah
0747b48d06
remove TEmpty
2022-01-03 04:09:59 +02:00
rarila
97e6511fab
Set number of lines before and after namespace.
2021-12-15 04:58:32 +01:00
ralila
8fb2e0f885
Handle some partials
2021-12-04 21:55:53 +01:00
Bruce Weirdan
0a9154b8bb
Allow references to enum cases in class constants
2021-11-15 05:56:09 +02:00
Bruce Weirdan
85f2083acb
Flag duplicate constants
...
Fixes vimeo/psalm#6882
Addresses p1 from vimeo/psalm#6471
2021-11-11 00:44:17 +02:00
orklah
e7a86148b0
Allow Psalm to store unresolved Unary Ops
2021-10-10 09:24:25 +02:00
orklah
dbf3512b70
introduce $definite_class flag and use it to avoid using final keyword for simple inference
2021-08-19 23:19:59 +02:00
orklah
1bf7447685
small refactor, add LiteralClassString, remove alter code blocks
2021-08-17 18:51:59 +02:00
orklah
9264ea5cbb
Allow type inference on dynamic ClassConstFetch
2021-08-16 21:20:20 +02:00
Bruce Weirdan
6294e06955
Improve constant array inference
...
This fixes int offset inference and adds handling for array unpacks in
constant arrays. Mostly it's copy/pasted from `ArrayAnalyzer` with
further adjustments.
Fixes vimeo/psalm#6263
Fixes vimeo/psalm#6289
2021-08-12 20:39:21 +03:00
orklah
f8644fb508
Improve resolution of __METHOD__ and __FUNCTION__
2021-07-03 10:01:53 +02:00
Bruce Weirdan
5bfb841072
Prevent crashes when class constant references missing class ( #5902 )
...
Fixes vimeo/psalm#5861
2021-06-07 13:20:07 -04:00
orklah
0b96f40198
quote offset value ( #5760 )
2021-05-14 17:19:23 -04:00
Matthew Brown
78ed9404cb
Fix #4107 - resolve reference to static in class constant
2021-05-13 12:49:33 -04:00
AndrolGenhald
9a03598a6d
Improve type resolution of class constants. ( #5591 )
...
Handle array plus operator (fixes #5588 ).
Handle array spread operator.
Improve string concatenation to resolve to literal instead of unknown string.
I feel like it should be possible to let ConstantTypeResolver take advantage of
the better type analysis in ArrayAnalyzer, ConcatAnalyzer, etc, but it would
require a restructuring that's beyond me for the time being.
2021-04-07 21:56:35 -04:00
AndrolGenhald
d4590711d6
Fix object-like array keys when combining string and automatic keys ( fixes #5427 ). ( #5428 )
...
* Fix object-like array keys (fixes #5427 ).
* Fix incorrect return types for tests.
* Fix false positive list with literal int key.
2021-03-19 21:44:44 -04:00
Matt Brown
b64eb6d716
Break out array_key_exists tests
2020-12-02 14:42:16 -05:00
Matt Brown
d47d817843
Fix #4479 - use correct keys in message
2020-11-05 10:13:08 -05:00
orklah
ead107fa9e
More return types ( #4173 )
...
* add native return types
* redundant phpdoc
2020-09-12 11:24:05 -04:00
Matthew Brown
422271b2cf
Prevent variables named "haystack" from receiving literal strings
...
cc @staabm
2020-09-05 00:35:48 -04:00
Bruce Weirdan
6fb63903c1
Infer better types for magic constants used in const initializers ( #3602 )
...
Fixes vimeo/psalm#3464
2020-06-18 09:48:51 -04:00
Matthew Brown
ce445636e7
Fix #3535 - match template param class constants properly
2020-06-06 20:02:14 -04:00
El Azimov
bed5a74065
Add wildcard support for class constants in template. ( #3489 )
...
Co-authored-by: El Azimov <el.azimov@rocks>
2020-05-30 16:55:18 -04:00
Brown
235704ad49
Fix #3484 - use better method to determine constant existence in wildcard checks
2020-05-29 09:09:59 -04:00
Brown
9b413cfccc
Improved understanding of array_key_exists
...
Fixes #3463
2020-05-27 09:03:36 -04:00
Brown
7af771a006
Fix #3132 - resolve array access in constant properly
2020-04-18 12:39:00 -04:00
Matthew Brown
7fdccc0439
Fix #3014 - change constant class access rules
2020-03-29 09:47:29 -04:00
Matthew Brown
c85fa9083d
Fix #2915 - prevent "if (true)" and similar
2020-03-15 22:23:31 -04:00
Matthew Brown
17afeae851
Fix support for bitwise or in constant expressions
2020-03-09 00:54:26 -04:00
Brown
443558ca49
Fix #2844 - resolve constant offset references
2020-02-21 15:56:30 -05:00
Matthew Brown
cf977c3542
Don’t convert constant descriptions to lowercase
2020-02-17 18:19:33 -05:00
Matthew Brown
8dd49b1cbf
Fix lowercase-string to constant string coercion
2020-02-17 17:58:36 -05:00
Brown
1c42875179
Support lowercase-string and warn about unnecessary calls to strtolower
2020-02-13 16:38:58 -05:00