Skip to content
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
27 changes: 24 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
steps:
-
name: Checkout code
Expand All @@ -21,11 +19,34 @@ jobs:
name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
php-version: 8.5
-
name: Install dependencies
run: composer install --no-progress --prefer-dist --no-interaction

-
name: Run checks
run: composer check

tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
dependency-version: [prefer-lowest, prefer-stable]
steps:
-
name: Checkout code
uses: actions/checkout@v6
-
name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
-
name: Update dependencies
run: composer update --no-progress --${{ matrix.dependency-version }} --prefer-dist --no-interaction
-
name: Run tests
run: composer check:tests
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PHP_CodeSniffer\Sniffs\Sniff;
use function in_array;
use function ltrim;
use function strpos;
use function str_contains;
use const T_DOUBLE_ARROW;
use const T_FN_ARROW;
use const T_MATCH_ARROW;
Expand All @@ -22,7 +22,7 @@ final class DoubleArrowSpacingSniff implements Sniff
*/
public function process(
File $phpcsFile,
$pointer
$pointer,
): void
{
$tokens = $phpcsFile->getTokens();
Expand Down Expand Up @@ -52,15 +52,15 @@ public function process(
if (!$beforeValid) {
if ($before['code'] !== T_WHITESPACE) {
$phpcsFile->fixer->addContentBefore($pointer, ' ');
} elseif (strpos($before['content'], "\n") === false) {
} elseif (!str_contains($before['content'], "\n")) {
$phpcsFile->fixer->replaceToken($pointer - 1, ' ');
}
}

if (!$afterValid) {
if ($after['code'] !== T_WHITESPACE) {
$phpcsFile->fixer->addContent($pointer, ' ');
} elseif (strpos($after['content'], "\n") === false) {
} elseif (!str_contains($after['content'], "\n")) {
$phpcsFile->fixer->replaceToken($pointer + 1, ' ');
} else {
// whitespace runs into a newline: drop the trailing spaces, keep the line break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function register(): array
*/
public function process(
File $phpcsFile,
$pointer
$pointer,
): void
{
$tokens = $phpcsFile->getTokens();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function register(): array
*/
public function process(
File $phpcsFile,
$catchPointer
$catchPointer,
): void
{
$tokens = $phpcsFile->getTokens();
Expand Down Expand Up @@ -196,7 +196,7 @@ public function process(
private function addOrReplaceWhitespaceToken(
File $phpcsFile,
int $pointer,
string $whitespaceContent
string $whitespaceContent,
): void
{
$tokens = $phpcsFile->getTokens();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function register(): array
*/
public function process(
File $phpcsFile,
$pointer
$pointer,
): void
{
$tokens = $phpcsFile->getTokens();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class MultilineConditionSpacingSniff implements Sniff
*/
public function process(
File $phpcsFile,
$pointer
$pointer,
): void
{
$tokens = $phpcsFile->getTokens();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class MultilineTernarySniff implements Sniff
*/
public function process(
File $phpcsFile,
$pointer
$pointer,
): void
{
$tokens = $phpcsFile->getTokens();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class OpenParenthesisSpacingSniff implements Sniff
*/
public function process(
File $phpcsFile,
$pointer
$pointer,
): void
{
$tokens = $phpcsFile->getTokens();
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"type": "phpcodesniffer-standard",
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"ext-tokenizer": "*",
"slevomat/coding-standard": "^8.28.0",
"squizlabs/php_codesniffer": "^4.0.1"
Expand All @@ -16,7 +16,7 @@
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^10.5.62",
"shipmonk/composer-dependency-analyser": "^1.8",
"shipmonk/dead-code-detector": "^0.12",
"shipmonk/name-collision-detector": "^2.1",
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
>
<arg name="basepath" value="."/>
<arg name="cache" value="cache/phpcs.cache"/>
<config name="php_version" value="70400"/>
<config name="php_version" value="80100"/>

<file>ShipMonkCodingStandard/</file>
<file>tests/</file>
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ includes:

parameters:
phpVersion:
min: 70400
max: 80499
min: 80100
max: 80599
internalErrorsCountLimit: 1
featureToggles:
internalTag: false # sniffs consume SlevomatCodingStandard @internal helpers, the intended way to build sniffs
Expand Down
9 changes: 4 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
bootstrap="vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
cacheResultFile="cache/phpunit.result.cache"
beStrictAboutCoverageMetadata="true"
failOnAllIssues="true"
displayDetailsOnAllIssues="true"
cacheDirectory="cache/phpunit"
>
<testsuites>
<testsuite name="tests">
Expand Down
10 changes: 5 additions & 5 deletions tests/DocCommentSpacingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use function exec;
use function implode;
use function preg_match;
use function strpos;
use function str_contains;
use const PHP_EOL;

class DocCommentSpacingTest extends TestCase
Expand Down Expand Up @@ -59,13 +59,13 @@ private static function runPhpcs(string $filePath): array
*/
private static function assertNoSniffErrors(
string $sniffPrefix,
array $phpcsOutput
array $phpcsOutput,
): void
{
$relevantErrors = [];

foreach ($phpcsOutput as $line) {
if (strpos($line, $sniffPrefix) !== false) {
if (str_contains($line, $sniffPrefix)) {
$relevantErrors[] = $line;
}
}
Expand All @@ -83,7 +83,7 @@ private static function assertNoSniffErrors(
private static function assertSniffErrorOnLine(
string $sniffCode,
array $phpcsOutput,
int $expectedLine
int $expectedLine,
): void
{
$currentLine = 0;
Expand All @@ -94,7 +94,7 @@ private static function assertSniffErrorOnLine(
$currentLine = (int) $matches[1];
}

if (strpos($outputLine, $sniffCode) !== false && $currentLine === $expectedLine) {
if (str_contains($outputLine, $sniffCode) && $currentLine === $expectedLine) {
$found = true;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/SniffTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected static function checkFile(string $filePath): File

protected static function assertErrorCount(
File $file,
int $expectedErrorCount
int $expectedErrorCount,
): void
{
self::assertSame($expectedErrorCount, $file->getErrorCount());
Expand Down