mirror of
https://github.com/dannyvankooten/AltoRouter.git
synced 2025-07-07 10:03:39 +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
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: [ '7.3', 'highest' ]
|
||||
php-versions: [ '7.3', 'highest' ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -35,5 +35,8 @@ jobs:
|
||||
if: steps.composer-cache.outputs.cache-hit != 'true'
|
||||
run: composer install --no-progress
|
||||
|
||||
- name: Check codestyle
|
||||
run: composer run-script check-codestyle
|
||||
|
||||
- name: Run test suite
|
||||
run: composer run-script test
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
MIT License
|
||||
|
||||
@ -13,7 +14,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
|
||||
class AltoRouter
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array Array of all routes (incl. named routes).
|
||||
*/
|
||||
@ -202,7 +202,7 @@ class AltoRouter
|
||||
$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
|
||||
if ($requestMethod === null) {
|
||||
@ -232,7 +232,7 @@ class AltoRouter
|
||||
} else {
|
||||
// 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)
|
||||
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position-1] !== '/')) {
|
||||
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position - 1] !== '/')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,8 @@
|
||||
"classmap": ["AltoRouter.php"]
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vendor/bin/phpunit",
|
||||
"check-syntax": "find . -name '*.php' -not -path './vendor/*' -print0 | xargs -0 -n1 php --define error_reporting=-1 -l"
|
||||
"test": "phpunit",
|
||||
"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"?>
|
||||
<ruleset name="rules">
|
||||
<description>rules</description>
|
||||
<rule ref="PSR2"/>
|
||||
<rule ref="PSR12">
|
||||
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
|
||||
</rule>
|
||||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|
||||
<file>tests</file>
|
||||
<file>AltoRouter.php</file>
|
||||
<file>examples/</file>
|
||||
<arg name="colors"/>
|
||||
|
Reference in New Issue
Block a user