File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ public function __toString()
8282 */
8383 final public function equals (Enum $ enum )
8484 {
85- return $ this ->getValue () === $ enum ->getValue ();
85+ return $ this ->getValue () === $ enum ->getValue () && get_called_class () == get_class ( $ enum ) ;
8686 }
8787
8888 /**
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * @link http://github.com/myclabs/php-enum
4+ * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
5+ */
6+ namespace MyCLabs \Tests \Enum ;
7+
8+ use MyCLabs \Enum \Enum ;
9+
10+ /**
11+ * Class EnumConflict
12+ *
13+ * @method static EnumConflict FOO()
14+ * @method static EnumConflict BAR()
15+ *
16+ * @author Daniel Costa <danielcosta@gmail.com>
17+ * @author Mirosław Filip <mirfilip@gmail.com>
18+ */
19+ class EnumConflict extends Enum
20+ {
21+ const FOO = "foo " ;
22+ const BAR = "bar " ;
23+ }
Original file line number Diff line number Diff line change @@ -242,4 +242,12 @@ public function testEqualsComparesProblematicValuesProperly()
242242 $ this ->assertFalse ($ emptyString ->equals ($ null ));
243243 $ this ->assertFalse ($ null ->equals ($ false ));
244244 }
245+
246+ /**
247+ * equals()
248+ */
249+ public function testEqualsConflictValues ()
250+ {
251+ $ this ->assertFalse (EnumFixture::FOO ()->equals (EnumConflict::FOO ()));
252+ }
245253}
You can’t perform that action at this time.
0 commit comments