-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c5108b
commit 9964bb6
Showing
27 changed files
with
796 additions
and
146 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
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
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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Eventjet\Ausdruck; | ||
|
||
use Eventjet\Ausdruck\Parser\Span; | ||
|
||
trait LocationTrait | ||
{ | ||
private readonly Span $location; | ||
|
||
public function location(): Span | ||
{ | ||
return $this->location; | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Eventjet\Ausdruck; | ||
|
||
use Eventjet\Ausdruck\Parser\Span; | ||
|
||
use function sprintf; | ||
|
||
/** | ||
* @template T of int | float | ||
* @extends Expression<T> | ||
*/ | ||
final class Negative extends Expression | ||
{ | ||
use LocationTrait; | ||
|
||
/** | ||
* @param Expression<T> $expression | ||
*/ | ||
public function __construct(public readonly Expression $expression, Span $location) | ||
{ | ||
$this->location = $location; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return sprintf('-%s', $this->expression); | ||
} | ||
|
||
/** | ||
* @psalm-suppress InvalidReturnType False positive | ||
*/ | ||
public function evaluate(Scope $scope): float|int | ||
{ | ||
/** @psalm-suppress InvalidReturnStatement False positive */ | ||
return -$this->expression->evaluate($scope); | ||
} | ||
|
||
public function equals(Expression $other): bool | ||
{ | ||
return $other instanceof self | ||
&& $this->expression->equals($other->expression); | ||
} | ||
|
||
public function getType(): Type | ||
{ | ||
return $this->expression->getType(); | ||
} | ||
} |
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
Oops, something went wrong.