Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
fail-fast: false
matrix:
php:
- "8.1"
- "8.2"
- "8.3"
dependencies:
Expand Down Expand Up @@ -43,8 +42,8 @@ jobs:
fail-fast: false
matrix:
php:
- "8.1"
- "8.2"
- "8.3"
dependencies:
- ""
- "--prefer-lowest"
Expand Down Expand Up @@ -74,7 +73,6 @@ jobs:
fail-fast: false
matrix:
php:
- "8.1"
- "8.2"
- "8.3"
dependencies:
Expand Down Expand Up @@ -106,7 +104,6 @@ jobs:
fail-fast: false
matrix:
php:
- "8.1"
- "8.2"
- "8.3"
dependencies:
Expand Down Expand Up @@ -140,7 +137,6 @@ jobs:
fail-fast: false
matrix:
php:
- "8.1"
- "8.2"
- "8.3"
dependencies:
Expand Down Expand Up @@ -171,9 +167,9 @@ jobs:
--coverage-clover=build/coverage/clover.xml

- name: Upload coverage
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.php }}
name: coverage-${{ matrix.php }}-${{ matrix.dependencies }}
path: build/coverage/

infection:
Expand All @@ -185,7 +181,6 @@ jobs:
fail-fast: false
matrix:
php:
- "8.1"
- "8.2"
- "8.3"
dependencies:
Expand All @@ -211,9 +206,9 @@ jobs:
run: composer update --no-progress --no-interaction ${{ matrix.dependencies }}

- name: Download coverage
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage-${{ matrix.php }}
name: coverage-${{ matrix.php }}-${{ matrix.dependencies }}
path: build/coverage/

- name: Infection coverage of changed lines
Expand All @@ -231,10 +226,10 @@ jobs:
-jmax

- name: Save Infection result
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: infection-log-${{ matrix.php }}.txt
name: infection-log-${{ matrix.php }}-${{ matrix.dependencies }}.txt
path: infection-log.txt

bc-breaks:
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
"license": "MIT",
"type": "library",
"require": {
"php": ">=8.1",
"php": ">=8.2",
"ext-ctype": "*"
},
"require-dev": {
"eventjet/coding-standard": "^3.12",
"eventjet/coding-standard": "^3.18",
"friendsofphp/php-cs-fixer": "^3.75",
"infection/infection": "^0.27.0",
"maglnet/composer-require-checker": "^4.6",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10.34",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpstan/phpstan": "^1.12.25",
"phpstan/phpstan-phpunit": "^1.4.2",
"phpstan/phpstan-strict-rules": "^1.6.2",
"phpunit/phpunit": "^10.2",
"psalm/plugin-phpunit": "^0.18.4",
"roave/backward-compatibility-check": "^8.3",
"vimeo/psalm": "^5.16"
"vimeo/psalm": "^5.26.1"
},
"minimum-stability": "stable",
"autoload": {
Expand Down
5 changes: 5 additions & 0 deletions src/And_.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Eventjet\Ausdruck;

use Eventjet\Ausdruck\Parser\Span;
use Override;

use function get_debug_type;
use function is_bool;
Expand All @@ -25,6 +26,7 @@ public function __toString(): string
return sprintf('%s && %s', $this->left, $this->right);
}

#[Override]
public function evaluate(Scope $scope): bool
{
$left = $this->left->evaluate($scope);
Expand All @@ -37,18 +39,21 @@ public function evaluate(Scope $scope): bool
return $left && $right;
}

#[Override]
public function equals(Expression $other): bool
{
return $other instanceof self
&& $this->left->equals($other->left)
&& $this->right->equals($other->right);
}

#[Override]
public function getType(): Type
{
return Type::bool();
}

#[Override]
public function location(): Span
{
return $this->left->location()->to($this->right->location());
Expand Down
4 changes: 4 additions & 0 deletions src/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Eventjet\Ausdruck;

use Eventjet\Ausdruck\Parser\Span;
use Override;
use Throwable;

use function array_map;
Expand Down Expand Up @@ -57,6 +58,7 @@ public function __toString(): string
return sprintf('%s.%s:%s(%s)', $this->target, $this->name, $this->type, implode(', ', $this->arguments));
}

#[Override]
public function evaluate(Scope $scope): mixed
{
$func = $scope->func($this->name);
Expand All @@ -72,6 +74,7 @@ public function evaluate(Scope $scope): mixed
}
}

#[Override]
public function equals(Expression $other): bool
{
return $other instanceof self
Expand All @@ -81,6 +84,7 @@ public function equals(Expression $other): bool
&& self::compareArguments($this->arguments, $other->arguments);
}

#[Override]
public function getType(): Type
{
return $this->type;
Expand Down
5 changes: 5 additions & 0 deletions src/Eq.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Eventjet\Ausdruck;

use Eventjet\Ausdruck\Parser\Span;
use Override;

use function sprintf;

Expand All @@ -23,23 +24,27 @@ public function __toString(): string
return sprintf('%s === %s', $this->left, $this->right);
}

