Skip to content

Commit 36cd9bb

Browse files
committed
!!!TASK: Remove old AST objects and adjust dependent classes/tests
1 parent 8af0e0e commit 36cd9bb

File tree

173 files changed

+2092
-4166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+2092
-4166
lines changed

scripts/test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@
1717
--display-deprecations \
1818
--display-errors \
1919
--display-notices \
20-
--testdox \
2120
--coverage-html build/coverage-report \
2221
--coverage-filter src $@

src/Definition/BinaryOperator.php

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/Definition/Precedence.php

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/Domain/ComponentName/ComponentName.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
namespace PackageFactory\ComponentEngine\Domain\ComponentName;
2424

25+
use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;
26+
2527
final class ComponentName
2628
{
2729
private function __construct(
@@ -33,4 +35,9 @@ public static function from(string $string): self
3335
{
3436
return new self($string);
3537
}
38+
39+
public function toTypeName(): TypeName
40+
{
41+
return TypeName::from($this->value);
42+
}
3643
}

src/Domain/EnumName/EnumName.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
namespace PackageFactory\ComponentEngine\Domain\EnumName;
2424

25+
use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;
26+
2527
final class EnumName
2628
{
2729
private function __construct(
@@ -33,4 +35,9 @@ public static function from(string $string): self
3335
{
3436
return new self($string);
3537
}
38+
39+
public function toTypeName(): TypeName
40+
{
41+
return TypeName::from($this->value);
42+
}
3643
}

src/Domain/PropertyName/PropertyName.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
namespace PackageFactory\ComponentEngine\Domain\PropertyName;
2424

25+
use PackageFactory\ComponentEngine\Domain\EnumMemberName\EnumMemberName;
26+
2527
final class PropertyName
2628
{
2729
private function __construct(
@@ -33,4 +35,9 @@ public static function from(string $string): self
3335
{
3436
return new self($string);
3537
}
38+
39+
public function toEnumMemberName(): EnumMemberName
40+
{
41+
return EnumMemberName::from($this->value);
42+
}
3643
}

src/Domain/StructName/StructName.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
namespace PackageFactory\ComponentEngine\Domain\StructName;
2424

25+
use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;
26+
2527
final class StructName
2628
{
2729
private function __construct(
@@ -33,4 +35,9 @@ public static function from(string $string): self
3335
{
3436
return new self($string);
3537
}
38+
39+
public function toTypeName(): TypeName
40+
{
41+
return TypeName::from($this->value);
42+
}
3643
}

src/Domain/TypeName/TypeName.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* PackageFactory.ComponentEngine - Universal View Components for PHP
5-
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
5+
* Copyright (C) 2023 Contributors of PackageFactory.ComponentEngine
66
*
77
* This program is free software: you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by
@@ -22,6 +22,8 @@
2222

2323
namespace PackageFactory\ComponentEngine\Domain\TypeName;
2424

25+
use PackageFactory\ComponentEngine\Domain\VariableName\VariableName;
26+
2527
final class TypeName
2628
{
2729
private function __construct(
@@ -33,4 +35,9 @@ public static function from(string $string): self
3335
{
3436
return new self($string);
3537
}
38+
39+
public function toVariableName(): VariableName
40+
{
41+
return VariableName::from($this->value);
42+
}
3643
}

src/Language/AST/Node/PropertyDeclaration/PropertyDeclarationNodes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ public function __construct(PropertyDeclarationNode ...$items)
3838

3939
$this->items = $itemsAsHashMap;
4040
}
41+
42+
public function isEmpty(): bool
43+
{
44+
return count($this->items) === 0;
45+
}
4146
}

src/Language/Parser/Expression/ExpressionParser.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use PackageFactory\ComponentEngine\Parser\Tokenizer\Token;
4646
use PackageFactory\ComponentEngine\Parser\Tokenizer\TokenType;
4747
use PackageFactory\ComponentEngine\Parser\Tokenizer\TokenTypes;
48+
use PhpParser\Parser\Tokens;
4849

4950
final class ExpressionParser
5051
{
@@ -69,23 +70,31 @@ public function __construct(
6970
*/
7071
public function parse(\Iterator &$tokens): ExpressionNode
7172
{
73+
Scanner::skipSpaceAndComments($tokens);
74+
7275
$result = $this->parseUnaryStatement($tokens);
7376

7477
if ($this->shouldStop($tokens)) {
7578
return $result;
7679
}
7780

78-
$result = match (Scanner::type($tokens)) {
81+
$binaryOperationTokens = TokenTypes::from(
7982
TokenType::OPERATOR_BOOLEAN_AND,
8083
TokenType::OPERATOR_BOOLEAN_OR,
8184
TokenType::COMPARATOR_EQUAL,
8285
TokenType::COMPARATOR_NOT_EQUAL,
8386
TokenType::COMPARATOR_GREATER_THAN,
8487
TokenType::COMPARATOR_GREATER_THAN_OR_EQUAL,
8588
TokenType::COMPARATOR_LESS_THAN,
86-
TokenType::COMPARATOR_LESS_THAN_OR_EQUAL => $this->parseBinaryOperation($tokens, $result),
87-
default => $result
88-
};
89+
TokenType::COMPARATOR_LESS_THAN_OR_EQUAL
90+
);
91+
92+
while (
93+
!$this->shouldStop($tokens) &&
94+
$binaryOperationTokens->contains(Scanner::type($tokens))
95+
) {
96+
$result = $this->parseBinaryOperation($tokens, $result);
97+
}
8998

9099
if ($this->shouldStop($tokens)) {
91100
return $result;

0 commit comments

Comments
 (0)