@@ -424,32 +424,6 @@ public function testResolvingCompoundTypedArrayTypes(): void
424424 $ this ->assertInstanceOf (Object_::class, $ secondType ->getValueType ());
425425 }
426426
427- /**
428- * @uses \phpDocumentor\Reflection\Types\Context
429- * @uses \phpDocumentor\Reflection\Types\Compound
430- * @uses \phpDocumentor\Reflection\Types\String_
431- * @uses \phpDocumentor\Reflection\Types\Nullable
432- * @uses \phpDocumentor\Reflection\Types\Null_
433- * @uses \phpDocumentor\Reflection\Types\Boolean
434- * @uses \phpDocumentor\Reflection\Fqsen
435- * @uses \phpDocumentor\Reflection\FqsenResolver
436- *
437- * @covers ::__construct
438- * @covers ::resolve
439- * @covers ::<private>
440- */
441- public function testResolvingNullableCompoundTypes (): void
442- {
443- $ this ->markTestSkipped ('Invalid type definition ' );
444- $ fixture = new TypeResolver ();
445-
446- // Note that in PHP types it is illegal to use shorthand nullable
447- // syntax with unions. This would be 'string|boolean|null' instead.
448- $ resolvedType = $ fixture ->resolve ('?string|null|?boolean ' );
449-
450- $ this ->assertSame ('?string|null|?bool ' , (string ) $ resolvedType );
451- }
452-
453427 /**
454428 * @uses \phpDocumentor\Reflection\Types\Context
455429 * @uses \phpDocumentor\Reflection\Types\Compound
@@ -876,6 +850,7 @@ public function testArrayKeyValueSpecification(): void
876850 * @dataProvider genericsProvider
877851 * @dataProvider callableProvider
878852 * @dataProvider constExpressions
853+ * @dataProvider illegalLegacyFormatProvider
879854 * @testdox create type from $type
880855 */
881856 public function testTypeBuilding (string $ type , Type $ expected ): void
@@ -1093,11 +1068,66 @@ public function constExpressions(): array
10931068 ],
10941069 [
10951070 'Foo::FOO_CONSTANT ' ,
1096- new ConstExpression (new Fqsen ('\\phpDocumentor \\Foo ' ), 'FOO_CONSTANT ' ),
1071+ new ConstExpression (new Object_ ( new Fqsen ('\\phpDocumentor \\Foo ' ) ), 'FOO_CONSTANT ' ),
10971072 ],
10981073 [
10991074 'Foo::FOO_* ' ,
1100- new ConstExpression (new Fqsen ('\\phpDocumentor \\Foo ' ), 'FOO_* ' ),
1075+ new ConstExpression (new Object_ (new Fqsen ('\\phpDocumentor \\Foo ' )), 'FOO_* ' ),
1076+ ],
1077+ [
1078+ 'self::*|null ' ,
1079+ new Compound ([new ConstExpression (new Self_ (), '* ' ), new Null_ ()]),
1080+ ],
1081+ ];
1082+ }
1083+
1084+ /**
1085+ * @return array<array{0: string, 1: Type}>
1086+ */
1087+ public function illegalLegacyFormatProvider (): array
1088+ {
1089+ return [
1090+ [
1091+ '?string|bool ' ,
1092+ new Compound ([new Nullable (new String_ ()), new Boolean ()]),
1093+ ],
1094+ [
1095+ '?string|?bool ' ,
1096+ new Compound ([new Nullable (new String_ ()), new Nullable (new Boolean ())]),
1097+ ],
1098+ [
1099+ '?string|?bool|null ' ,
1100+ new Compound ([new Nullable (new String_ ()), new Nullable (new Boolean ()), new Null_ ()]),
1101+ ],
1102+ [
1103+ '?string|bool|Foo ' ,
1104+ new Compound ([
1105+ new Nullable (new String_ ()),
1106+ new Boolean (),
1107+ new Object_ (new Fqsen ('\\phpDocumentor \\Foo ' )),
1108+ ]),
1109+ ],
1110+ [
1111+ '?string&bool ' ,
1112+ new Intersection ([new Nullable (new String_ ()), new Boolean ()]),
1113+ ],
1114+ [
1115+ '?string&bool|Foo ' ,
1116+ new Intersection (
1117+ [
1118+ new Nullable (new String_ ()),
1119+ new Compound ([new Boolean (), new Object_ (new Fqsen ('\\phpDocumentor \\Foo ' ))]),
1120+ ]
1121+ ),
1122+ ],
1123+ [
1124+ '?string&?bool|null ' ,
1125+ new Compound (
1126+ [
1127+ new Intersection ([new Nullable (new String_ ()), new Nullable (new Boolean ())]),
1128+ new Null_ (),
1129+ ]
1130+ ),
11011131 ],
11021132 ];
11031133 }
0 commit comments