Skip to content

Commit

Permalink
Add PHP 8.4 tests support
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Jul 28, 2024
1 parent f39e4a6 commit ac3cbc3
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
stability: [ prefer-lowest, prefer-stable ]
steps:
Expand Down
7 changes: 3 additions & 4 deletions src/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private function each(iterable $nodes): iterable
* Recursively traverse array (usually of nodes).
*
* @param array<array-key, object> $nodes Array to traverse
*
* @return array<array-key, object> Result of traversal. May be original
* array or changed one.
*/
Expand Down Expand Up @@ -229,7 +230,6 @@ protected function traverseArray(array $nodes): array
$error = \sprintf($error, \get_class($visitor), \gettype($visitor));

throw new BadMethodException($error, static::ERROR_CODE_ARRAY_ENTERING);

default:
$error = self::ERROR_ENTER_RETURN_TYPE;
$error = \sprintf($error, \get_class($visitor), \gettype($visitor));
Expand Down Expand Up @@ -297,7 +297,8 @@ protected function traverseArray(array $nodes): array
/**
* Recursively traverse a node.
*
* @param NodeInterface $node NodeInterface to traverse.
* @param NodeInterface $node nodeInterface to traverse
*
* @return NodeInterface Result of traversal (may be original node or new one)
*/
protected function traverseNode(NodeInterface $node): NodeInterface
Expand Down Expand Up @@ -375,7 +376,6 @@ protected function traverseNode(NodeInterface $node): NodeInterface
$error = \sprintf($error, \get_class($visitor));

throw new BadReturnTypeException($error, static::ERROR_CODE_NODE_LEAVING);

default:
$error = self::ERROR_LEAVE_RETURN_TYPE;
$error = \sprintf($error, \get_class($visitor), \gettype($return));
Expand All @@ -396,7 +396,6 @@ protected function traverseNode(NodeInterface $node): NodeInterface

/**
* @param string|int $key
* @param mixed $value
*/
private function updateNodeValue(NodeInterface $node, $key, $value): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/ExecutorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ExecutorInterface
/**
* Traverses an array of nodes using the registered visitors.
*
* @param iterable<array-key, object> $nodes List of nodes.
* @param iterable<array-key, object> $nodes list of nodes
*
* @return iterable<array-key, object> Traversed list of nodes
*/
Expand Down
2 changes: 0 additions & 2 deletions src/Traverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

namespace Phplrt\Visitor;

use Phplrt\Contracts\Ast\NodeInterface;

class Traverser implements TraverserInterface
{
/**
Expand Down
3 changes: 1 addition & 2 deletions src/TraverserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Phplrt\Visitor;

use Phplrt\Contracts\Ast\NodeInterface;

/**
* The TraverserInterface allows to traverse groups of
* nodes using visitor sets.
Expand Down Expand Up @@ -75,6 +73,7 @@ public function without(VisitorInterface $visitor): self;
* registered visitors.
*
* @param iterable<array-key, object> $nodes
*
* @return iterable<array-key, object>
*/
public function traverse(iterable $nodes): iterable;
Expand Down
6 changes: 2 additions & 4 deletions src/VisitorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,26 @@ interface VisitorInterface
* Called once before traversal.
*
* @param iterable|NodeInterface[]|NodeInterface $nodes
*
* @return iterable|NodeInterface[]|NodeInterface|null
*/
public function before(iterable $nodes): ?iterable;

/**
* Called when entering a node.
*
* @return mixed
*/
public function enter(NodeInterface $node);

/**
* Called when leaving a node.
*
* @return mixed
*/
public function leave(NodeInterface $node);

/**
* Called once after traversal.
*
* @param iterable|NodeInterface[]|NodeInterface $nodes
*
* @return iterable|NodeInterface[]|NodeInterface|null
*/
public function after(iterable $nodes): ?iterable;
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Mutations/BeforeTraversingMutationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Phplrt\Visitor\Tests\Unit\Stub\Node;
use Phplrt\Visitor\Tests\Unit\TestCase;
use Phplrt\Visitor\Visitor;
use PHPUnit\Framework\ExpectationFailedException;

/**
* @testdox A set of tests that verify an AST modification using the Visitor::before() method.
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Mutations/EnteringMutationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Phplrt\Visitor\Tests\Unit\Stub\Node;
use Phplrt\Visitor\Tests\Unit\TestCase;
use Phplrt\Visitor\Visitor;
use PHPUnit\Framework\ExpectationFailedException;

/**
* @testdox A set of tests that verify an AST modification using the Visitor::enter() method.
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Mutations/LeavingMutationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Phplrt\Visitor\Tests\Unit\Stub\Node;
use Phplrt\Visitor\Tests\Unit\TestCase;
use Phplrt\Visitor\Visitor;
use PHPUnit\Framework\ExpectationFailedException;

/**
* @testdox A set of tests that verify an AST modification using the Visitor::leave() method.
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Stub/Counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
class Counter implements VisitorInterface
{
public $before = 0;
public $after = 0;
public $enter = 0;
public $leave = 0;
public $after = 0;
public $enter = 0;
public $leave = 0;

public function before(iterable $nodes): ?iterable
{
Expand Down
13 changes: 0 additions & 13 deletions tests/Unit/Stub/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,14 @@ class Node implements NodeInterface
*/
public array $children;

/**
* @var int
*/
private int $id;

/**
* @param int $id
* @param array $children
*/
public function __construct(int $id, array $children = [])
{
$this->id = $id;
$this->children = $children;
}

/**
* @return int
*/
public function getId(): int
{
return $this->id;
Expand All @@ -44,9 +34,6 @@ public function getIterator(): \Traversable
return new \ArrayIterator(['children' => $this->children]);
}

/**
* @return int
*/
public function getOffset(): int
{
return 0;
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/TraversableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Phplrt\Visitor\Tests\Unit;

use Phplrt\Visitor\Tests\Unit\Stub\Counter;
use PHPUnit\Framework\ExpectationFailedException;

/**
* @testdox A set of tests that count the number of passes by nodes.
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/VisitorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Phplrt\Visitor\Tests\Unit\Stub\Counter;
use Phplrt\Visitor\Traverser;
use PHPUnit\Framework\ExpectationFailedException;

/**
* @testdox A set of tests that check the interaction of Visitor instances with the Traversable container.
Expand Down

0 comments on commit ac3cbc3

Please sign in to comment.