File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,11 @@ final public static function byName(string $name)
226226 throw new InvalidArgumentException ("{$ const } not defined " );
227227 }
228228
229+ assert (
230+ self ::noAmbiguousValues (static ::getConstants ()),
231+ 'Ambiguous enumerator values detected for ' . static ::class
232+ );
233+
229234 return self ::$ instances [static ::class][$ name ] = new static (\constant ($ const ));
230235 }
231236
Original file line number Diff line number Diff line change @@ -339,6 +339,14 @@ public function testDisabledAssertAmbiguousEnumeratorValues()
339339 EnumAmbiguous::get ('unknown ' );
340340 }
341341
342+ public function testByNameAmbiguousEnumeratorValues ()
343+ {
344+ $ this ->expectException (AssertionError::class);
345+ $ this ->expectExceptionMessage ('Ambiguous enumerator values detected for ' . EnumAmbiguous::class);
346+
347+ EnumAmbiguous::byName ('AMBIGUOUS_INT1 ' );
348+ }
349+
342350 public function testExtendedEnabledAssertAmbiguousEnumeratorValues ()
343351 {
344352 $ this ->expectException (AssertionError::class);
You can’t perform that action at this time.
0 commit comments