Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #261

Merged
merged 4 commits into from
Sep 19, 2023
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
.idea/

phpunit.xml
/.phpunit.result.cache
/*.cache
/.phpbench
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"php": ">=8.1.0"
},
"require-dev": {
"doctrine/coding-standard": "^12.0",
"lcobucci/coding-standard": "^11.0",
"phpbench/phpbench": "^1.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "^9.6"
"phpunit/phpunit": "^10.3"
},
"suggest": {
"ext-apcu": "To be able to use APCu cache driver"
Expand Down
802 changes: 366 additions & 436 deletions composer.lock

Large diffs are not rendered by default.

47 changes: 1 addition & 46 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,7 @@
<file>src</file>
<file>test</file>

<rule ref="Doctrine">
<rule ref="Lcobucci">
<exclude name="Generic.Formatting.MultipleStatementAlignment" />
</rule>

<rule ref="SlevomatCodingStandard.Commenting.RequireOneLineDocComment"/>
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedParameter"/>

<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="declareOnFirstLine" value="false" />
<property name="linesCountBeforeDeclare" value="0" />
<property name="spacesCountAroundEqualsSign" value="0" />
<property name="linesCountAfterDeclare" value="1" />
</properties>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>

<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="@internal, @deprecated"/>
<element value="@link, @see"/>
<element value="@test, @group, @dataProvider, @depends, @doesNotPerformAssertions, @runInSeparateProcess, @runTestsInSeparateProcesses, @before, @beforeClass, @after, @afterClass, @testWith"/>
<element value="@testdox"/>
<element value="@requires"/>
<element value="@covers, @coversNothing, @coversDefaultClass"/>
<element value="@uses"/>
<element value="@Given, @Then, @When, @Transform, @BeforeSuite, @AfterSuite, @BeforeFeature, @AfterFeature, @BeforeScenario, @AfterScenario, @BeforeStep, @AfterStep"/>
<element value="@ORM\,@ODM\"/>
<element value="@ParamProviders"/>
<element value="@template"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
</ruleset>
14 changes: 11 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
verbose="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutTodoAnnotatedTests="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
executionOrder="random"
cacheDirectory=".phpunit.cache"
>
<testsuites>
<testsuite name="FastRoute Tests">
<directory>./test/</directory>
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory>./src/</directory>
</include>
</coverage>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Cache/FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function get(string $key, callable $loader): array
}

/** @return array{0: array<string, array<string, mixed>>, 1: array<string, array<array{regex: string, suffix?: string, routeMap: array<int|string, array{0: mixed, 1: array<string, string>}>}>>}|null */
private static function readFileContents(string $path): array|null
private static function readFileContents(string $path): ?array
{
// error suppression is faster than calling `file_exists()` + `is_file()` + `is_readable()`, especially because there's no need to error here
set_error_handler(self::$emptyErrorHandler);
Expand Down
2 changes: 1 addition & 1 deletion src/Dispatcher/CharCountBased.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CharCountBased extends RegexBasedAbstract
{
/** @inheritDoc */
protected function dispatchVariableRoute(array $routeData, string $uri): array|null
protected function dispatchVariableRoute(array $routeData, string $uri): ?array
{
foreach ($routeData as $data) {
if (! preg_match($data['regex'], $uri . $data['suffix'], $matches)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Dispatcher/GroupCountBased.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class GroupCountBased extends RegexBasedAbstract
{
/** @inheritDoc */
protected function dispatchVariableRoute(array $routeData, string $uri): array|null
protected function dispatchVariableRoute(array $routeData, string $uri): ?array
{
foreach ($routeData as $data) {
if (! preg_match($data['regex'], $uri, $matches)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Dispatcher/GroupPosBased.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class GroupPosBased extends RegexBasedAbstract
{
/** @inheritDoc */
protected function dispatchVariableRoute(array $routeData, string $uri): array|null
protected function dispatchVariableRoute(array $routeData, string $uri): ?array
{
foreach ($routeData as $data) {
if (! preg_match($data['regex'], $uri, $matches)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Dispatcher/MarkBased.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class MarkBased extends RegexBasedAbstract
{
/** @inheritDoc */
protected function dispatchVariableRoute(array $routeData, string $uri): array|null
protected function dispatchVariableRoute(array $routeData, string $uri): ?array
{
foreach ($routeData as $data) {
if (! preg_match($data['regex'], $uri, $matches)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Dispatcher/RegexBasedAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(array $data)
*
* @return array{0: int, 1?: list<string>|mixed, 2?: array<string, string>}|null
*/
abstract protected function dispatchVariableRoute(array $routeData, string $uri): array|null;
abstract protected function dispatchVariableRoute(array $routeData, string $uri): ?array;

/** @inheritDoc */
public function dispatch(string $httpMethod, string $uri): array
Expand Down
14 changes: 9 additions & 5 deletions src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@

class Route
{
/** @param array<string, string> $variables */
public function __construct(
public string $httpMethod,
public mixed $handler,
public string $regex,
public array $variables,
) {
}

/** @param array<string|array{0: string, 1:string}> $routeData */
public static function fromParsedRoute(string $httpMethod, array $routeData, mixed $handler): self
{
Expand Down Expand Up @@ -47,11 +56,6 @@ private static function extractRegex(array $routeData): array
return [$regex, $variables];
}

/** @param array<string, string> $variables */
public function __construct(public string $httpMethod, public mixed $handler, public string $regex, public array $variables)
{
}

/**
* Tests whether this route matches the given string.
*/
Expand Down
11 changes: 6 additions & 5 deletions test/Dispatcher/CachingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use FastRoute\Dispatcher;
use FastRoute\RouteCollector;
use PHPUnit\Framework\Attributes as PHPUnit;
use PHPUnit\Framework\TestCase;

use function FastRoute\cachedDispatcher;
Expand All @@ -14,13 +15,13 @@ final class CachingTest extends TestCase
{
private const CACHE_FILE = __DIR__ . '/routing_cache.php';

/** @after */
#[PHPUnit\After]
public function cleanUpCache(): void
{
unlink(self::CACHE_FILE);
}

/** @before */
#[PHPUnit\Before]
public function warmUpCache(): void
{
$this->createDispatcher();
Expand All @@ -37,7 +38,7 @@ static function (RouteCollector $collector): void {
);
}

/** @test */
#[PHPUnit\Test]
public function dynamicRouteShouldMatch(): void
{
$dispatcher = $this->createDispatcher();
Expand All @@ -48,7 +49,7 @@ public function dynamicRouteShouldMatch(): void
self::assertSame(['page' => '1234'], $result[2]);
}

/** @test */
#[PHPUnit\Test]
public function staticRouteShouldMatch(): void
{
$dispatcher = $this->createDispatcher();
Expand All @@ -58,7 +59,7 @@ public function staticRouteShouldMatch(): void
self::assertSame(['test'], $result[1]);
}

/** @test */
#[PHPUnit\Test]
public function missingRoutShouldNotBeFound(): void
{
$dispatcher = $this->createDispatcher();
Expand Down
2 changes: 1 addition & 1 deletion test/Dispatcher/CharCountBasedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use FastRoute\DataGenerator;
use FastRoute\Dispatcher;

class CharCountBasedTest extends DispatcherTest
class CharCountBasedTest extends DispatcherTestCase
{
protected function getDispatcherClass(): string
{
Expand Down
Loading
Loading