Skip to content
Open
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 @@ -57,6 +57,7 @@
"symfony/var-exporter": "^6.4 || ^7.4"
},
"require-dev": {
"boundwize/structarmed": "^0.18.0",
"dotkernel/dot-maker": "^2.0.0",
"filp/whoops": "^2.18.4",
"laminas/laminas-coding-standard": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/src/Adapter/AuthenticationAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function authenticate(): Result

/** @var non-empty-string[] $roles */
$roles = array_map(
fn (RoleInterface $role): string => (string) $role->getName()->value,
static fn (RoleInterface $role): string => (string) $role->getName()->value,
$identityClass->getRoles()
);

Expand Down
2 changes: 1 addition & 1 deletion src/Admin/src/Delegator/AdminRoleDelegator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __invoke(ContainerInterface $container, $name, callable $callbac
$adminForm = $callback();
if ($adminForm instanceof CreateAdminForm) {
$adminForm->setRoles(
array_map(fn (AdminRole $role): array => [
array_map(static fn (AdminRole $role): array => [
'label' => $role->getName()->value,
'value' => $role->getId()->toString(),
'selected' => false,
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/src/Handler/Admin/GetEditAdminFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$adminRoles = $this->adminRoleService->getAdminRoleRepository()->findAll();
$adminRoles = array_map(
/** @return SelectDataType */
fn (AdminRole $adminRole): array => [
static fn (AdminRole $adminRole): array => [
'label' => $adminRole->getName()->value,
'value' => $adminRole->getId()->toString(),
'selected' => $admin->hasRole($adminRole),
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/src/Handler/Admin/PostEditAdminHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$adminRoles = $this->adminRoleService->getAdminRoleRepository()->findAll();
$adminRoles = array_map(
/** @return SelectDataType */
fn (AdminRole $adminRole): array => [
static fn (AdminRole $adminRole): array => [
'label' => $adminRole->getName()->value,
'value' => $adminRole->getId()->toString(),
'selected' => $admin->hasRole($adminRole),
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Admin/src/Entity/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function getArrayCopy(): array
'firstName' => $this->firstName,
'lastName' => $this->lastName,
'status' => $this->status->value,
'roles' => array_map(fn (RoleInterface $role): array => $role->getArrayCopy(), $this->roles->toArray()),
'roles' => array_map(static fn (RoleInterface $role): array => $role->getArrayCopy(), $this->roles->toArray()),
'created' => $this->created,
'updated' => $this->updated,
];
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Admin/src/Enum/AdminStatusEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function values(): array
*/
public static function toArray(): array
{
return array_reduce(self::cases(), function (array $collector, self $enum): array {
return array_reduce(self::cases(), static function (array $collector, self $enum): array {
$collector[$enum->value] = $enum->name;

return $collector;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/App/src/DBAL/Types/AbstractEnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
return 'TEXT';
}

$values = array_map(fn($case) => "'$case->value'", $this->getEnumCases());
$values = array_map(static fn($case) => "'$case->value'", $this->getEnumCases());

return sprintf('ENUM(%s)', implode(', ', $values));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/User/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public function getArrayCopy(): array
'hash' => $this->hash,
'identity' => $this->identity,
'status' => $this->status->value,
'roles' => array_map(fn (RoleInterface $role): array => $role->getArrayCopy(), $this->roles->toArray()),
'roles' => array_map(static fn (RoleInterface $role): array => $role->getArrayCopy(), $this->roles->toArray()),
'created' => $this->created,
'updated' => $this->updated,
];
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/User/src/Enum/UserRoleEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum UserRoleEnum: string
*/
public static function validCases(): array
{
return array_filter(self::cases(), fn (self $value) => $value !== self::Guest);
return array_filter(self::cases(), static fn (self $value) => $value !== self::Guest);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Core/src/User/src/Enum/UserStatusEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public static function validValues(): array
*/
public static function validCases(): array
{
return array_filter(self::cases(), fn (self $enum) => $enum !== self::Deleted);
return array_filter(self::cases(), static fn (self $enum) => $enum !== self::Deleted);
}

/**
* @return array<string, non-empty-string>
*/
public static function toArray(): array
{
return array_reduce(self::validCases(), function (array $collector, self $enum): array {
return array_reduce(self::validCases(), static function (array $collector, self $enum): array {
$collector[$enum->value] = $enum->name;

return $collector;
Expand Down
4 changes: 2 additions & 2 deletions src/User/src/Delegator/UserRoleDelegator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public function __invoke(ContainerInterface $container, $name, callable $callbac
{
$userForm = $callback();
if ($userForm instanceof CreateUserForm) {
$userRoles = array_map(fn (UserRole $role): array => [
$userRoles = array_map(static fn (UserRole $role): array => [
'label' => $role->getName()->value,
'value' => $role->getId()->toString(),
'selected' => $role->getName() === self::DEFAULT_ROLE,
], $container->get(EntityManagerInterface::class)->getRepository(UserRole::class)->findAll());
$userRoles = array_filter($userRoles, fn (array $role) => $role['label'] !== UserRoleEnum::Guest->value);
$userRoles = array_filter($userRoles, static fn (array $role) => $role['label'] !== UserRoleEnum::Guest->value);

$userForm->setRoles($userRoles);
}
Expand Down
4 changes: 2 additions & 2 deletions src/User/src/Handler/GetEditUserFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$userRoles = $this->userRoleService->getUserRoleRepository()->findAll();
$userRoles = array_map(
/** @return SelectDataType */
fn (UserRole $userRole): array => [
static fn (UserRole $userRole): array => [
'label' => $userRole->getName()->value,
'value' => $userRole->getId()->toString(),
'selected' => $user->hasRole($userRole),
],
$userRoles
);
$userRoles = array_filter($userRoles, fn (array $role) => $role['label'] !== UserRoleEnum::Guest->value);
$userRoles = array_filter($userRoles, static fn (array $role) => $role['label'] !== UserRoleEnum::Guest->value);

$this->editUserAvatarForm
->setAttribute(
Expand Down
4 changes: 2 additions & 2 deletions src/User/src/Handler/PostEditUserAvatarHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$userRoles = $this->userRoleService->getUserRoleRepository()->findAll();
$userRoles = array_map(
/** @return SelectDataType */
fn (UserRole $userRole): array => [
static fn (UserRole $userRole): array => [
'label' => $userRole->getName()->value,
'value' => $userRole->getId()->toString(),
'selected' => $user->hasRole($userRole),
],
$userRoles
);
$userRoles = array_filter($userRoles, fn (array $role) => $role['label'] !== UserRoleEnum::Guest->value);
$userRoles = array_filter($userRoles, static fn (array $role) => $role['label'] !== UserRoleEnum::Guest->value);

$this->editUserAvatarForm
->setAttribute(
Expand Down
4 changes: 2 additions & 2 deletions src/User/src/Handler/PostEditUserHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$userRoles = $this->userRoleService->getUserRoleRepository()->findAll();
$userRoles = array_map(
/** @return SelectDataType */
fn (UserRole $userRole): array => [
static fn (UserRole $userRole): array => [
'label' => $userRole->getName()->value,
'value' => $userRole->getId()->toString(),
'selected' => $user->hasRole($userRole),
],
$userRoles
);
$userRoles = array_filter($userRoles, fn (array $role) => $role['label'] !== UserRoleEnum::Guest->value);
$userRoles = array_filter($userRoles, static fn (array $role) => $role['label'] !== UserRoleEnum::Guest->value);

$this->editUserAvatarForm
->setAttribute(
Expand Down
35 changes: 35 additions & 0 deletions structarmed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

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

return Architecture::define()
->withPresets(Preset::PSR4(), Preset::CODEQUALITY())
->layer('CoreApp', 'src/Core/src/App/src', 'src/Core/src/App/src/Fixture')
->layer('CoreFixture', 'src/Core/src/App/src/Fixture')
->layer('CoreSetting', 'src/Core/src/Setting/src')
->layer('CoreAdmin', 'src/Core/src/Admin/src')
->layer('CoreSecurity', 'src/Core/src/Security/src')
->layer('CoreUser', 'src/Core/src/User/src')
->layer('App', 'src/App/src')
->layer('Admin', 'src/Admin/src')
->layer('Dashboard', 'src/Dashboard/src')
->layer('Page', 'src/Page/src')
->layer('Setting', 'src/Setting/src')
->layer('User', 'src/User/src')
->ruleset([
'CoreApp' => ['CoreUser'],
'CoreSetting' => ['+CoreApp', 'CoreAdmin'],
'CoreAdmin' => ['+CoreSetting'],
'CoreSecurity' => ['+CoreAdmin'],
'CoreUser' => ['+CoreSecurity'],
'CoreFixture' => ['+CoreUser'],
'App' => ['+CoreUser'],
'Admin' => ['+App'],
'Dashboard' => ['+App'],
'Page' => ['+App'],
'Setting' => ['+Admin'],
'User' => ['+App'],
]);
4 changes: 2 additions & 2 deletions test/Unit/Admin/Delegator/AdminRoleDelegatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testInvokeWillSucceedWithoutAdminForm(): void
$delegator = (new AdminRoleDelegator())(
$container,
'',
fn () => new stdClass()
static fn () => new stdClass()
);

$this->assertIsObject($delegator);
Expand All @@ -53,7 +53,7 @@ public function testInvokeWillSucceedWithAdminForm(): void
$delegator = (new AdminRoleDelegator())(
$container,
'',
fn () => new CreateAdminForm()
static fn () => new CreateAdminForm()
);

$this->assertInstanceOf(CreateAdminForm::class, $delegator);
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/App/Plugin/FormsPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testWillRestoreState(): void
->expects($this->exactly(2))
->method('getData')
->willReturnCallback(
fn (string $key) => match ($key) {
static fn (string $key) => match ($key) {
'loginForm_data' => $oldData,
'loginForm_messages' => [],
default => null,
Expand Down