Skip to content

Commit 86aa961

Browse files
authored
Merge pull request #31 from PackageFactory/task/30/split-parsing-logic
TASK: Split parsing logic from AST objects
2 parents ef85ca5 + 5b3f7ca commit 86aa961

File tree

329 files changed

+17414
-8750
lines changed

Some content is hidden

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

329 files changed

+17414
-8750
lines changed

scripts/test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
./vendor/bin/phpunit \
1616
--enforce-time-limit \
17-
--testdox \
17+
--display-deprecations \
18+
--display-errors \
19+
--display-notices \
1820
--coverage-html build/coverage-report \
1921
--coverage-filter src $@

src/Definition/BinaryOperator.php

Lines changed: 0 additions & 72 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/**
4+
* PackageFactory.ComponentEngine - Universal View Components for PHP
5+
* Copyright (C) 2023 Contributors of PackageFactory.ComponentEngine
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
declare(strict_types=1);
22+
23+
namespace PackageFactory\ComponentEngine\Domain\AttributeName;
24+
25+
final class AttributeName
26+
{
27+
/**
28+
* @var array<string,self>
29+
*/
30+
private static array $instances = [];
31+
32+
private function __construct(
33+
public readonly string $value
34+
) {
35+
}
36+
37+
public static function from(string $string): self
38+
{
39+
return self::$instances[$string] ??= new self($string);
40+
}
41+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* PackageFactory.ComponentEngine - Universal View Components for PHP
5+
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
declare(strict_types=1);
22+
23+
namespace PackageFactory\ComponentEngine\Domain\ComponentName;
24+
25+
use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;
26+
27+
final class ComponentName
28+
{
29+
/**
30+
* @var array<string,self>
31+
*/
32+
private static array $instances = [];
33+
34+
private function __construct(
35+
public readonly string $value
36+
) {
37+
}
38+
39+
public static function from(string $string): self
40+
{
41+
return self::$instances[$string] ??= new self($string);
42+
}
43+
44+
public function toTypeName(): TypeName
45+
{
46+
return TypeName::from($this->value);
47+
}
48+
}

src/Definition/IntegerFormat.php renamed to src/Domain/EnumMemberName/EnumMemberName.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,22 @@
2020

2121
declare(strict_types=1);
2222

23-
namespace PackageFactory\ComponentEngine\Definition;
23+
namespace PackageFactory\ComponentEngine\Domain\EnumMemberName;
2424

25-
use PackageFactory\ComponentEngine\Parser\Tokenizer\TokenType;
26-
27-
enum IntegerFormat: string
25+
final class EnumMemberName
2826
{
29-
case BINARY = 'BINARY';
30-
case OCTAL = 'OCTAL';
31-
case DECIMAL = 'DECIMAL';
32-
case HEXADECIMAL = 'HEXADECIMAL';
27+
/**
28+
* @var array<string,self>
29+
*/
30+
private static array $instances = [];
3331

34-
public static function fromTokenType(TokenType $tokenType): self
35-
{
36-
return match ($tokenType) {
37-
TokenType::NUMBER_BINARY => self::BINARY,
38-
TokenType::NUMBER_OCTAL => self::OCTAL,
39-
TokenType::NUMBER_DECIMAL => self::DECIMAL,
40-
TokenType::NUMBER_HEXADECIMAL => self::HEXADECIMAL,
32+
private function __construct(
33+
public readonly string $value
34+
) {
35+
}
4136

42-
default => throw new \Exception('@TODO: Unknown Integer Format: ' . $tokenType->value)
43-
};
37+
public static function from(string $string): self
38+
{
39+
return self::$instances[$string] ??= new self($string);
4440
}
4541
}

src/Domain/EnumName/EnumName.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* PackageFactory.ComponentEngine - Universal View Components for PHP
5+
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
declare(strict_types=1);
22+
23+
namespace PackageFactory\ComponentEngine\Domain\EnumName;
24+
25+
use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;
26+
27+
final class EnumName
28+
{
29+
/**
30+
* @var array<string,self>
31+
*/
32+
private static array $instances = [];
33+
34+
private function __construct(
35+
public readonly string $value
36+
) {
37+
}
38+
39+
public static function from(string $string): self
40+
{
41+
return self::$instances[$string] ??= new self($string);
42+
}
43+
44+
public function toTypeName(): TypeName
45+
{
46+
return TypeName::from($this->value);
47+
}
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* PackageFactory.ComponentEngine - Universal View Components for PHP
5+
* Copyright (C) 2023 Contributors of PackageFactory.ComponentEngine
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
declare(strict_types=1);
22+
23+
namespace PackageFactory\ComponentEngine\Domain\PropertyName;
24+
25+
use PackageFactory\ComponentEngine\Domain\EnumMemberName\EnumMemberName;
26+
27+
final class PropertyName
28+
{
29+
/**
30+
* @var array<string,self>
31+
*/
32+
private static array $instances = [];
33+
34+
private function __construct(
35+
public readonly string $value
36+
) {
37+
}
38+
39+
public static function from(string $string): self
40+
{
41+
return self::$instances[$string] ??= new self($string);
42+
}
43+
44+
public function toEnumMemberName(): EnumMemberName
45+
{
46+
return EnumMemberName::from($this->value);
47+
}
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* PackageFactory.ComponentEngine - Universal View Components for PHP
5+
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
declare(strict_types=1);
22+
23+
namespace PackageFactory\ComponentEngine\Domain\StructName;
24+
25+
use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;
26+
27+
final class StructName
28+
{
29+
/**
30+
* @var array<string,self>
31+
*/
32+
private static array $instances = [];
33+
34+
private function __construct(
35+
public readonly string $value
36+
) {
37+
}
38+
39+
public static function from(string $string): self
40+
{
41+
return self::$instances[$string] ??= new self($string);
42+
}
43+
44+
public function toTypeName(): TypeName
45+
{
46+
return TypeName::from($this->value);
47+
}
48+
}

0 commit comments

Comments
 (0)