drop support for complement type

This commit is contained in:
Jan Tvrdik 2017-10-27 21:20:24 +02:00
parent d23d1c922c
commit 7492b2a16e
4 changed files with 5 additions and 47 deletions

View File

@ -1,6 +1,5 @@
Type
::= Atomic (Union | Intersection)?
| Complement
Union
::= ('|' Atomic)+
@ -8,9 +7,6 @@ Union
Intersection
::= ('&' Atomic)+
Complement
::= '~' Atomic
Atomic
::= Identifier (Generic | Array)?
| '(' Type ')' Array?

View File

@ -1,6 +1,5 @@
Type
= Atomic (Union / Intersection)?
/ Complement
Union
= ('|' Atomic)+
@ -8,9 +7,6 @@ Union
Intersection
= ('&' Atomic)+
Complement
= '~' Atomic
Atomic
= Identifier (Generic / Array)?
/ '(' Type ')' Array?

View File

@ -1,22 +0,0 @@
<?php declare(strict_types = 1);
namespace PhpStan\TypeParser\Ast;
class ComplementNode implements Node
{
/** @var Node */
public $type;
public function __construct(Node $type)
{
$this->type = $type;
}
public function __toString(): string
{
return '~' . $this->type;
}
}

View File

@ -67,18 +67,13 @@ class Parser
private function parseType(): Ast\Node
{
if ($this->tokenType === Lexer::TOKEN_COMPLEMENT) {
$type = $this->parseComplement();
$type = $this->parseAtomic();
} else {
$type = $this->parseAtomic();
if ($this->tokenType === Lexer::TOKEN_UNION) {
$type = $this->parseUnion($type);
if ($this->tokenType === Lexer::TOKEN_UNION) {
$type = $this->parseUnion($type);
} elseif ($this->tokenType === Lexer::TOKEN_INTERSECTION) {
$type = $this->parseIntersection($type);
}
} elseif ($this->tokenType === Lexer::TOKEN_INTERSECTION) {
$type = $this->parseIntersection($type);
}
return $type;
@ -140,13 +135,6 @@ class Parser
}
private function parseComplement(): Ast\Node
{
$this->consume(Lexer::TOKEN_COMPLEMENT);
return new Ast\ComplementNode($this->parseAtomic());
}
private function parseGeneric(Ast\SimpleNode $baseType): Ast\Node
{
$this->consume(Lexer::TOKEN_OPEN_ANGLE_BRACKET);