Compare commits

..

62 commits

Author SHA1 Message Date
Continuous Integration
23d37db8f6 Continuous Integration Fixes
Some checks are pending
/ ls (push) Waiting to run
2023-11-30 20:39:40 +00:00
28491fd4ea fix arrayFilter helper function
All checks were successful
/ ls (push) Successful in 24s
2023-11-30 21:14:17 +01:00
4910317c38 updatecontainer
All checks were successful
/ ls (push) Successful in 27s
2023-11-29 19:34:36 +01:00
f23b073377 update deps
All checks were successful
/ ls (push) Successful in 24s
2023-11-29 19:24:08 +01:00
Continuous Integration
70d16b7659 Continuous Integration Fixes 2023-11-27 20:53:47 +00:00
911c0ff4b5 lol
All checks were successful
/ ls (push) Successful in 25s
2023-11-27 21:53:24 +01:00
2872d932b6 test
Some checks failed
/ ls (push) Failing after 11s
2023-11-27 21:44:24 +01:00
Continuous Integration
45b5b746f6 Continuous Integration Fixes 2023-11-08 17:11:03 +00:00
0733c8456d also
All checks were successful
/ ls (push) Successful in 22s
2023-11-08 17:22:36 +01:00
Continuous Integration
5ccbc66134 Continuous Integration Fixes 2023-10-20 18:04:11 +00:00
lubiana
03952677f6
add php styler
Some checks failed
/ ls (push) Failing after 24s
2023-10-20 20:03:44 +02:00
lubiana
ea7d5eff68
test
All checks were successful
/ ls (push) Successful in 23s
2023-10-20 19:57:46 +02:00
lubiana
14db5b36e6
test
Some checks failed
/ ls (push) Failing after 20s
2023-10-20 19:10:05 +02:00
lubiana
b638a0124f
test
All checks were successful
/ ls (push) Successful in 21s
2023-10-20 19:08:44 +02:00
lubiana
a7f60358eb
test
All checks were successful
/ ls (push) Successful in 21s
2023-10-20 18:31:00 +02:00
lubiana
4ca96eafb9
test
All checks were successful
/ ls (push) Successful in 21s
2023-10-20 18:30:16 +02:00
lubiana
8d8306ef42
test
Some checks failed
/ ls (push) Failing after 20s
2023-10-20 18:29:10 +02:00
lubiana
1bbde50fc3
test
All checks were successful
/ ls (push) Successful in 21s
2023-10-20 18:24:43 +02:00
lubiana
919d84173e
test
Some checks failed
/ ls (push) Failing after 20s
2023-10-20 18:20:08 +02:00
lubiana
ea854064b3
test
All checks were successful
/ ls (push) Successful in 22s
2023-10-20 18:15:38 +02:00
lubiana
36ea1f111f
test
All checks were successful
/ ls (push) Successful in 21s
2023-10-18 17:59:57 +02:00
lubiana
b665352669
test
All checks were successful
/ ls (push) Successful in 22s
2023-10-18 17:53:01 +02:00
lubiana
4e8953ba46
test
Some checks failed
/ ls (push) Failing after 16s
2023-10-17 20:57:28 +02:00
lubiana
e7c1df5eb1
test
Some checks failed
/ ls (push) Failing after 17s
2023-10-17 20:54:50 +02:00
lubiana
90ce46d9d1
test
All checks were successful
/ ls (push) Successful in 22s
2023-10-17 20:46:41 +02:00
lubiana
c769aa5fe4
test
All checks were successful
/ ls (push) Successful in 23s
2023-10-17 20:43:29 +02:00
lubiana
cf25187eef
test
All checks were successful
/ ls (push) Successful in 20s
2023-10-16 22:16:28 +02:00
lubiana
0b7f70541f
test
All checks were successful
/ ls (push) Successful in 19s
2023-10-16 22:14:40 +02:00
lubiana
b43ce75c42
test
All checks were successful
/ ls (push) Successful in 19s
2023-10-16 22:12:39 +02:00
lubiana
912dddb6fb
test
All checks were successful
/ ls (push) Successful in 18s
2023-10-16 22:12:06 +02:00
lubiana
c4acc2c358
test
Some checks failed
/ ls (push) Failing after 19s
2023-10-16 22:11:05 +02:00
lubiana
b85c91b3d0
test
Some checks failed
/ ls (push) Failing after 18s
2023-10-16 22:07:41 +02:00
lubiana
32eba79853
test
Some checks failed
/ ls (push) Failing after 18s
2023-10-16 22:01:09 +02:00
Continuous Integration
2eeb093f8e Continuous Integration Build Artifacts 2023-10-16 19:59:40 +00:00
lubiana
9228c09d60
test
All checks were successful
/ ls (push) Successful in 19s
2023-10-16 21:59:20 +02:00
lubiana
ff7e416c57
test
All checks were successful
/ ls (push) Successful in 18s
2023-10-16 21:55:59 +02:00
lubiana
66c8dc14ce
test
All checks were successful
/ ls (push) Successful in 14s
2023-10-16 21:51:55 +02:00
lubiana
766b4c2d87
test
Some checks failed
/ ls (push) Failing after 6s
2023-10-16 21:50:30 +02:00
lubiana
2a4660a732
test 2023-10-16 21:49:56 +02:00
lubiana
f5f216e0e8
test
Some checks failed
/ ls (push) Failing after 11s
2023-10-16 21:26:50 +02:00
lubiana
f1453b0c2f
test
Some checks failed
/ ls (push) Failing after 18s
2023-10-16 20:48:23 +02:00
lubiana
f1796b2ea1
test
Some checks failed
/ ls (push) Failing after 18s
2023-10-16 20:46:39 +02:00
lubiana
0ecf1160d5
test
Some checks failed
/ ls (push) Failing after 16s
2023-10-16 20:34:37 +02:00
lubiana
d2fe65734e
test
Some checks failed
/ ls (push) Failing after 13s
2023-10-16 20:33:37 +02:00
lubiana
56cf5fec2e
test
Some checks failed
/ ls (push) Failing after 10s
2023-10-16 20:26:48 +02:00
lubiana
668dd79d07
test
Some checks failed
/ ls (push) Failing after 9s
2023-10-16 20:25:50 +02:00
lubiana
fc554efd13
test 2023-10-16 20:23:35 +02:00
lubiana
3e6e8c70b8
test
All checks were successful
/ ls (push) Successful in 6s
2023-10-16 20:16:48 +02:00
lubiana
c4ae79cd69
test
All checks were successful
/ ls (push) Successful in 3s
2023-10-16 20:08:28 +02:00
lubiana
dbb98b1eac
test
All checks were successful
/ ls (push) Successful in 9s
2023-10-16 19:50:10 +02:00
lubiana
a06f01d598
test
All checks were successful
/ ls (push) Successful in 3s
2023-10-16 19:38:06 +02:00
lubiana
f21b18d8ac
test
All checks were successful
/ ls (push) Successful in 6s
2023-10-16 19:36:06 +02:00
lubiana
0687c75d0a
test
All checks were successful
/ ls (push) Successful in 9s
2023-10-16 19:35:29 +02:00
lubiana
1e97d89a5a
test
Some checks failed
/ build (push) Failing after 5s
2023-10-16 19:18:51 +02:00
lubiana
c86dad5c6c
test
Some checks failed
/ build (push) Failing after 10s
2023-10-16 19:17:32 +02:00
lubiana
2679849cc4
test
Some checks failed
/ build (push) Failing after 5s
2023-10-16 19:16:13 +02:00
lubiana
fcaf69c2ad
test
Some checks failed
/ build (push) Failing after 5s
2023-10-16 19:15:01 +02:00
lubiana
63dc61769d
test
Some checks failed
/ composer (push) Failing after 5s
2023-10-16 19:08:34 +02:00
lubiana
d03ecc5b93
test
Some checks failed
/ checkout (push) Successful in 8s
/ composer (push) Failing after 3s
2023-10-16 19:05:29 +02:00
lubiana
d98ff5b363
test
Some checks failed
/ checkout (push) Successful in 8s
/ composer (push) Failing after 8s
2023-10-16 19:04:40 +02:00
lubiana
bb77a21fb8
test
Some checks failed
/ checkout (push) Successful in 8s
/ composer (push) Failing after 1s
2023-10-16 19:03:17 +02:00
lubiana
e7ab312d84
1: add forge push action file
All checks were successful
/ ls (push) Successful in 9s
2023-10-16 18:43:01 +02:00
25 changed files with 1422 additions and 1436 deletions

