mirror of
https://github.com/dannyvankooten/AltoRouter.git
synced 2025-07-09 11:03:37 +02:00
adhere to (mostly) PSR12, check codestyle in CI
This commit is contained in:
5
.github/workflows/php.yml
vendored
5
.github/workflows/php.yml
vendored
@ -7,7 +7,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php-versions: [ '7.3', 'highest' ]
|
php-versions: [ '7.3', 'highest' ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -35,5 +35,8 @@ jobs:
|
|||||||
if: steps.composer-cache.outputs.cache-hit != 'true'
|
if: steps.composer-cache.outputs.cache-hit != 'true'
|
||||||
run: composer install --no-progress
|
run: composer install --no-progress
|
||||||
|
|
||||||
|
- name: Check codestyle
|
||||||
|
run: composer run-script check-codestyle
|
||||||
|
|
||||||
- name: Run test suite
|
- name: Run test suite
|
||||||
run: composer run-script test
|
run: composer run-script test
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
@ -13,7 +14,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|||||||
|
|
||||||
class AltoRouter
|
class AltoRouter
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array Array of all routes (incl. named routes).
|
* @var array Array of all routes (incl. named routes).
|
||||||
*/
|
*/
|
||||||
@ -202,7 +202,7 @@ class AltoRouter
|
|||||||
$requestUrl = substr($requestUrl, 0, $strpos);
|
$requestUrl = substr($requestUrl, 0, $strpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
$lastRequestUrlChar = $requestUrl ? $requestUrl[strlen($requestUrl)-1] : '';
|
$lastRequestUrlChar = $requestUrl ? $requestUrl[strlen($requestUrl) - 1] : '';
|
||||||
|
|
||||||
// set Request Method if it isn't passed as a parameter
|
// set Request Method if it isn't passed as a parameter
|
||||||
if ($requestMethod === null) {
|
if ($requestMethod === null) {
|
||||||
@ -232,7 +232,7 @@ class AltoRouter
|
|||||||
} else {
|
} else {
|
||||||
// Compare longest non-param string with url before moving on to regex
|
// Compare longest non-param string with url before moving on to regex
|
||||||
// Check if last character before param is a slash, because it could be optional if param is optional too (see https://github.com/dannyvankooten/AltoRouter/issues/241)
|
// Check if last character before param is a slash, because it could be optional if param is optional too (see https://github.com/dannyvankooten/AltoRouter/issues/241)
|
||||||
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position-1] !== '/')) {
|
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position - 1] !== '/')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,8 @@
|
|||||||
"classmap": ["AltoRouter.php"]
|
"classmap": ["AltoRouter.php"]
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vendor/bin/phpunit",
|
"test": "phpunit",
|
||||||
"check-syntax": "find . -name '*.php' -not -path './vendor/*' -print0 | xargs -0 -n1 php --define error_reporting=-1 -l"
|
"check-syntax": "find . -name '*.php' -not -path './vendor/*' -print0 | xargs -0 -n1 php --define error_reporting=-1 -l",
|
||||||
|
"check-codestyle": "phpcs -ns"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<ruleset name="rules">
|
<ruleset name="rules">
|
||||||
<description>rules</description>
|
<description>rules</description>
|
||||||
<rule ref="PSR2"/>
|
<rule ref="PSR12">
|
||||||
|
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
|
||||||
|
</rule>
|
||||||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|
||||||
<file>tests</file>
|
|
||||||
<file>AltoRouter.php</file>
|
<file>AltoRouter.php</file>
|
||||||
<file>examples/</file>
|
<file>examples/</file>
|
||||||
<arg name="colors"/>
|
<arg name="colors"/>
|
||||||
|
Reference in New Issue
Block a user