File tree 2 files changed +13
-0
lines changed
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)
226
226
throw new InvalidArgumentException ("{$ const } not defined " );
227
227
}
228
228
229
+ assert (
230
+ self ::noAmbiguousValues (static ::getConstants ()),
231
+ 'Ambiguous enumerator values detected for ' . static ::class
232
+ );
233
+
229
234
return self ::$ instances [static ::class][$ name ] = new static (\constant ($ const ));
230
235
}
231
236
Original file line number Diff line number Diff line change @@ -339,6 +339,14 @@ public function testDisabledAssertAmbiguousEnumeratorValues()
339
339
EnumAmbiguous::get ('unknown ' );
340
340
}
341
341
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
+
342
350
public function testExtendedEnabledAssertAmbiguousEnumeratorValues ()
343
351
{
344
352
$ this ->expectException (AssertionError::class);
You can’t perform that action at this time.
0 commit comments