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 @@ -32,6 +32,7 @@
"psr/http-server-middleware": "^1.0.2"
},
"require-dev": {
"boundwize/structarmed": "^0.18.10",
"laminas/laminas-coding-standard": "^3.1.0",
"mikey179/vfsstream": "^1.6.12",
"phpstan/phpstan": "^2.2.5",
Expand Down
4 changes: 2 additions & 2 deletions src/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ErrorHandler implements ErrorHandlerInterface
*/
public function __construct(callable $responseFactory, ?callable $responseGenerator = null)
{
$this->responseFactory = function () use ($responseFactory): ResponseInterface {
$this->responseFactory = static function () use ($responseFactory): ResponseInterface {
return $responseFactory();
};
$this->responseGenerator = $responseGenerator ?: new ErrorResponseGenerator();
Expand Down Expand Up @@ -89,7 +89,7 @@ public function createErrorHandler(): callable
/**
* @throws ErrorException if error is not within the error_reporting mask.
*/
return function (int $errno, string $errstr, string $errfile, int $errline): void {
return static function (int $errno, string $errstr, string $errfile, int $errline): void {
if (! (error_reporting() & $errno)) {
// error_reporting does not include this error
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Extra/Processor/RequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function process(array $data): array
} else {
$matches = array_filter(
$sensitiveParameters,
fn (string $sensitiveParameter) => str_contains(strtolower($key), $sensitiveParameter)
static fn (string $sensitiveParameter) => str_contains(strtolower($key), $sensitiveParameter)
);

if (! isset($this->sensitiveParameters[ProcessorInterface::ALL]) && count($matches) === 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/Extra/Processor/ServerProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function process(array $data): array

private function stringToAssociativeArray(string $subject): array
{
return array_reduce(explode('; ', $subject), function (array $result, string $keyValue): array {
return array_reduce(explode('; ', $subject), static function (array $result, string $keyValue): array {
$keyValue = explode('=', $keyValue, 2);
$result[$keyValue[0]] = $keyValue[1] ?? '';

Expand All @@ -60,7 +60,7 @@ private function stringToAssociativeArray(string $subject): array
private function associativeArrayToString(array $subject): string
{
$subject = array_map(
fn(string $key, string $value) => sprintf('%s=%s', $key, $value),
static fn(string $key, string $value) => sprintf('%s=%s', $key, $value),
array_keys($subject),
$subject
);
Expand Down
2 changes: 1 addition & 1 deletion src/Extra/Processor/SessionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SessionProcessor extends AbstractProcessor
public function process(array $data): array
{
return array_map(
fn (iterable $container): array => ArrayUtils::iteratorToArray($container),
static fn (iterable $container): array => ArrayUtils::iteratorToArray($container),
$data
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Extra/Processor/TraceProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function process(array $data): array
/**
* @param string[] $trace
*/
fn (array $trace): string => sprintf(
static fn (array $trace): string => sprintf(
'%s%s%s:%d',
$trace['class'] ?? $trace['file'] ?? 'unknown',
$trace['type'] ?? '->',
Expand Down
4 changes: 2 additions & 2 deletions src/LogErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
?LoggerInterface $logger = null,
?ExtraProvider $extraProvider = null,
) {
$this->responseFactory = function () use ($responseFactory): ResponseInterface {
$this->responseFactory = static function () use ($responseFactory): ResponseInterface {
return $responseFactory();
};
$this->responseGenerator = $responseGenerator ?: new ErrorResponseGenerator();
Expand Down Expand Up @@ -109,7 +109,7 @@ public function createErrorHandler(): callable
/**
* @throws ErrorException if error is not within the error_reporting mask.
*/
return function (int $errno, string $errstr, string $errfile, int $errline): void {
return static function (int $errno, string $errstr, string $errfile, int $errline): void {
if (! (error_reporting() & $errno)) {
// error_reporting does not include this error
return;
Expand Down
25 changes: 25 additions & 0 deletions structarmed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

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

return Architecture::define()
->withPresets(Preset::PSR4(), Preset::CODEQUALITY())
->layer('ReplacementStrategy', 'src/Extra/ReplacementStrategy.php')
->layer('Processor', 'src/Extra/Processor')
->layer('Provider', 'src/Extra/Provider')
->layer('Extra', 'src/Extra', [
'src/Extra/ReplacementStrategy.php',
'src/Extra/Processor',
'src/Extra/Provider',
])
->layer('ErrorHandler', 'src', 'src/Extra')
->ruleset([
'ReplacementStrategy' => [],
'Processor' => ['ReplacementStrategy'],
'Provider' => ['+Processor'],
'Extra' => ['+Provider'],
'ErrorHandler' => ['+Extra'],
]);
Loading