Skip to content

Commit 5efc19a

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

File tree

173 files changed

+2082
-4167
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

+2082
-4167
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: 11 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
{
@@ -75,17 +76,23 @@ public function parse(\Iterator &$tokens): ExpressionNode
7576
return $result;
7677
}
7778

78-
$result = match (Scanner::type($tokens)) {
79+
$binaryOperationTokens = TokenTypes::from(
7980
TokenType::OPERATOR_BOOLEAN_AND,
8081
TokenType::OPERATOR_BOOLEAN_OR,
8182
TokenType::COMPARATOR_EQUAL,
8283
TokenType::COMPARATOR_NOT_EQUAL,
8384
TokenType::COMPARATOR_GREATER_THAN,
8485
TokenType::COMPARATOR_GREATER_THAN_OR_EQUAL,
8586
TokenType::COMPARATOR_LESS_THAN,
86-
TokenType::COMPARATOR_LESS_THAN_OR_EQUAL => $this->parseBinaryOperation($tokens, $result),
87-
default => $result
88-
};
87+
TokenType::COMPARATOR_LESS_THAN_OR_EQUAL
88+
);
89+
90+
while (
91+
!$this->shouldStop($tokens) &&
92+
$binaryOperationTokens->contains(Scanner::type($tokens))
93+
) {
94+
$result = $this->parseBinaryOperation($tokens, $result);
95+
}
8996

9097
if ($this->shouldStop($tokens)) {
9198
return $result;

0 commit comments

Comments
 (0)