1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00
Commit Graph

119 Commits

Author SHA1 Message Date
Evan Shaw
4cec31eba9 Test for dynamic enum fetch 2024-02-05 21:56:30 +13:00
Evan Shaw
a827806709 ParseError for dynamic constants before PHP 8.3 2024-02-05 21:49:40 +13:00
robchett
338b50a959 Change __LINE__ to a positive-int 2023-06-17 12:24:09 +01:00
Markus Staab
9af897f328
Fixed typo in ConstantTest 2023-05-30 08:43:54 +02:00
Yannick Gottschalk
a41eb35b24 Fix #9824 2023-05-28 17:37:16 +02:00
Alessandro Lai
54531a1d31
Add regression test for non-ambiguous constant inheritance 2023-04-27 22:39:52 +02:00
orklah
542d627994
Merge pull request #9393 from ygottschalk/fix/9373-using-enum-property-as-const-array-key
Fix/9373 using enum property as const array key
2023-04-17 12:56:42 +02:00
Maximilian Bösing
3f6f91f0ef
qa: re-order error message to match recent changes
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-04-01 14:57:21 +02:00
Bruce Weirdan
30369e826a
Correctly handle near-overflowing keys and flag autoincrement overflows
Co-authored-by: Maximilian Krög <maxi_kroeg@web.de>
2023-03-12 19:57:14 -04:00
Bruce Weirdan
0e9085f3e0
Handle overflow in SimpleTypeInferer as well 2023-03-12 17:47:42 -04:00
Yannick Gottschalk
ad5bf62094 Fixes #9373 2023-02-24 13:32:04 +01:00
Yannick Gottschalk
98d3514197 Refs #9373, partial fix 2023-02-24 10:17:27 +01:00
Bruce Weirdan
f4e66a0fbf
Add test 2023-02-23 04:01:29 -04:00
Bruce Weirdan
8c491e93e8
Flag class constant references where LHS is ordinary string
Fixes vimeo/psalm#2185
2023-02-15 02:57:00 -04:00
Jack Worman
1c19260cdd Require trailing commas 2022-12-18 13:20:31 -06:00
Jack Worman
643542346b Add codesniffer rules and expand php-cs-fixer to bin and test 2022-12-14 13:29:09 -06:00
Matthew Brown
8d36bdc3ed
Make array shapes strict by default (#8701)
* Make array shapes strict by default

* Fix PSL tests
2022-11-11 20:14:21 -05:00
1986c8b4a8
Add support for strict arrays, fix type alias intersection, fix array_is_list assertion on non-lists (#8395)
* Immutable CodeLocation

* Remove excess clones

* Remove external clones

* Remove leftover clones

* Fix final clone issue

* Immutable storages

* Refactoring

* Fixes

* Fixes

* Fix

* Fix

* Fixes

* Simplify

* Fixes

* Fix

* Fixes

* Update

* Fix

* Cache global types

* Fix

* Update

* Update

* Fixes

* Fixes

* Refactor

* Fixes

* Fix

* Fix

* More caching

* Fix

* Fix

* Update

* Update

* Fix

* Fixes

* Update

* Refactor

* Update

* Fixes

* Break one more test

* Fix

* FIx

* Fix

* Fix

* Fix

* Fix

* Improve performance and readability

* Equivalent logic

* Fixes

* Revert

* Revert "Revert"

This reverts commit f9175100c8452c80559234200663fd4c4f4dd889.

* Fix

* Fix reference bug

* Make default TypeVisitor immutable

* Bugfix

* Remove clones

* Partial refactoring

* Refactoring

* Fixes

* Fix

* Fixes

* Fixes

* cs-fix

* Fix final bugs

* Add test

* Misc fixes

* Update

* Fixes

* Experiment with removing different property

* revert "Experiment with removing different property"

This reverts commit ac1156e077fc4ea633530d51096d27b6e88bfdf9.

* Uniform naming

* Uniform naming

* Hack hotfix

* Clean up $_FILES ref #8621

* Undo hack, try fixing properly

* Helper method

* Remove redundant call

* Partially fix bugs

* Cleanup

* Change defaults

* Fix bug

* Fix (?, hope this doesn't break anything else)

* cs-fix

* Review fixes

* Bugfix

* Bugfix

* Improve logic

* Add support for list{} and callable-list{} types, properly implement array_is_list assertions (fixes #8389)

* Default to sealed arrays

* Fix array_merge bug

* Fixes

* Fix

* Sealed type checks

* Properly infer properties-of and get_object_vars on final classes

* Fix array_map zipping

* Fix tests

* Fixes

* Fixes

* Fix more stuff

* Recursively resolve type aliases

* Fix typo

* Fixes

* Fix array_is_list assertion on keyed array

* Add BC docs

* Fixes

* fix

* Update

* Update

* Update

* Update

* Seal arrays with count assertions

* Fix #8528

* Fix

* Update

* Improve sealed array foreach logic

* get_object_vars on template properties

* Fix sealed array assertion reconciler logic

* Improved reconciler

* Add tests

* Single source of truth for test types

* Fix tests

* Fixup tests

* Fixup tests

* Fixup tests

* Update

* Fix tests

* Fix tests

* Final fixes

* Fixes

* Use list syntax only when needed

* Fix tests

* Cs-fix

* Update docs

* Update docs

* Update docs

* Update docs

* Update docs

* Document missing types

* Update docs

* Improve class-string-map docs

* Update

* Update

* I love working on psalm :)

* Keep arrays unsealed by default

* Fixup tests

* Fix syntax mistake

* cs-fix

* Fix typo

* Re-import missing types

* Keep strict types only in return types

* argc/argv fixes

* argc/argv fixes

* Fix test

* Comment-out valinor code, pinging @romm pls merge https://github.com/CuyZ/Valinor/pull/246 so we can add valinor to the psalm docs :)
2022-11-05 22:34:42 +01:00
da21229cab Fix #8664 2022-11-05 19:15:46 +01:00
Bitwise Operators
9f6ce3059d tests: added tests for bitwise-and, bitwise-xor, bitwise-not and boolean-not class constants 2022-08-04 08:52:43 +02:00
AndrolGenhald
80e94daefb Fix class const issue when using floats declared in future consts (fixes #7973).
- Calculate literal type for float arithmetic instead of only for int arithmetic
 - Fix copy/paste fail causing InvalidConstantAssignmentValue to be marked as fixable
2022-05-20 14:46:05 -05:00
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