Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"php": "~8.3.0 || ~8.4.0 || ~8.5.0"
},
"require-dev": {
"boundwize/structarmed": "^0.19",
"laminas/laminas-coding-standard": "^3.1.0",
"mikey179/vfsstream": "^1.6.12",
"phpstan/phpstan": "^2.1.33",
Expand Down
6 changes: 3 additions & 3 deletions src/Component/ClassFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,22 +235,22 @@ public function render(): string
$class .= '{' . PHP_EOL;

if (count($this->traits) > 0) {
$traits = array_map(fn (string $trait): string => $trait, $this->traits);
$traits = array_map(static fn (string $trait): string => $trait, $this->traits);

$class .= ' ' . implode(PHP_EOL . ' ', $traits) . PHP_EOL . PHP_EOL;
}

if (count($this->properties) > 0) {
$properties = array_map(
fn (ParameterInterface $property): string => $property->render(4),
static fn (ParameterInterface $property): string => $property->render(4),
$this->properties
);

$class .= implode(PHP_EOL, $properties) . PHP_EOL . PHP_EOL;
}

if (count($this->methods) > 0) {
$methods = array_map(fn (MethodInterface $method): string => $method->render(), $this->methods);
$methods = array_map(static fn (MethodInterface $method): string => $method->render(), $this->methods);

$class .= ' ' . implode(PHP_EOL . PHP_EOL . ' ', $methods) . PHP_EOL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Declaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function renderParameters(): string
}

return implode(PHP_EOL, array_map(
fn (ParameterInterface $parameter): string => sprintf(' %s,', $parameter->render()),
static fn (ParameterInterface $parameter): string => sprintf(' %s,', $parameter->render()),
$this->parameters
));
}
Expand Down
3 changes: 2 additions & 1 deletion src/Component/Inject.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ private function renderWithNamedArguments(): string
private function renderWithPositionalArguments(int $spaces = 4): string
{
$arguments = array_map(
fn (string $argument): string => sprintf('%s%s%s,', PHP_EOL, str_repeat(' ', $spaces + 4), $argument),
static fn (string $argument): string =>
sprintf('%s%s%s,', PHP_EOL, str_repeat(' ', $spaces + 4), $argument),
$this->positionalArguments
);

Expand Down
2 changes: 1 addition & 1 deletion src/Component/InterfaceFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function render(): string

if (count($this->declarations) > 0) {
$declarations = array_map(
fn (Declaration $declaration): string => $declaration->render(),
static fn (Declaration $declaration): string => $declaration->render(),
$this->declarations
);

Expand Down
4 changes: 2 additions & 2 deletions src/Component/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function renderInjects(): string
return '';
}

$injects = array_map(fn (Inject $inject): string => $inject->render(), $this->injects);
$injects = array_map(static fn (Inject $inject): string => $inject->render(), $this->injects);

return implode(PHP_EOL, $injects);
}
Expand All @@ -199,7 +199,7 @@ public function renderParameters(int $spaces = 0): string
}

return implode(PHP_EOL, array_map(
fn (ParameterInterface $parameter): string => sprintf(
static fn (ParameterInterface $parameter): string => sprintf(
'%s%s,',
str_repeat(' ', $spaces),
$parameter->render()
Expand Down
51 changes: 51 additions & 0 deletions structarmed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

use Boundwize\StructArmed\Architecture;
use Boundwize\StructArmed\Preset\Preset;

return Architecture::define()
->withPresets(Preset::PSR4(), Preset::CODEQUALITY())

->layer('ColorEnum', 'src/ColorEnum.php')
->layer('VisibilityEnum', 'src/VisibilityEnum.php')
->layer('Context', 'src/Context.php')
->layer('Config', 'src/Config.php')
->layer('Message', 'src/Message.php')
->layer('Maker', 'src/Maker.php')
->layer('IO', 'src/IO/')
->layer('Exception', 'src/Exception/')
->layer('BaseComponent', ['src/Component.php', 'src/Component/'], 'src/Component/Method/')
->layer('MethodComponent', 'src/Component/Method/')
->layer('FileSystem', ['src/FileSystem.php', 'src/FileSystem/'])
->layer('CommonType', 'src/Type/', [
'src/Type/Form/',
'src/Type/Handler/',
'src/Type/Input/',
'src/Type/InputFilter/',
])
->layer('FormType', 'src/Type/Form/')
->layer('HandlerType', 'src/Type/Handler/', 'src/Type/Handler/Api/')
->layer('ApiHandlerType', 'src/Type/Handler/Api/')
->layer('InputType', 'src/Type/Input/')
->layer('InputFilterType', 'src/Type/InputFilter/')
->ruleset([
'ColorEnum' => [],
'VisibilityEnum' => [],
'Context' => [],
'IO' => ['ColorEnum'],
'Message' => ['ColorEnum', 'Context'],
'BaseComponent' => ['Context', 'VisibilityEnum', 'MethodComponent'],
'MethodComponent' => ['+BaseComponent'],
'Exception' => ['FileSystem'],
'FileSystem' => ['+BaseComponent', 'Exception'],
'FormType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'],
'HandlerType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'],
'ApiHandlerType' => ['+HandlerType'],
'InputType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'],
'InputFilterType' => ['CommonType', 'Config', '+FileSystem', '+IO', '+Message'],
'CommonType' => ['+FormType', '+ApiHandlerType', '+InputType', '+InputFilterType'],
'Maker' => ['+CommonType'],
'Config' => ['Maker'],
]);
2 changes: 1 addition & 1 deletion test/Component/ClassFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\ClassFile;
use Dot\Maker\Component\Inject;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/CoreImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\Import;
use Dot\Maker\Context;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/DeclarationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\Declaration;
use Dot\Maker\Component\Parameter;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\Import;
use Dot\Maker\Context;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/InjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\Inject;
use PHPUnit\Framework\TestCase;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/InterfaceFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\Declaration;
use Dot\Maker\Component\InterfaceFile;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/Method/ConstructorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component\Method;
namespace DotTest\Maker\Component\Method;

use Dot\Maker\Component\Inject;
use Dot\Maker\Component\Method\Constructor;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/Method/GetterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component\Method;
namespace DotTest\Maker\Component\Method;

use Dot\Maker\Component\Method\Getter;
use Dot\Maker\Component\Parameter;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/Method/SetterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component\Method;
namespace DotTest\Maker\Component\Method;

use Dot\Maker\Component\Method\Setter;
use Dot\Maker\Component\Parameter;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/MethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\Inject;
use Dot\Maker\Component\Method;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/ParameterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\Parameter;
use Dot\Maker\VisibilityEnum;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/PromotedPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\PromotedProperty;
use Dot\Maker\VisibilityEnum;
Expand Down
2 changes: 1 addition & 1 deletion test/Component/PropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Component;
namespace DotTest\Maker\Component;

use Dot\Maker\Component\Property;
use Dot\Maker\VisibilityEnum;
Expand Down
Loading