File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,8 @@ final public function getOrdinal()
128
128
*/
129
129
final public function is ($ enum )
130
130
{
131
- return $ this ->value === $ enum || ($ enum instanceof static && $ this ->value === $ enum ->getValue ());
131
+ return $ this ->value === $ enum
132
+ || (($ enum instanceof static || $ this instanceof $ enum ) && $ this ->value === $ enum ->getValue ());
132
133
}
133
134
134
135
/**
Original file line number Diff line number Diff line change @@ -147,6 +147,21 @@ public function testIsBasic()
147
147
$ this ->assertFalse ($ enum ->is (EnumBasic2::ONE ())); // same value but different instance
148
148
}
149
149
150
+ public function testIsExtended ()
151
+ {
152
+ $ enum1Basic = EnumBasic::ONE ();
153
+ $ enum1Inherited = EnumInheritance::ONE ();
154
+ $ enumExtended = EnumInheritance::INHERITANCE ();
155
+
156
+ $ this ->assertTrue ($ enum1Basic ->is ($ enum1Inherited ));
157
+ $ this ->assertTrue ($ enum1Inherited ->is ($ enum1Basic ));
158
+
159
+ $ this ->assertFalse ($ enumExtended ->is ($ enum1Basic ));
160
+ $ this ->assertFalse ($ enumExtended ->is ($ enum1Inherited ));
161
+ $ this ->assertFalse ($ enum1Basic ->is ($ enumExtended ));
162
+ $ this ->assertFalse ($ enum1Inherited ->is ($ enumExtended ));
163
+ }
164
+
150
165
public function testCallingGetOrdinalTwoTimesWillResultTheSameValue ()
151
166
{
152
167
$ enum = EnumBasic::get (EnumBasic::TWO );
You can’t perform that action at this time.
0 commit comments