View file

@ -0,0 +1,32 @@
on: [push]
jobs:
ls:
runs-on: docker
container:
image: git.php.fail/lubiana/container/php:8.3.0-node-20231212
steps:
- uses: actions/checkout@v3
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: restore-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-cache
- run: composer install
- run: composer fix
- name: GIT commit and push all changed files
env:
CI_COMMIT_MESSAGE: Continuous Integration Fixes
CI_COMMIT_AUTHOR: Continuous Integration
run: |
if [[ -n "$(git status -s)" ]]; then
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "gitbot@users.noreply.php.fail"
git commit -am "${{ env.CI_COMMIT_MESSAGE }}"
git push
fi

View file

@ -15,20 +15,20 @@
} }
], ],
"require": { "require": {
"php": ">=8.2", "php": ">=8.3",
"ext-apcu": "*", "ext-apcu": "*",
"php-di/php-di": "^7.0.1", "php-di/php-di": "^7.0.6",
"nikic/fast-route": "^1.3", "nikic/fast-route": "^1.3",
"symfony/http-foundation": "^6.2.5", "symfony/http-foundation": "^7.0"
"vimeo/psalm": "^5.6"
}, },
"require-dev": { "require-dev": {
"phpstan/phpstan": "^1.9.14", "phpstan/phpstan": "^1.10.46",
"lubiana/code-quality": "^1.1.5", "lubiana/code-quality": "^1.2",
"phpstan/extension-installer": "^1.2", "phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan-strict-rules": "^1.4.5", "phpstan/phpstan-strict-rules": "^1.5.2",
"thecodingmachine/phpstan-strict-rules": "^1.0", "thecodingmachine/phpstan-strict-rules": "^1.0",
"pmjones/php-styler": "0.x-dev" "pmjones/php-styler": "^0.14.0",
"vimeo/psalm": "^5.16"
}, },
"config": { "config": {
"allow-plugins": { "allow-plugins": {
@ -51,7 +51,7 @@
], ],
"style": "./vendor/bin/ecs", "style": "./vendor/bin/ecs",
"fix": [ "fix": [
"rector process" ,"ecs --fix", "ecs --fix" "rector process", "php-styler apply" ,"ecs --fix", "ecs --fix"
], ],
"rector": "./vendor/bin/rector process" "rector": "./vendor/bin/rector process"
}, },

