-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
raise notice if Reflection::getConstants is used on a enum/enum class…
… that imports constants via enum_inclusion Summary: Goal: get data on how often `ReflectionClass::getConstants` is used on enums or enum classes that use/extend other enums. This diffs updates `getConstants` to `raise_notice` whenever this happens. Reviewed By: viratyosin Differential Revision: D65018282 fbshipit-source-id: aeb0f3e286c6a596b3f6bc80acf4f31496dcbb8b
- Loading branch information
1 parent
c0f20fa
commit 7a50223
Showing
4 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?hh | ||
|
||
enum Enum1: string as string { | ||
A = 'A'; | ||
} | ||
|
||
enum Enum2: string as string { | ||
B = 'B'; | ||
} | ||
|
||
enum Enum3: string as string { | ||
C = 'C'; | ||
} | ||
|
||
enum CombinedEnums: string as string { | ||
use Enum1, Enum2, Enum3; | ||
D = 'D'; | ||
} | ||
|
||
|
||
enum class Base: int { | ||
int BA = 1; | ||
} | ||
|
||
enum class Extd : int extends Base { | ||
int BB = 2; | ||
} | ||
|
||
<<__EntryPoint>> | ||
function main(): void { | ||
$reflector = new ReflectionClass(Enum1::class); | ||
var_dump($reflector->getConstants()); | ||
$reflector = new ReflectionClass(CombinedEnums::class); | ||
var_dump($reflector->getConstants()); | ||
|
||
$reflector = new ReflectionClass(Base::class); | ||
var_dump($reflector->getConstants()); | ||
|
||
$reflector = new ReflectionClass(Extd::class); | ||
var_dump($reflector->getConstants()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
dict(1) { | ||
["A"]=> | ||
string(1) "A" | ||
} | ||
|
||
Notice: ReflectionClass::getConstants() misses constants from the enums/enum classes included by CombinedEnums in %s/enum_supertyping/reflection.php on line 34 | ||
dict(1) { | ||
["D"]=> | ||
string(1) "D" | ||
} | ||
dict(1) { | ||
["BA"]=> | ||
int(1) | ||
} | ||
|
||
Notice: ReflectionClass::getConstants() misses constants from the enums/enum classes included by Extd in %s/reflection.php on line 40 | ||
dict(1) { | ||
["BB"]=> | ||
int(2) | ||
} |