File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
src/test/php/lang/ast/unittest/emit Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,29 @@ public static function run($arg) {
158
158
Assert::equals ($ expected , $ t ->getMethod ('run ' )->invoke (null , [$ arg ]));
159
159
}
160
160
161
+ #[Test]
162
+ public function declare_method_on_enum () {
163
+ $ t = $ this ->type ('enum <T> {
164
+ case Hearts;
165
+ case Diamonds;
166
+ case Clubs;
167
+ case Spades;
168
+
169
+ public function color() {
170
+ return match ($this) {
171
+ self::Hearts, self::Diamonds => "red",
172
+ self::Clubs, self::Spaces => "black",
173
+ };
174
+ }
175
+
176
+ public static function run() {
177
+ return self::Hearts->color();
178
+ }
179
+ } ' );
180
+
181
+ Assert::equals ('red ' , $ t ->getMethod ('run ' )->invoke (null ));
182
+ }
183
+
161
184
#[Test]
162
185
public function enum_values () {
163
186
$ t = $ this ->type ('enum <T> {
You can’t perform that action at this time.
0 commit comments