create(ParserFactory::PREFER_PHP7); } private static function getAtomic($string) { return array_values(Type::parseString($string)->types)[0]; } public function testIntOrString() { $this->assertEquals('int|string', (string) Type::parseString('int|string')); } public function testArray() { $this->assertEquals('array', (string) Type::parseString('array')); $this->assertEquals('array', (string) Type::parseString('array')); $this->assertEquals('array', (string) Type::parseString('array')); $this->assertEquals('array', (string) Type::parseString('array')); } public function testGeneric() { $this->assertEquals('B', (string) Type::parseString('B')); } public function testPhpDocStyle() { $this->assertEquals('array', (string) Type::parseString('A[]')); $this->assertEquals('array', (string) Type::parseString('(A|B)[]')); $this->assertEquals('array>', (string) Type::parseString('A[][]')); $this->assertEquals('array>', (string) Type::parseString('(A|B)[][]')); $this->assertEquals('array', (string) Type::parseString('A[]|B[]')); $this->assertEquals('array|C', (string) Type::parseString('A[]|B[]|C')); } public function testObjectLike() { $this->assertEquals('array{a:int, b:string}', (string) Type::parseString('array{a:int, b:string}')); $this->assertEquals( 'array{a:int|string, b:string}', (string) Type::parseString('array{a:int|string, b:string}') ); $this->assertEquals( 'array{a:array, b:string}', (string) Type::parseString('array{a:array, b:string}') ); } }