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 @@ -83,6 +83,7 @@
"zircote/swagger-php": "^6.0.0"
},
"require-dev": {
"boundwize/structarmed": "^0.17.12",
"dotkernel/dot-maker": "^2.0.0",
"laminas/laminas-coding-standard": "^3.0.1",
"laminas/laminas-development-mode": "^3.13.0",
Expand Down
2 changes: 1 addition & 1 deletion src/App/src/Factory/ProblemDetailsDelegatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __invoke(
$errorHandler = $container->get(ErrorHandlerInterface::class);
assert($errorHandler instanceof LogErrorHandler);

$listener = function (Throwable $throwable, RequestInterface $request) use ($errorHandler) {
$listener = static function (Throwable $throwable, RequestInterface $request) use ($errorHandler) {
assert($request instanceof ServerRequestInterface);
$errorHandler->handleThrowable($throwable, $request);
};
Expand Down
2 changes: 1 addition & 1 deletion src/App/src/Factory/UserIdentityFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UserIdentityFactory
{
public function __invoke(ContainerInterface $container): callable
{
return function (string $identity, array $roles = [], array $details = []): UserInterface {
return static function (string $identity, array $roles = [], array $details = []): UserInterface {
/** @var non-empty-string $identity */
return new UserIdentity($identity, $roles, $details);
};
Expand Down
2 changes: 1 addition & 1 deletion src/App/src/Middleware/AuthorizationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
}

$defaultUser->setRoles(
array_map(fn (RoleInterface $role): string => (string) $role->getName()->value, $user->getRoles())
array_map(static fn (RoleInterface $role): string => (string) $role->getName()->value, $user->getRoles())
);

$request = $request->withAttribute(UserInterface::class, $defaultUser);
Expand Down
2 changes: 1 addition & 1 deletion src/App/src/Middleware/ContentNegotiationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private function parseAcceptHeader(string $header): array
}

// Sort by quality in descending order
usort($types, fn ($a, $b) => $b['quality'] <=> $a['quality']);
usort($types, static fn ($a, $b) => $b['quality'] <=> $a['quality']);

return $types;
}
Expand Down
3 changes: 2 additions & 1 deletion src/App/src/Middleware/DeprecationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ private function getAttribute(array $attributes): ?array
return array_values(
array_filter(
$attributes,
fn (array $attribute): bool => $attribute['deprecationType'] === self::RESOURCE_DEPRECATION_ATTRIBUTE
static fn (array $attribute): bool
=> $attribute['deprecationType'] === self::RESOURCE_DEPRECATION_ATTRIBUTE
)
)[0] ?? null;
}
Expand Down
5 changes: 4 additions & 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,10 @@ 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
5 changes: 4 additions & 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,10 @@ 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
31 changes: 31 additions & 0 deletions structarmed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

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

return Architecture::define()
->withPresets(Preset::PSR4(), Preset::CODEQUALITY())
->layerPattern('CoreApp', '/^Core\\\\App\\\\.*$/', '/^Core\\\\App\\\\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('Security', 'src/Security/src')
->layer('Admin', 'src/Admin/src')
->layer('User', 'src/User/src')
->ruleset([
'CoreApp' => ['CoreUser'],
'CoreSetting' => ['+CoreApp', 'CoreAdmin'],
'CoreAdmin' => ['+CoreSetting'],
'CoreSecurity' => ['+CoreAdmin'],
'CoreUser' => ['+CoreSecurity'],
'CoreFixture' => ['+CoreUser'],
'App' => ['+CoreUser'],
'Security' => ['+App'],
'Admin' => ['+App'],
'User' => ['+App'],
]);
2 changes: 1 addition & 1 deletion test/Unit/App/Template/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Template;
namespace ApiTest\Unit\App\Template;

use Api\App\Template\Parser;
use Api\App\Template\ParserInterface;
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/App/Template/RendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace App\Template;
namespace ApiTest\Unit\App\Template;

use Api\App\Exception\RuntimeException;
use Api\App\Template\Parser;
Expand Down
Loading