Skip to content

Commit

Permalink
Merge pull request #31 from PackageFactory/task/30/split-parsing-logic
Browse files Browse the repository at this point in the history
TASK: Split parsing logic from AST objects
  • Loading branch information
grebaldi authored Sep 27, 2023
2 parents ef85ca5 + 5b3f7ca commit 86aa961
Show file tree
Hide file tree
Showing 329 changed files with 17,414 additions and 8,750 deletions.
4 changes: 3 additions & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

./vendor/bin/phpunit \
--enforce-time-limit \
--testdox \
--display-deprecations \
--display-errors \
--display-notices \
--coverage-html build/coverage-report \
--coverage-filter src $@
72 changes: 0 additions & 72 deletions src/Definition/BinaryOperator.php

This file was deleted.

41 changes: 41 additions & 0 deletions src/Domain/AttributeName/AttributeName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2023 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\AttributeName;

final class AttributeName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}
}
48 changes: 48 additions & 0 deletions src/Domain/ComponentName/ComponentName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\ComponentName;

use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;

final class ComponentName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}

public function toTypeName(): TypeName
{
return TypeName::from($this->value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,22 @@

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Definition;
namespace PackageFactory\ComponentEngine\Domain\EnumMemberName;

use PackageFactory\ComponentEngine\Parser\Tokenizer\TokenType;

enum IntegerFormat: string
final class EnumMemberName
{
case BINARY = 'BINARY';
case OCTAL = 'OCTAL';
case DECIMAL = 'DECIMAL';
case HEXADECIMAL = 'HEXADECIMAL';
/**
* @var array<string,self>
*/
private static array $instances = [];

public static function fromTokenType(TokenType $tokenType): self
{
return match ($tokenType) {
TokenType::NUMBER_BINARY => self::BINARY,
TokenType::NUMBER_OCTAL => self::OCTAL,
TokenType::NUMBER_DECIMAL => self::DECIMAL,
TokenType::NUMBER_HEXADECIMAL => self::HEXADECIMAL,
private function __construct(
public readonly string $value
) {
}

default => throw new \Exception('@TODO: Unknown Integer Format: ' . $tokenType->value)
};
public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}
}
48 changes: 48 additions & 0 deletions src/Domain/EnumName/EnumName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\EnumName;

use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;

final class EnumName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}

public function toTypeName(): TypeName
{
return TypeName::from($this->value);
}
}
48 changes: 48 additions & 0 deletions src/Domain/PropertyName/PropertyName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2023 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\PropertyName;

use PackageFactory\ComponentEngine\Domain\EnumMemberName\EnumMemberName;

final class PropertyName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}

public function toEnumMemberName(): EnumMemberName
{
return EnumMemberName::from($this->value);
}
}
48 changes: 48 additions & 0 deletions src/Domain/StructName/StructName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\StructName;

use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;

final class StructName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}

public function toTypeName(): TypeName
{
return TypeName::from($this->value);
}
}
Loading

0 comments on commit 86aa961

Please sign in to comment.