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

Version 10 #207

Merged
merged 5 commits into from
Mar 11, 2024
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
17 changes: 6 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.1'
coverage: 'none'
- name: Cache dependencies
uses: actions/cache@v3
Expand Down Expand Up @@ -52,8 +52,11 @@ jobs:
- ""
include:
- os: windows-latest
php_version: 8.0
php_version: 8.1
dependencies_level: --prefer-lowest
- os: windows-latest
php_version: 8.1
dependencies_level: ''
runs-on: ${{ matrix.os }}
steps:
- name: Set git to use LF on windows
Expand All @@ -76,22 +79,14 @@ jobs:
key: "cache-composer-${{ hashFiles('composer.json') }}"
restore-keys: 'cache-composer-'
- name: Run composer
if: ${{ matrix.php_version != '8.0' && matrix.php_version != '8.1' && matrix.php_version != '8.2' && matrix.php_version != '8.3' }}
run: composer update ${{ matrix.dependencies_level }} --prefer-dist --no-interaction --no-progress
- name: Run composer with workaround for PHP 8 and incompatible PHPUnit
if: ${{ matrix.php_version == '8.0' || matrix.php_version == '8.1' || matrix.php_version == '8.2' || matrix.php_version == '8.3' }}
run: composer update ${{ matrix.dependencies_level }} --ignore-platform-reqs --prefer-dist --no-interaction --no-progress
- name: Check composer.json
run: composer normalize --dry-run
- name: Run tests with coverage
if: ${{ matrix.php_version != '8.0' && matrix.php_version != '8.1' && matrix.php_version != '8.2' && matrix.php_version != '8.3' }}
if: ${{ matrix.os != 'windows-latest' && matrix.php_version == '8.1' && matrix.dependencies_level != '--prefer-lowest' }}
run: php vendor/bin/phpunit --coverage-clover=coverage.xml
- name: Run tests
if: ${{ matrix.php_version == '8.0' }}
run: vendor/bin/phpunit
- name: Run tests
if: ${{ matrix.php_version == '8.1' }}
run: vendor/bin/phpunit --no-configuration --bootstrap=tests/bootstrap.php --dont-report-useless-tests vendor/squizlabs/php_codesniffer/tests/Standards/AllSniffs.php
- name: Run integration tests
run: vendor/bin/phpcs -s --standard=MO4 integrationtests/testfile.php
- name: Run PHPStan
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ composer.lock
/build/
.atoum.php
phpunit.xml
.phpunit.result.cache
behat.yml

# OSX
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# language: php
build:
environment:
php: 7.4.14
php: 8.1
tests:
override:
- phpcs-run --standard=phpcs.xml.dist
Expand Down
24 changes: 24 additions & 0 deletions MO4/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@
<!-- Require exactly one blank line after trait use -->
<rule ref="PSR12.Traits.UseDeclaration"/>

<!-- Forbid whitespace between array access operator and the variable or between array access operators. -->
<rule ref="SlevomatCodingStandard.Arrays.ArrayAccess"/>
<!-- Sort attributes alphabetically -->
<rule ref="SlevomatCodingStandard.Attributes.AttributesOrder">
<properties>
<property name="orderAlphabetically" value="true"/>
</properties>
</rule>
<!-- Disallow multiple attributes inside one #[] -->
<rule ref="SlevomatCodingStandard.Attributes.DisallowAttributesJoining"/>
<!-- Require only one attribute per line -->
<rule ref="SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine"/>

<!-- Force Enum Spacing-->
<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
<!-- Require presence of constant visibility -->
Expand All @@ -101,6 +114,15 @@
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Forbid empty lines around Enum cases -->
<rule ref="SlevomatCodingStandard.Classes.EnumCaseSpacing">
<properties>
<property name="minLinesCountBeforeWithComment" value="0"/>
<property name="maxLinesCountBeforeWithComment" value="0"/>
<property name="minLinesCountBeforeWithoutComment" value="0"/>
<property name="maxLinesCountBeforeWithoutComment" value="0"/>
</properties>
</rule>
<!-- Forbid properties to be public -->
<rule ref="SlevomatCodingStandard.Classes.ForbiddenPublicProperty">
<properties>
Expand Down Expand Up @@ -144,6 +166,8 @@
<property name="ignoreMultiLine" value="true"/>
</properties>
</rule>
<!-- Enforce consistent spacing of named arguments -->
<rule ref="SlevomatCodingStandard.Functions.NamedArgumentSpacing"/>
<!-- Require static closures for microoptimization -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused function parameters -->
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
},
"require": {
"php": "~7.2 || ~8.0",
"dealerdirect/phpcodesniffer-composer-installer": "~0.7",
"dealerdirect/phpcodesniffer-composer-installer": "~0.7 || ~1.0",
"escapestudios/symfony2-coding-standard": "^3.10.0",
"slevomat/coding-standard": "^8.4",
"squizlabs/php_codesniffer": "^3.6.2"
"slevomat/coding-standard": "^8.14",
"squizlabs/php_codesniffer": "^3.8.0"
},
"require-dev": {
"ergebnis/composer-normalize": ">=2.19 <2.30",
"phan/phan": "^5.4.2",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.5.20 || ^8.5.36 || ^9.6.15",
"psalm/plugin-phpunit": "^0.18",
"vimeo/psalm": "^4.30"
},
Expand Down
7 changes: 5 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@

declare(strict_types=1);

use PHP_CodeSniffer\Config;
use PHP_CodeSniffer\Util\Standards;

$myStandardName = 'MO4';

require_once __DIR__.'/../vendor/squizlabs/php_codesniffer/tests/bootstrap.php';

// Add this Standard.
PHP_CodeSniffer\Config::setConfigData(
Config::setConfigData(
'installed_paths',
__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$myStandardName,
true
);

// Ignore all other Standards in tests.
$standards = PHP_CodeSniffer\Util\Standards::getInstalledStandards();
$standards = Standards::getInstalledStandards();
$standards[] = 'Generic';

$ignoredStandardsStr = implode(
Expand Down