Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support enums rfc #4313

Open
16 of 18 tasks
TysonAndre opened this issue Dec 22, 2020 · 0 comments
Open
16 of 18 tasks

Support enums rfc #4313

TysonAndre opened this issue Dec 22, 2020 · 0 comments
Labels
enhancement This improves the quality of Phan's analysis of a codebase php8.1 Tracks changes to prepare for analyzing php 8.1 code

Comments

@TysonAndre
Copy link
Member

TysonAndre commented Dec 22, 2020

https://wiki.php.net/rfc/enumerations

  • Update php-ast requirement (1.0.11 partially supports it, 1.0.12 will support the latest php 8.1)
  • Update tolerant-php-parser
  • Warn about instantiating enums
  • Warn about attempting to write to or unset or read missing properties
  • Warn about invalid declarations
  • Warn about mismatch of enum X: int { case INVALID = 'not an int'; }, etc (reading : int requires bumping minimum AST version (from 80 to 85+) and php-ast version
  • Overload template syntax to support enums, or support class constant syntax
  • Warn about enum with no case being suspicious when there are instance methods
  • Warn about instance&static properties on enums being forbidden
  • Class constants would be allowed to be enums
  • Warn about case on non-enum
  • Warn about declaring forbidden magic methods on enums (only __call, __callStatic, and __invoke magic methods are permitted)
     php > enum Foo { public function __set($name, $value) {}}
    
     Fatal error: Enum may not include __set in php shell code on line 1
    
  • Warn about calling clone on enums
  • Infer that $case->name exists on all enums, $case->value exists on backed enums with a int/string type (and doesn't exist on unit enums)
  • Infer that typed enums implement BackedEnum and implement the cases()/from/tryFrom() methods - cases is a list of known size
  • Infer that unit enums implement UnitEnum and implement cases() - cases is still a list
  • Add more specific type signatures for UnitEnum/BackedEnum
  • Infer that ArrayAccess and ... unpacking (Traversable) on enums is forbidden in constant expressions
@TysonAndre TysonAndre changed the title Support enums rfc if it passes and is merged Support enums rfc Apr 14, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue May 14, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue May 14, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue May 14, 2021
TysonAndre added a commit that referenced this issue May 15, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue May 16, 2021
Warn about enums with instance methods but no cases
Warn about enums that contain instance/static methods.
Add other checks

For phan#4313
TysonAndre added a commit to TysonAndre/phan that referenced this issue May 16, 2021
Warn about enums with instance methods but no cases
Warn about enums that contain instance/static methods.
Add other checks

For phan#4313
TysonAndre added a commit to TysonAndre/phan that referenced this issue May 16, 2021
Warn about enums with instance methods but no cases
Warn about enums that contain instance/static methods.
Add other checks

For phan#4313
TysonAndre added a commit to TysonAndre/phan that referenced this issue May 16, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue May 16, 2021
@TysonAndre TysonAndre added enhancement This improves the quality of Phan's analysis of a codebase php8.1 Tracks changes to prepare for analyzing php 8.1 code labels May 18, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue Jul 24, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue Jul 24, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue Jul 24, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue Jul 24, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue Jul 24, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue Sep 7, 2021
TysonAndre added a commit to TysonAndre/phan that referenced this issue Sep 26, 2021
Fix false positive warnings when analyzing enums,
infer that automatically generated methods of enums exist.
For phan#4313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This improves the quality of Phan's analysis of a codebase php8.1 Tracks changes to prepare for analyzing php 8.1 code
Projects
None yet
Development

No branches or pull requests

1 participant