-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On itself it doesn't do much good as property fetch analyzer doesn't support object intersections yet. But it's a groundwork for future enhancements.
- Loading branch information
Showing
6 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Psalm\Storage\Assertion; | ||
|
||
use Psalm\Storage\Assertion; | ||
|
||
/** | ||
* @psalm-immutable | ||
*/ | ||
final class DoesNotHaveProperty extends Assertion | ||
{ | ||
public string $property_name; | ||
|
||
public function __construct(string $property_name) | ||
{ | ||
$this->property_name = $property_name; | ||
} | ||
|
||
public function getNegation(): Assertion | ||
{ | ||
return new HasProperty($this->property_name); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return '!has-property-' . $this->property_name; | ||
} | ||
|
||
public function isNegationOf(Assertion $assertion): bool | ||
{ | ||
return $assertion instanceof HasProperty && $this->property_name === $assertion->property_name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Psalm\Storage\Assertion; | ||
|
||
use Psalm\Storage\Assertion; | ||
|
||
/** | ||
* @psalm-immutable | ||
*/ | ||
final class HasProperty extends Assertion | ||
{ | ||
public string $property_name; | ||
|
||
public function __construct(string $property_name) | ||
{ | ||
$this->property_name = $property_name; | ||
} | ||
|
||
public function getNegation(): Assertion | ||
{ | ||
return new DoesNotHaveProperty($this->property_name); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return 'has-property-' . $this->property_name; | ||
} | ||
|
||
public function isNegationOf(Assertion $assertion): bool | ||
{ | ||
return $assertion instanceof DoesNotHaveProperty && $this->property_name === $assertion->property_name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters