Skip to content

Commit

Permalink
Update code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jul 16, 2020
1 parent 3b879f0 commit 97996be
Show file tree
Hide file tree
Showing 30 changed files with 14 additions and 136 deletions.
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
php-version: ${{ matrix.php-versions }}
extensions: ast,mbstring,xdebug
tools: pecl

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
Expand Down
7 changes: 2 additions & 5 deletions spec/loophp/phptree/Node/NaryNodeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ public function it_can_have_children(): void

public function it_can_throw_an_error_when_capacity_is_invalid(): void
{
$this->beConstructedWith(null);
$this->beConstructedWith();

$this
->capacity()
->shouldBeNull();

$this->shouldThrow(Exception::class)
->during('add', [new NaryNode()]);
->shouldBe(0);
}

public function it_can_use_a_different_traverser(): void
Expand Down
2 changes: 0 additions & 2 deletions src/Builder/BuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ interface BuilderInterface
{
/**
* @param iterable<mixed> $nodes
*
* @return NodeInterface|null
*/
public static function create(iterable $nodes): ?NodeInterface;
}
7 changes: 0 additions & 7 deletions src/Builder/Random.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public static function create(iterable $nodes): ?NodeInterface

/**
* @param array<mixed> $parameters
*
* @return \loophp\phptree\Node\NodeInterface
*/
private static function createNode(array $parameters = []): NodeInterface
{
Expand All @@ -60,11 +58,6 @@ static function ($parameter) {
return new $class(...$parameters);
}

/**
* @param \loophp\phptree\Node\NodeInterface $node
*
* @return \loophp\phptree\Node\NodeInterface
*/
private static function pickRandomNode(NodeInterface $node): NodeInterface
{
$pick = (int) random_int(0, $node->count());
Expand Down
3 changes: 0 additions & 3 deletions src/Exporter/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ private function createVertexId(NodeInterface $node): string
return sha1(spl_object_hash($node));
}

/**
* @return \Fhaculty\Graph\Graph
*/
private function getGraph(): OriginalGraph
{
return $this->graph;
Expand Down
2 changes: 0 additions & 2 deletions src/Exporter/Gv.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ private function findEdges(NodeInterface $node): iterable
/**
* Get the default GV file content.
*
* @param string $attributes
* @param string $nodes
* @param string $edges
* The edges.
*
Expand Down
18 changes: 0 additions & 18 deletions src/Exporter/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public function __construct()
}

/**
* @param NodeInterface $node
*
* @throws Exception
*
* @return string
*/
public function export(NodeInterface $node): string
{
Expand All @@ -54,17 +50,12 @@ public function export(NodeInterface $node): string

/**
* Get the executable to use.
*
* @return string
*/
public function getExecutable(): string
{
return $this->executable;
}

/**
* @return string
*/
public function getFormat(): string
{
return $this->format;
Expand All @@ -73,8 +64,6 @@ public function getFormat(): string
/**
* Change the executable to use.
*
* @param string $executable
*
* @return \loophp\phptree\Exporter\Image
*/
public function setExecutable(string $executable): self
Expand All @@ -85,8 +74,6 @@ public function setExecutable(string $executable): self
}

/**
* @param string $format
*
* @return \loophp\phptree\Exporter\Image
*/
public function setFormat(string $format): self
Expand All @@ -96,11 +83,6 @@ public function setFormat(string $format): self
return $this;
}

/**
* @param string $path
*
* @return string
*/
private function getConvertCommand(string $path): string
{
return sprintf(
Expand Down
10 changes: 0 additions & 10 deletions src/Importer/MicrosoftTolerantPhpParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,19 @@ final class MicrosoftTolerantPhpParser implements ImporterInterface
* @param SourceFileNode $data
*
* @throws Exception
*
* @return NodeInterface
*/
public function import($data): NodeInterface
{
return $this->parseNode($this->createNode(['label' => 'root']), $data);
}

/**
* @param array $attributes
*
* @return AttributeNodeInterface
*/
private function createNode(array $attributes): AttributeNodeInterface
{
return new AttributeNode($attributes);
}

/**
* @param AttributeNodeInterface $parent
* @param Node ...$astNodes
*
* @return NodeInterface
*/
private function parseNode(AttributeNodeInterface $parent, Node ...$astNodes): NodeInterface
{
Expand Down
10 changes: 0 additions & 10 deletions src/Importer/NikicPhpAst.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ final class NikicPhpAst implements ImporterInterface
* @param Node $data
*
* @throws Exception
*
* @return NodeInterface
*/
public function import($data): NodeInterface
{
Expand All @@ -36,21 +34,13 @@ public function import($data): NodeInterface
return $this->parseNode($this->createNode(['label' => 'root']), $data);
}

/**
* @param array $attributes
*
* @return AttributeNodeInterface
*/
private function createNode(array $attributes): AttributeNodeInterface
{
return new AttributeNode($attributes);
}

/**
* @param AttributeNodeInterface $parent
* @param Node ...$astNodes
*
* @return NodeInterface
*/
private function parseNode(AttributeNodeInterface $parent, Node ...$astNodes): NodeInterface
{
Expand Down
12 changes: 0 additions & 12 deletions src/Importer/NikicPhpParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,18 @@ final class NikicPhpParser implements ImporterInterface
* @param Node[] $data
*
* @throws Exception
*
* @return NodeInterface
*/
public function import($data): NodeInterface
{
return $this->parseNode($this->createNode(['label' => 'root']), ...$data);
}

/**
* @param array $attributes
*
* @return AttributeNodeInterface
*/
private function createNode(array $attributes): AttributeNodeInterface
{
return new AttributeNode($attributes);
}

/**
* @param \PhpParser\Node $astNode
*
* @return array<int, Node>
*/
private function getAllNodeChildren(Node $astNode): array
Expand Down Expand Up @@ -69,10 +60,7 @@ static function (string $subNodeName) use ($astNode): array {
}

/**
* @param AttributeNodeInterface $parent
* @param Node ...$astNodes
*
* @return NodeInterface
*/
private function parseNode(AttributeNodeInterface $parent, Node ...$astNodes): NodeInterface
{
Expand Down
3 changes: 0 additions & 3 deletions src/Importer/SimpleArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ private function createNode($data): AttributeNodeInterface
}

/**
* @param AttributeNodeInterface $parent
* @param array ...$nodes
*
* @return \loophp\phptree\Node\NodeInterface
*/
private function parseNode(AttributeNodeInterface $parent, array ...$nodes): NodeInterface
{
Expand Down
3 changes: 0 additions & 3 deletions src/Importer/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ static function (string $match): string {
}

/**
* @param AttributeNodeInterface $parent
* @param string ...$nodes
*
* @return \loophp\phptree\Node\NodeInterface
*/
private function parseNode(AttributeNodeInterface $parent, string ...$nodes): NodeInterface
{
Expand Down
8 changes: 1 addition & 7 deletions src/Modifier/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
use loophp\phptree\Traverser\PostOrder;
use loophp\phptree\Traverser\TraverserInterface;

/**
* Class Apply.
*/
class Apply implements ModifierInterface
{
/**
Expand All @@ -19,15 +16,12 @@ class Apply implements ModifierInterface
private $apply;

/**
* @var TraverserInterface|null
* @var TraverserInterface
*/
private $traverser;

/**
* Apply constructor.
*
* @param callable $apply
* @param TraverserInterface|null $traverser
*/
public function __construct(callable $apply, ?TraverserInterface $traverser = null)
{
Expand Down
3 changes: 0 additions & 3 deletions src/Modifier/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class Filter implements ModifierInterface

/**
* Filter constructor.
*
* @param callable $filter
* @param TraverserInterface|null $traverser
*/
public function __construct(callable $filter, ?TraverserInterface $traverser = null)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Modifier/FulfillCapacity.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class FulfillCapacity implements ModifierInterface

/**
* FulfillCapacity constructor.
*
* @param TraverserInterface|null $traverser
*/
public function __construct(?TraverserInterface $traverser = null)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Modifier/RemoveNullNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class RemoveNullNode implements ModifierInterface

/**
* RemoveNullNode constructor.
*
* @param TraverserInterface|null $traverser
*/
public function __construct(?TraverserInterface $traverser = null)
{
Expand Down
5 changes: 3 additions & 2 deletions src/Node/ABNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public function add(NodeInterface ...$nodes): NodeInterface

ksort($count);

$child = array_shift($count);
$child->add($node);
if (null !== $child = array_shift($count)) {
$child->add($node);
}
}

return $this;
Expand Down
10 changes: 2 additions & 8 deletions src/Node/AttributeNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,21 @@

use loophp\phptree\Traverser\TraverserInterface;

/**
* Class AttributeNode.
*/
class AttributeNode extends NaryNode implements AttributeNodeInterface
{
/**
* @var array
*/
private $attributes = [];
private $attributes;

/**
* ValueNode constructor.
*
* @param array<int|string, mixed> $attributes
* @param int|null $capacity
* @param TraverserInterface|null $traverser
* @param NodeInterface|null $parent
*/
public function __construct(
array $attributes = [],
?int $capacity = 0,
int $capacity = 0,
?TraverserInterface $traverser = null,
?NodeInterface $parent = null
) {
Expand Down
2 changes: 0 additions & 2 deletions src/Node/AttributeNodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ interface AttributeNodeInterface extends NaryNodeInterface
/**
* Get an attribute.
*
* @param string $key
*
* @return mixed
* The value of the attribute.
*/
Expand Down
5 changes: 1 addition & 4 deletions src/Node/KeyValueNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ class KeyValueNode extends ValueNode implements KeyValueNodeInterface
*
* @param mixed|null $key
* @param mixed|null $value
* @param int|null $capacity
* @param TraverserInterface|null $traverser
* @param NodeInterface|null $parent
*/
public function __construct(
$key,
$value,
?int $capacity = 0,
int $capacity = 0,
?TraverserInterface $traverser = null,
?NodeInterface $parent = null
) {
Expand Down
1 change: 0 additions & 1 deletion src/Node/MerkleNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class MerkleNode extends ValueNode implements MerkleNodeInterface
* MerkleNode constructor.
*
* @param mixed $value
* @param int $capacity
* @param HasherInterface $hasher
*/
public function __construct(
Expand Down
3 changes: 0 additions & 3 deletions src/Node/MerkleNodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
*/
interface MerkleNodeInterface extends ValueNodeInterface
{
/**
* @return string
*/
public function hash(): string;

/**
Expand Down

0 comments on commit 97996be

Please sign in to comment.