File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -369,7 +369,10 @@ private static function detectConstants($class)
369369 $ publicConstants = $ scopeConstants + $ publicConstants ;
370370 } while (($ reflection = $ reflection ->getParentClass ()) && $ reflection ->name !== __CLASS__ );
371371
372- assert (self ::noAmbiguousValues ($ publicConstants ));
372+ assert (
373+ self ::noAmbiguousValues ($ publicConstants ),
374+ "Ambiguous enumerator values detected for {$ class }"
375+ );
373376
374377 self ::$ constants [$ class ] = $ publicConstants ;
375378 self ::$ names [$ class ] = \array_keys ($ publicConstants );
@@ -379,7 +382,7 @@ private static function detectConstants($class)
379382 }
380383
381384 /**
382- * Assert that the given enumeration class doesn't define ambiguous enumerator values
385+ * Test that the given constants does not contain ambiguous values
383386 * @param array $constants
384387 * @return bool
385388 */
Original file line number Diff line number Diff line change @@ -313,6 +313,12 @@ public function testInstantiateUsingMagicMethod()
313313 public function testEnabledAssertAmbiguousEnumeratorValues ()
314314 {
315315 $ this ->expectException (AssertionError::class);
316+
317+ if (\PHP_VERSION_ID >= 70000 && strpos (\PHP_VERSION , 'hhvm ' ) === false ) {
318+ // The assertion error contains the assertion description as exception message since PHP-7
319+ $ this ->expectExceptionMessage ('Ambiguous enumerator values detected for ' . EnumAmbiguous::class);
320+ }
321+
316322 EnumAmbiguous::get ('unknown ' );
317323 }
318324
@@ -327,6 +333,12 @@ public function testDisabledAssertAmbiguousEnumeratorValues()
327333 public function testExtendedEnabledAssertAmbiguousEnumeratorValues ()
328334 {
329335 $ this ->expectException (AssertionError::class);
336+
337+ if (\PHP_VERSION_ID >= 70000 && strpos (\PHP_VERSION , 'hhvm ' ) === false ) {
338+ // The assertion error contains the assertion description as exception message since PHP-7
339+ $ this ->expectExceptionMessage ('Ambiguous enumerator values detected for ' . EnumExtendedAmbiguous::class);
340+ }
341+
330342 EnumExtendedAmbiguous::get ('unknown ' );
331343 }
332344
You can’t perform that action at this time.
0 commit comments