2691
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@ use PhpStyler\Files;
use PhpStyler\Styler; use PhpStyler\Styler;
return new Config( return new Config(
files: new Files(__DIR__ . '/src'),
styler: new Styler(), styler: new Styler(),
files: new Files(__DIR__ . '/src'),
cache: __DIR__ . '/.php-styler.cache', cache: __DIR__ . '/.php-styler.cache',
); );

View file

@ -1,13 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.6.0@e784128902dfe01d489c4123d69918a9f3c1eac5"> <files psalm-version="5.16.0@2897ba636551a8cb61601cc26f6ccfbba6c36591">
<file src="src/Infrastructure/Finder.php"> <file src="src/Infrastructure/Finder.php">
<UnresolvableInclude> <UnresolvableInclude>
<code>require_once (string) $file</code> <code>require_once (string) $file</code>
</UnresolvableInclude> </UnresolvableInclude>
</file> </file>
<file src="src/Infrastructure/functions.php">
<MixedArgumentTypeCoercion>
<code>$callable</code>
</MixedArgumentTypeCoercion>
</file>
</files> </files>

View file

@ -6,7 +6,7 @@ use DI\ContainerBuilder;
use Lubian\AttributeMagic\Infrastructure\Event\Dispatcher; use Lubian\AttributeMagic\Infrastructure\Event\Dispatcher;
use Lubian\AttributeMagic\Infrastructure\Event\DispatcherFactory; use Lubian\AttributeMagic\Infrastructure\Event\DispatcherFactory;
use Lubian\AttributeMagic\Infrastructure\Finder; use Lubian\AttributeMagic\Infrastructure\Finder;
use Lubian\AttributeMagic\Infrastructure\WebApp\Request\RequestEvent; use Lubian\AttributeMagic\Infrastructure\HttpKernel;
use Lubian\AttributeMagic\Infrastructure\WebApp\Route\HandlerResolver; use Lubian\AttributeMagic\Infrastructure\WebApp\Route\HandlerResolver;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -14,18 +14,17 @@ use function assert;
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../vendor/autoload.php';
$cached = false; $cached = false;
$container = (new ContainerBuilder)->addDefinitions( $container = (new ContainerBuilder())->addDefinitions(
[ [
Finder::class => static fn (): Finder => new Finder(__DIR__, [], $cached), Finder::class => static fn(): Finder => new Finder(__DIR__, [], $cached),
Dispatcher::class => static fn (DispatcherFactory $f): Dispatcher Dispatcher::class => static fn(DispatcherFactory $f): Dispatcher
=> $f->getDispatcher($cached), => $f->getDispatcher($cached),
HandlerResolver::class => static fn (Dispatcher $d): HandlerResolver HandlerResolver::class => static fn(Dispatcher $d): HandlerResolver
=> new HandlerResolver($d, $cached), => new HandlerResolver($d, $cached),
], ],
)->build(); )->build();
$dispatcher = $container->get(Dispatcher::class); $kernel = $container->get(HttpKernel::class);
assert($dispatcher instanceof Dispatcher); assert($kernel instanceof HttpKernel);
$request = new RequestEvent(Request::createFromGlobals()); $response = $kernel->handle(Request::createFromGlobals());
$dispatcher->dispatch($request); $response->send();
$request->response?->send();
exit(); exit();

