@@ -38,8 +38,14 @@ public function testFromSuccess(): void
3838
3939 public function testFromInvalidValue (): void
4040 {
41+ if (PHP_VERSION_ID < 80200 ) {
42+ $ enumClass = '" ' . BasicStringEnum::class . '" ' ;
43+ } else {
44+ $ enumClass = BasicStringEnum::class;
45+ }
46+
47+ $ this ->expectExceptionMessage ("\"10 \" is not a valid backing value for enum {$ enumClass }" );
4148 $ this ->expectException ('ValueError ' );
42- $ this ->expectExceptionMessage ('"10" is not a valid backing value for enum "BasicStringEnum" ' );
4349 BasicStringEnum::from ('10 ' );
4450 }
4551
@@ -74,13 +80,20 @@ public function testFromUnexpectedBoolTypeError(): void
7480 if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100 ) {
7581 $ class = EmulatedStringEnum::class;
7682 $ type = 'string|int ' ;
83+ $ given = 'bool ' ;
7784 } else {
7885 $ class = BasicStringEnum::class;
7986 $ type = 'string ' ;
87+
88+ if (PHP_VERSION_ID >= 80300 ) {
89+ $ given = 'true ' ;
90+ } else {
91+ $ given = 'bool ' ;
92+ }
8093 }
8194
8295 $ this ->expectException ('TypeError ' );
83- $ this ->expectExceptionMessage ("{$ class }::from(): Argument #1 ( \$value) must be of type {$ type }, bool given " );
96+ $ this ->expectExceptionMessage ("{$ class }::from(): Argument #1 ( \$value) must be of type {$ type }, { $ given } given " );
8497
8598 /** @phpstan-ignore-next-line */
8699 BasicStringEnum::from (true );
@@ -169,13 +182,20 @@ public function testTryFromUnexpectedBoolTypeError(): void
169182 if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100 ) {
170183 $ class = EmulatedStringEnum::class;
171184 $ type = 'string|int ' ;
185+ $ given = 'bool ' ;
172186 } else {
173187 $ class = BasicStringEnum::class;
174188 $ type = 'string ' ;
189+
190+ if (PHP_VERSION_ID >= 80300 ) {
191+ $ given = 'true ' ;
192+ } else {
193+ $ given = 'bool ' ;
194+ }
175195 }
176196
177197 $ this ->expectException ('TypeError ' );
178- $ this ->expectExceptionMessage ("{$ class }::tryFrom(): Argument #1 ( \$value) must be of type {$ type }, bool given " );
198+ $ this ->expectExceptionMessage ("{$ class }::tryFrom(): Argument #1 ( \$value) must be of type {$ type }, { $ given } given " );
179199
180200 /** @phpstan-ignore-next-line */
181201 BasicStringEnum::tryFrom (true );
0 commit comments