Skip to content

Commit

Permalink
Merge pull request #9017 from orklah/isnotaclass
Browse files Browse the repository at this point in the history
Add getAtomicType to IsNotAClass for proper negation Reconciliation
  • Loading branch information
orklah committed Dec 28, 2022
2 parents 7b8b44c + 58853c0 commit 1bd0644
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Psalm/Storage/Assertion/IsAClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getNegation(): Assertion
return new IsNotAClass($this->type, $this->allow_string);
}

public function getAtomicType(): ?Atomic
public function getAtomicType(): Atomic
{
return $this->type;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Psalm/Storage/Assertion/IsNotAClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public function getNegation(): Assertion
return new IsAClass($this->type, $this->allow_string);
}

public function getAtomicType(): Atomic
{
return $this->type;
}

public function __toString(): string
{
return 'isa-' . ($this->allow_string ? 'string-' : '') . $this->type;
Expand Down
1 change: 1 addition & 0 deletions tests/TypeReconciliation/ReconcilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public function providerTestReconcilation(): array
'SimpleXMLIteratorNotAlwaysTruthy' => ['SimpleXMLIterator', new Truthy(), 'SimpleXMLIterator'],
'SimpleXMLIteratorNotAlwaysTruthy2' => ['SimpleXMLIterator', new Falsy(), 'SimpleXMLIterator'],
'stringWithAny' => ['string', new Any(), 'string'],
'IsNotAClassReconciliation' => ['int', new Assertion\IsNotAClass(new TNamedObject('IDObject'), true), 'int|IDObject'],
];
}

Expand Down

0 comments on commit 1bd0644

Please sign in to comment.