-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds support for internal enums with the same basic approach as userland enums. Enum values are stored as CONSTANT_AST and objects created during constant updating at runtime. This means that we need to use mutable_data for internal enums. This just adds basic support and APIs, it does not include the stubs integration from #7212. Closes GH-7302.
- Loading branch information
Showing
11 changed files
with
250 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--TEST-- | ||
Internal enums | ||
--EXTENSIONS-- | ||
zend_test | ||
--FILE-- | ||
<?php | ||
|
||
var_dump($bar = ZendTestUnitEnum::Bar); | ||
var_dump($bar === ZendTestUnitEnum::Bar); | ||
var_dump($bar instanceof UnitEnum); | ||
|
||
var_dump($foo = zend_get_unit_enum()); | ||
var_dump($foo === ZendTestUnitEnum::Foo); | ||
|
||
var_dump(ZendTestUnitEnum::cases()); | ||
echo "\n"; | ||
|
||
var_dump($foo = ZendTestStringEnum::Foo); | ||
var_dump($foo instanceof BackedEnum); | ||
var_dump(ZendTestStringEnum::Foo->value); | ||
var_dump($bar = ZendTestStringEnum::from("Test2")); | ||
var_dump($bar === ZendTestStringEnum::Bar); | ||
var_dump(ZendTestStringEnum::tryFrom("Test3")); | ||
var_dump(ZendTestStringEnum::cases()); | ||
|
||
var_dump($s = serialize($foo)); | ||
var_dump(unserialize($s)); | ||
var_dump(unserialize($s) === $foo); | ||
|
||
?> | ||
--EXPECT-- | ||
enum(ZendTestUnitEnum::Bar) | ||
bool(true) | ||
bool(true) | ||
enum(ZendTestUnitEnum::Foo) | ||
bool(true) | ||
array(2) { | ||
[0]=> | ||
enum(ZendTestUnitEnum::Foo) | ||
[1]=> | ||
enum(ZendTestUnitEnum::Bar) | ||
} | ||
|
||
enum(ZendTestStringEnum::Foo) | ||
bool(true) | ||
string(5) "Test1" | ||
enum(ZendTestStringEnum::Bar) | ||
bool(true) | ||
NULL | ||
array(2) { | ||
[0]=> | ||
enum(ZendTestStringEnum::Foo) | ||
[1]=> | ||
enum(ZendTestStringEnum::Bar) | ||
} | ||
string(30) "E:22:"ZendTestStringEnum:Foo";" | ||
enum(ZendTestStringEnum::Foo) | ||
bool(true) |
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
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
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
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
a374230
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. I'm afraid the PHP building with the configuration from community job is broken after this commit.
NTS+DEBUG+ASAN build of PHP. I used the similar configurations with the community job.
Here is the ASAN error message:
I'm not sure whether you can reproduce it or not. If yes, could you help to take a look at this error? Thanks.
a374230
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shqking Thanks, it should be fixed by 645ef62.
a374230
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I just now suspected this line. Thanks for your quick fix.