View file

@ -9,6 +9,11 @@ use Symfony\Component\HttpFoundation\Response;
final class HalloDimi final class HalloDimi
{ {
/**
* Returns a JSON response with the message "Hallo Dimi".
*
* @return Response The JSON response.
*/
#[AsHandler(HttpMethod::GET, '/dimi')] #[AsHandler(HttpMethod::GET, '/dimi')]
public function hallo(): Response public function hallo(): Response
{ {

View file

@ -11,8 +11,7 @@ final readonly class Lol
{ {
public function __construct( public function __construct(
private Dispatcher $dispatcher private Dispatcher $dispatcher
) { ) {}
}
#[AsHandler(HttpMethod::GET, '/')] #[AsHandler(HttpMethod::GET, '/')]
public function lol(): void public function lol(): void

View file

@ -14,6 +14,5 @@ final readonly class AsListener
public function __construct( public function __construct(
public string $eventClass, public string $eventClass,
public int $priority = 0 public int $priority = 0
) { ) {}
}
} }

View file

@ -15,8 +15,7 @@ final class Dispatcher
public function __construct( public function __construct(
private readonly InvokerInterface $invoker, private readonly InvokerInterface $invoker,
private array $listeners = [], private array $listeners = [],
) { ) {}
}
public function addListener(Listener $listener): void public function addListener(Listener $listener): void
{ {
@ -30,7 +29,7 @@ final class Dispatcher
{ {
return arrayFilter( return arrayFilter(
$this->listeners, $this->listeners,
static fn (Listener $l): bool => $l->eventClass === $event::class, static fn(Listener $l): bool => $l->eventClass === $event::class,
); );
} }
@ -42,7 +41,7 @@ final class Dispatcher
$filtered = $this->getListenerForEvent($event); $filtered = $this->getListenerForEvent($event);
usort( usort(
$filtered, $filtered,
static fn (Listener $a, Listener $b): int => $a->priority <=> $b->priority, static fn(Listener $a, Listener $b): int => $a->priority <=> $b->priority,
); );
return $filtered; return $filtered;
} }

View file

@ -18,8 +18,7 @@ final readonly class DispatcherFactory
public function __construct( public function __construct(
private Finder $finder, private Finder $finder,
private InvokerInterface $invoker, private InvokerInterface $invoker,
) { ) {}
}
public function getDispatcher(bool $cached = false): Dispatcher public function getDispatcher(bool $cached = false): Dispatcher
{ {

View file

@ -15,6 +15,5 @@ final readonly class Listener
public int $priority, public int $priority,
public string $listenerClass, public string $listenerClass,
public string $listenerMethod, public string $listenerMethod,
) { ) {}
}
} }

View file

@ -34,8 +34,7 @@ final class Finder
private readonly string $path, private readonly string $path,
private array $classNames = [], private array $classNames = [],
private readonly bool $cached = false, private readonly bool $cached = false,
) { ) {}
}
/** /**
* @return Listener[] * @return Listener[]
@ -44,7 +43,7 @@ final class Finder
{ {
$this->populateClassnames(); $this->populateClassnames();
return array_map( return array_map(
static fn (array $h): Listener static fn(array $h): Listener
=> new Listener($h[0]->eventClass, $h[0]->priority, $h[1], $h[2]), => new Listener($h[0]->eventClass, $h[0]->priority, $h[1], $h[2]),
iterator_to_array($this->getAttributes(AsListener::class)), iterator_to_array($this->getAttributes(AsListener::class)),
); );
@ -57,7 +56,7 @@ final class Finder
{ {
$this->populateClassnames(); $this->populateClassnames();
return array_map( return array_map(
static fn (array $h): Handler static fn(array $h): Handler
=> new Handler($h[0]->method, $h[0]->path, $h[1], $h[2]), => new Handler($h[0]->method, $h[0]->path, $h[1], $h[2]),
iterator_to_array($this->getAttributes(AsHandler::class)), iterator_to_array($this->getAttributes(AsHandler::class)),
); );
@ -72,6 +71,7 @@ final class Finder
if ($this->cached === true && file_exists(self::CACHE_FILE)) { if ($this->cached === true && file_exists(self::CACHE_FILE)) {
$data = file_get_contents(self::CACHE_FILE); $data = file_get_contents(self::CACHE_FILE);
/** test */
if ($data === false) { if ($data === false) {
return; return;
} }