#[Override]
public function evaluate(Scope $scope): bool
{
return $this->left->evaluate($scope) === $this->right->evaluate($scope);
}

#[Override]
public function equals(Expression $other): bool
{
return $other instanceof self
&& $this->left->equals($other->left)
&& $this->right->equals($other->right);
}

#[Override]
public function getType(): Type
{
return Type::bool();
}

#[Override]
public function location(): Span
{
return $this->left->location()->to($this->right->location());
Expand Down
16 changes: 4 additions & 12 deletions src/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,22 @@ public function eq(self $other): Eq

public function subtract(self $subtrahend): Subtract
{
/** @var self $self */
$self = $this;
return Expr::subtract($self, $subtrahend);
return Expr::subtract($this, $subtrahend);
}

public function gt(self $right): Gt
{
/** @var self $self */
$self = $this;
return Expr::gt($self, $right);
return Expr::gt($this, $right);
}

public function or_(self $other): Or_
{
/** @var self $self */
$self = $this;
return Expr::or_($self, $other);
return Expr::or_($this, $other);
}

public function and_(self $other): self
{
/** @var self $self */
$self = $this;
return Expr::and_($self, $other);
return Expr::and_($this, $other);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Eventjet\Ausdruck\Parser\Span;
use Eventjet\Ausdruck\Parser\TypeHint;
use Override;

use function get_debug_type;
use function sprintf;
Expand Down Expand Up @@ -34,6 +35,7 @@ public function __toString(): string
return sprintf('%s%s', $this->name, $this->typeHint);
}

#[Override]
public function evaluate(Scope $scope): mixed
{
/** @psalm-suppress MixedAssignment */
Expand All @@ -57,13 +59,15 @@ public function evaluate(Scope $scope): mixed
}
}

#[Override]
public function equals(Expression $other): bool
{
return $other instanceof self
&& $this->name === $other->name
&& $this->typeHint->type->equals($other->typeHint->type);
}

#[Override]
public function getType(): Type
{
return $this->typeHint->type;
Expand Down
5 changes: 5 additions & 0 deletions src/Gt.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Eventjet\Ausdruck;

use Eventjet\Ausdruck\Parser\Span;
use Override;

use function sprintf;

Expand All @@ -23,23 +24,27 @@ public function __toString(): string
return sprintf('%s > %s', $this->left, $this->right);
}

#[Override]
public function evaluate(Scope $scope): bool
{
return $this->left->evaluate($scope) > $this->right->evaluate($scope);
}

#[Override]
public function equals(Expression $other): bool
{
return $other instanceof self
&& $this->left->equals($other->left)
&& $this->right->equals($other->right);
}

#[Override]
public function getType(): Type
{
return Type::bool();
}

#[Override]
public function location(): Span
{
return $this->left->location()->to($this->right->location());
Expand Down
4 changes: 4 additions & 0 deletions src/Lambda.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Eventjet\Ausdruck;

use Eventjet\Ausdruck\Parser\Span;
use Override;

use function array_map;
use function implode;
Expand Down Expand Up @@ -34,6 +35,7 @@ public function __toString(): string
/**
* @return callable(Scope): mixed
*/
#[Override]
public function evaluate(Scope $scope): callable
{
return function (mixed ...$params) use ($scope): mixed {
Expand All @@ -45,13 +47,15 @@ public function evaluate(Scope $scope): callable
};
}

#[Override]
public function equals(Expression $other): bool
{
return $other instanceof self
&& $this->parameters === $other->parameters
&& $this->body->equals($other->body);
}

#[Override]
public function getType(): Type
{
return Type::func($this->body->getType(), array_map(static fn(string $_name) => Type::any(), $this->parameters));
Expand Down
5 changes: 5 additions & 0 deletions src/ListLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Eventjet\Ausdruck;

use Eventjet\Ausdruck\Parser\Span;
use Override;

use function array_map;
use function implode;
Expand All @@ -23,6 +24,7 @@ public function __toString()
return '[' . implode(', ', $this->elements) . ']';
}

#[Override]
public function location(): Span
{
return $this->location;
Expand All @@ -31,6 +33,7 @@ public function location(): Span
/**
* @return list<mixed>
*/
#[Override]
public function evaluate(Scope $scope): array
{
return array_map(
Expand All @@ -39,6 +42,7 @@ public function evaluate(Scope $scope): array
);
}

#[Override]
public function equals(Expression $other): bool
{
if (!$other instanceof self) {
Expand All @@ -53,6 +57,7 @@ public function equals(Expression $other): bool
return true;
}

#[Override]
public function getType(): Type
{
$elementType = null;
Expand Down
Loading
Loading