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

62 Commits

Author SHA1 Message Date
Maximilian Bösing
1d4f496d0d
feature: introduce value-of in assertions
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2023-04-01 14:57:20 +02:00
Bruce Weirdan
f801561ea7
Improce enum case reconciliation
Fixes vimeo/psalm#9456
2023-03-05 16:34:51 -04:00
Bruce Weirdan
cee90fc071
Compare enum cases thoroughly
Fixes vimeo/psalm#7814
2023-02-13 22:39:33 -04:00
Bruce Weirdan
873d79c5d7
Forbid overriding built-in enum methods
Fixes vimeo/psalm#9274
2023-02-13 00:37:59 -04:00
Bruce Weirdan
085e8f6fb2
Forbid implementing some interfaces
- `Throwable` can only be implemented when classes extend one of
  `Exception` or `Error`
- `UnitEnum` and `BackedEnum` cannot be implemented by user-defined
  classes

Refs vimeo/psalm#7722
2023-02-12 02:48:50 -04:00
Anner Visser
d86fcf4a85
Narrow ->value of enum case(s) to only the possible values
Using $stmt_var_type to determine if we're dealing with a subset of the
enum cases. If so, we only consider those cases for the possible values.

Fixes #8568
Fixes #8812
2023-01-21 12:05:24 +01:00
Bruce Weirdan
afb8c8891b
fix I::cases() where interface I extends BackedEnum
Fixes vimeo/psalm#9065

Inheritance in stubs seems to be broken
2023-01-05 21:35:47 -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
Bruce Weirdan
19a1005bc3
Forbid most magic methods on enums
Fixes vimeo/psalm#8889

Additionally this fixes case-sensitivity of
MethodSignatureMustOmitReturnType issue

Fixes vimeo/psalm#8888
2022-12-12 03:03:20 -04:00
Bruce Weirdan
c613e47c55
Merge pull request #8693 from weirdan/fix-8267
Fixes https://github.com/vimeo/psalm/issues/8267
2022-11-10 21:13:12 -04:00
Bruce Weirdan
6effd1bd2d Flag invalid enum case value types
Fixes vimeo/psalm#8267
2022-11-10 19:55:18 -04:00
Bruce Weirdan
290b65f6dd Allow enum cases to reference constants
Fixes vimeo/psalm#8242
2022-11-10 19:54:45 -04: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
orklah
0fe6eaf5d9 Merge remote-tracking branch 'upstream/4.x' into upstream-master13 2022-02-26 21:26:59 +01:00
Bei Xiao
40cc346991 Update stub 2022-02-23 00:52:53 +02:00
Bei Xiao
0b24b07423 Specify required php version for test 2022-02-22 23:41:53 +02:00
Bei Xiao
6a3b5679fe Support interfaces extending enums 2022-02-22 16:04:56 +02:00
orklah
aaf34d7573 add test 2022-02-13 19:38:45 +01:00
orklah
9cc82d55f7 add test 2022-02-13 10:52:22 +01:00
orklah
7c4f08067b Merge remote-tracking branch 'upstream/4.x' into upstream-master5 2022-01-23 23:44:04 +01:00
orklah
82d84b0b3a fix internal properties on interfaces 2022-01-23 13:08:35 +01: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
Matthew Brown
2358b96f54
Fix merge errors 2022-01-03 04:10:39 +02:00
Philip Hofstetter
e8e968e8c2
recognize Deprecated attribute on enum cases
just like with properties, this recognizes both `Psalm\Deprecated` and
`JetBrains\PhpStorm\Deprecated`
2021-12-22 06:16:42 +01:00
rarila
97e6511fab Set number of lines before and after namespace. 2021-12-15 04:58:32 +01:00
Ricardo Boss
2ec77fe29c Make name property of enum cases return non-empty-strings (vimeo/psalm#6964) 2021-12-06 00:33:57 +01:00
ralila
8fb2e0f885 Handle some partials 2021-12-04 21:55:53 +01:00
Bruce Weirdan
806db287d2
Infer ::from() and ::tryFrom() return types on backed enums
Fixes vimeo/psalm#6429
2021-11-28 09:47:01 +02:00
Bruce Weirdan
ac903c5634
Include enum cases in const wildcards
Refs vimeo/psalm#6471
2021-11-28 05:49:39 +02:00
Bruce Weirdan
97445b52f3
Correctly process constant references on enum-valued variables 2021-11-27 04:32:32 +02:00
Bruce Weirdan
f215ed28d0
Drop special handling of constant references on enums
Internally enum cases are constants, and they should be resolved as
such.

Fixes vimeo/psalm#6994
2021-11-26 06:00:01 +02:00
orklah
049285add2 allow using EnumCase in an Attribute 2021-11-24 19:43:43 +01:00
Bruce Weirdan
0a9154b8bb
Allow references to enum cases in class constants 2021-11-15 05:56:09 +02:00
Bruce Weirdan
68495be147
Forbid declaring enums as attributes
This is in line with current Psalm behavior. We forbid non-instantiable
classlikes as attributes, including abstract classes and classes with
non-public constructors.

Refs vimeo/psalm#6841
2021-11-07 01:47:11 +02:00
Bruce Weirdan
9210bbcdd4
Forbid enum instantiation
Fixes vimeo/psalm#6837
2021-11-07 00:14:37 +02:00
Bruce Weirdan
59e63c3235
Merge pull request #6839 from weirdan/forbid-enum-properties 2021-11-06 23:15:09 +02:00
Bruce Weirdan
f0f085e084
Add test for NoEnumProperties
This was somehow missed from vimeo/psalm#6836
2021-11-06 22:52:17 +02:00
orklah
18677bb108 better understands value and name properties for enum 2021-11-06 21:49:42 +01:00
Bruce Weirdan
b4f024b1fe
Basic enum checks
* Duplicate cases
* Duplicate case values
* Invalid case values: value on a pure enum case, missing value on a
backed enum case, backing type / case type mismatch
* Literal expression evaluation for case values

Fixes vimeo/psalm#6426
Fixes vimeo/psalm#6427
2021-09-07 12:35:38 +03:00
Bruce Weirdan
7b11024886
Flag invalid backing types for enums
Fixes vimeo/psalm#6428
2021-09-05 20:12:24 +03:00
Matthew Brown
832a190dd4
Support enums (#5699)
* Add initial enum preparation

* Support cases method

* Ignore bad use error

cc @weirdan

* Fix type
2021-05-03 17:54:09 -04:00
Matt Brown
698adeff07 Rename incorrectly-named test 2021-04-25 18:26:00 -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
orklah
ead107fa9e
More return types (#4173)
* add native return types

* redundant phpdoc
2020-09-12 11:24:05 -04:00
Brown
4a434d9a2f Add separate issue for undefined classes in docblocks 2019-05-15 18:41:26 -04:00
Bruce Weirdan
9bdc9f774f More provider typing 2019-03-02 08:43:19 -05:00
Bruce Weirdan
8408effe57 Dropped unused uses 2019-02-17 13:17:45 -05:00