View file

@ -0,0 +1,23 @@
<?php declare(strict_types=1);
namespace Lubian\AttributeMagic\Infrastructure;
use Exception;
use Lubian\AttributeMagic\Infrastructure\Event\Dispatcher;
use Lubian\AttributeMagic\Infrastructure\WebApp\Request\RequestEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class HttpKernel
{
public function __construct(
private readonly Dispatcher $dispatcher
) {}
public function handle(Request $request): Response
{
$requestEvent = new RequestEvent($request);
$this->dispatcher->dispatch($requestEvent);
return $requestEvent->response ?? throw new Exception('errror');
}
}

View file

@ -13,6 +13,5 @@ final readonly class AsHandler
public function __construct( public function __construct(
public HttpMethod $method, public HttpMethod $method,
public string $path public string $path
) { ) {}
}
} }

View file

@ -13,6 +13,5 @@ final readonly class Handler
public string $path, public string $path,
public string $handlerClass, public string $handlerClass,
public string $handlerMethod, public string $handlerMethod,
) { ) {}
}
} }

View file

@ -13,6 +13,5 @@ final class RequestEvent extends GenericEvent
public Request $request, public Request $request,
public Response|null $response = null, public Response|null $response = null,
public Handler|null $handler = null, public Handler|null $handler = null,
) { ) {}
}
} }

View file

@ -9,8 +9,7 @@ final readonly class AttributeRouteCollector
{ {
public function __construct( public function __construct(
private Finder $finder private Finder $finder
) { ) {}
}
#[AsListener(CollectRoutes::class)] #[AsListener(CollectRoutes::class)]
public function collect(CollectRoutes $event): void public function collect(CollectRoutes $event): void

View file

@ -32,7 +32,6 @@ final class CachedResponse
/** @var Response|null $response */ /** @var Response|null $response */
$response = unserialize($serialized); $response = unserialize($serialized);
$event->response = $response; $event->response = $response;
$event->stopped = true; $event->stopped = true;
} }

View file

@ -29,7 +29,6 @@ final class CachedRouteCollector
/** @var Handler[] $routes */ /** @var Handler[] $routes */
$routes = unserialize(file_get_contents(self::ROUTES_DIR)); $routes = unserialize(file_get_contents(self::ROUTES_DIR));
$event->routes = $routes; $event->routes = $routes;
$event->stopped = true; $event->stopped = true;
} }

View file

@ -14,6 +14,5 @@ final class CollectRoutes extends GenericEvent
public function __construct( public function __construct(
public readonly bool $cached = false public readonly bool $cached = false
) { ) {}
}
} }

View file

@ -14,8 +14,7 @@ final readonly class HandlerCaller
{ {
public function __construct( public function __construct(
private InvokerInterface $invoker private InvokerInterface $invoker
) { ) {}
}
#[AsListener(RequestEvent::class, -50)] #[AsListener(RequestEvent::class, -50)]
public function callHandler(RequestEvent $event): void public function callHandler(RequestEvent $event): void

View file

@ -21,8 +21,7 @@ final readonly class HandlerResolver
public function __construct( public function __construct(
private Dispatcher $dispatcher, private Dispatcher $dispatcher,
private bool $cached = false, private bool $cached = false,
) { ) {}
}
#[AsListener(RequestEvent::class, -90)] #[AsListener(RequestEvent::class, -90)]
public function resolveHandler(RequestEvent $event): void public function resolveHandler(RequestEvent $event): void

View file

@ -7,9 +7,9 @@ use function array_values;
/** /**
* @template T * @template T
* @param array<T> $input * @param T[] $input
* @param callable(mixed, mixed=):scalar $callable * @param callable(T):bool $callable
* @return array<int, T> * @return T[]
*/ */
function arrayFilter(array $input, callable $callable): array function arrayFilter(array $input, callable $callable): array
{ {

View file

@ -8,6 +8,5 @@ final class LauschEvent extends GenericEvent
{ {
public function __construct( public function __construct(
public string $message public string $message
) { ) {}
}
} }