Skip to content
Merged
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
36 changes: 30 additions & 6 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
fail-fast: false
matrix:
php:
- "8.2"
- "8.3"
- "8.4"
dependencies:
- ""
- "--prefer-lowest"
Expand Down Expand Up @@ -42,7 +42,8 @@ jobs:
fail-fast: false
matrix:
php:
- "8.2"
- "8.3"
- "8.4"
dependencies:
- ""
- "--prefer-lowest"
Expand Down Expand Up @@ -72,8 +73,8 @@ jobs:
fail-fast: false
matrix:
php:
- "8.2"
- "8.3"
- "8.4"
dependencies:
- ""
- "--prefer-lowest"
Expand Down Expand Up @@ -103,8 +104,8 @@ jobs:
fail-fast: false
matrix:
php:
- "8.2"
- "8.3"
- "8.4"
dependencies:
- ""
- "--prefer-lowest"
Expand Down Expand Up @@ -136,8 +137,8 @@ jobs:
fail-fast: false
matrix:
php:
- "8.2"
- "8.3"
- "8.4"
dependencies:
- ""
- "--prefer-lowest"
Expand Down Expand Up @@ -180,8 +181,8 @@ jobs:
fail-fast: false
matrix:
php:
- "8.2"
- "8.3"
- "8.4"
dependencies:
- ""
- "--prefer-lowest"
Expand Down Expand Up @@ -230,3 +231,26 @@ jobs:
with:
name: infection-log-${{ matrix.php }}-${{ matrix.dependencies }}.txt
path: infection-log.txt

bc-breaks:
name: Backward Compatibility

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: ctype

- name: Install dependencies
run: composer update --no-progress --no-interaction

- name: "Check for BC breaks"
run: vendor/bin/roave-backward-compatibility-check
23 changes: 15 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@
"license": "MIT",
"type": "library",
"require": {
"php": ">=8.2",
"php": ">=8.3",
"ext-ctype": "*"
},
"require-dev": {
"eventjet/coding-standard": "^3.18",
"infection/infection": "^0.29.10",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"amphp/dns": "^2.4",
"amphp/socket": "^2.3.1",
"beberlei/assert": "^3.3.3",
"composer/pcre": "^3.3",
"eventjet/coding-standard": "^3.12",
"friendsofphp/php-cs-fixer": "^3.88",
"infection/infection": "^0.31.2",
"maglnet/composer-require-checker": "^4.16",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^2.1.29",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^11.5",
"psalm/plugin-phpunit": "^0.19.2",
"vimeo/psalm": "^6.2"
"phpunit/phpunit": "^12.3",
"psalm/plugin-phpunit": "^0.19.5",
"roave/backward-compatibility-check": "^8.14",
"vimeo/psalm": "^6.13"
},
"minimum-stability": "stable",
"autoload": {
Expand Down
3 changes: 3 additions & 0 deletions infection.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"$schema": "vendor/infection/infection/resources/schema.json",
"timeout": 2,
"source": {
"directories": [
"src"
]
},
"staticAnalysisTool": "phpstan",
"staticAnalysisToolOptions": "--memory-limit=256M",
"logs": {
"text": "infection-log.txt"
},
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 array_key_exists;
use function count;
Expand Down Expand Up @@ -54,23 +55,27 @@ public function __toString(): string
return sprintf('%s === %s', $this->left, $this->right);
}

#[Override]
public function evaluate(Scope $scope): bool
{
return self::compareValues($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
5 changes: 5 additions & 0 deletions src/FieldAccess.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_object;
Expand All @@ -29,11 +30,13 @@ public function __toString(): string
return sprintf('%s.%s', $this->struct, $this->field);
}

#[Override]
public function location(): Span
{
return $this->location;
}

#[Override]
public function evaluate(Scope $scope): mixed
{
$struct = $this->struct->evaluate($scope);
Expand All @@ -47,13 +50,15 @@ public function evaluate(Scope $scope): mixed
return $struct->{$this->field};
}

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

#[Override]
public function getType(): Type
{
return $this->struct->getType()->fields[$this->field];
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
Loading