Skip to content

Commit 520341b

Browse files
authored
Merge pull request #110 from alma-oss/feature/remove-skip-of-blank-line-rule
Feat: Remove skip of BlankLineAfterOpeningTagFixer
2 parents c072555 + e5ab266 commit 520341b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+789
-129
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<!-- There is always Unreleased section on the top. Subsections (Added, Changed, Fixed, Removed) should be added as needed. -->
66

77
## Unreleased
8+
- Remove skip of BlankLineAfterOpeningTagFixer to be PSR-12 compliant.
89

910
## 4.2.0 - 2025-02-28
1011
- Rename the package from "Alma Career Czechia Standard for PHP" to more broad "Alma Career Coding Standard for PHP". 🎉

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ composer require --dev almacareer/coding-standard
4646
1. Create `ecs.php` file in the root directory of your project and import the code-style rules:
4747

4848
```php
49-
<?php declare(strict_types=1);
49+
<?php
50+
51+
declare(strict_types=1);
5052

5153
use Lmc\CodingStandard\Set\SetList;
5254
use Symplify\EasyCodingStandard\Config\ECSConfig;
@@ -92,7 +94,9 @@ If needed, you can also override any default settings.
9294
Below find examples of some more opinionated checks you may want to add depending on your needs:
9395

9496
```php
95-
<?php declare(strict_types=1);
97+
<?php
98+
99+
declare(strict_types=1);
96100

97101
use Lmc\CodingStandard\Set\SetList;
98102
use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff;
@@ -133,7 +137,9 @@ See [EasyCodingStandard docs][ecs-docs] for more configuration options.
133137
You can configure your `ecs.php` file to entirely skip some files, disable specific checks, or suppress specific errors.
134138

135139
```php
136-
<?php declare(strict_types=1);
140+
<?php
141+
142+
declare(strict_types=1);
137143

138144
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
139145
use PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayDeclarationSniff;

composer.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,28 @@
1111
],
1212
"require": {
1313
"php": "^8.0",
14-
"friendsofphp/php-cs-fixer": "^3.66.0",
14+
"friendsofphp/php-cs-fixer": "^3.66",
1515
"slevomat/coding-standard": "^8.6",
1616
"squizlabs/php_codesniffer": "^3.9",
1717
"symplify/easy-coding-standard": "^12.2.0 <12.4 || ^12.5.5"
1818
},
1919
"require-dev": {
20-
"ergebnis/composer-normalize": "^2.42.0",
21-
"nikic/php-parser": "<5.0",
22-
"php-parallel-lint/php-parallel-lint": "^1.4.0",
20+
"ergebnis/composer-normalize": "^2.42",
21+
"nikic/php-parser": "^4.19",
22+
"php-parallel-lint/php-parallel-lint": "^1.4",
2323
"phpstan/extension-installer": "^1.3.1",
2424
"phpstan/phpstan": "^1.11.1",
25-
"phpstan/phpstan-phpunit": "^1.4.0",
25+
"phpstan/phpstan-phpunit": "^1.4",
2626
"phpunit/phpunit": "^9.6.19"
2727
},
2828
"prefer-stable": true,
2929
"autoload": {
3030
"psr-4": {
3131
"Lmc\\CodingStandard\\": "src/"
32-
}
32+
},
33+
"files": [
34+
"src/polyfill.php"
35+
]
3336
},
3437
"autoload-dev": {
3538
"psr-4": {

ecs-internal.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
use Lmc\CodingStandard\Set\SetList;
46
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
@@ -18,7 +20,7 @@
1820
SetList::ALMACAREER,
1921
],
2022
)
21-
->withConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' => 'annotation'])
23+
->withConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' => 'prefix'])
2224
->withConfiguredRule(
2325
LineLengthFixer::class,
2426
['line_length' => 120, 'break_long_lines' => true, 'inline_short_lines' => false],

ecs.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
use Lmc\CodingStandard\Fixer\SpecifyArgSeparatorFixer;
46
use Lmc\CodingStandard\Sniffs\Naming\AbstractClassNameSniff;
@@ -127,7 +129,6 @@
127129
use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer;
128130
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer;
129131
use PhpCsFixer\Fixer\Phpdoc\PhpdocVarAnnotationCorrectOrderFixer;
130-
use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer;
131132
use PhpCsFixer\Fixer\PhpTag\FullOpeningTagFixer;
132133
use PhpCsFixer\Fixer\PhpUnit\PhpUnitConstructFixer;
133134
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertFixer;
@@ -638,7 +639,4 @@
638639
// Skip unwanted rules from ReturnTypeHintSniff
639640
ReturnTypeHintSniff::class . '.' . ReturnTypeHintSniff::CODE_MISSING_TRAVERSABLE_TYPE_HINT_SPECIFICATION => null,
640641
ReturnTypeHintSniff::class . '.' . ReturnTypeHintSniff::CODE_MISSING_ANY_TYPE_HINT => null,
641-
642-
// We use declare(strict_types=1); after opening tag
643-
BlankLineAfterOpeningTagFixer::class => null,
644642
]);

phpstan.neon

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,3 @@ parameters:
66
bootstrapFiles:
77
- vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/autoload.php
88
- vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/src/Util/Tokens.php
9-
ignoreErrors:
10-
- path: %currentWorkingDirectory%/tests/Fixer/SpecifyArgSeparatorFixerTest.php
11-
message: '#Parameter \#1 \$code of static method PhpCsFixer\\Tokenizer\\Tokens::fromCode\(\) expects string, string\|false given#'
12-
- path: %currentWorkingDirectory%/tests/Integration/CodingStandardTest.php
13-
message: '#Parameter \#2 \$actualString of method PHPUnit\\Framework\\Assert::assertStringEqualsFile\(\) expects string, string\|false given#'
14-
- identifier: missingType.iterableValue
15-
path: %currentWorkingDirectory%/tests/*

phpunit.xml.dist

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4-
bootstrap="./vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/tests/bootstrap.php"
5-
colors="true"
6-
>
7-
<testsuites>
8-
<testsuite name="unit">
9-
<directory>./tests/</directory>
10-
</testsuite>
11-
</testsuites>
12-
13-
<coverage>
14-
<include>
15-
<directory suffix=".php">./src</directory>
16-
</include>
17-
</coverage>
18-
19-
<php>
20-
<!-- E_ALL = 30719 -->
21-
<ini name="error_reporting" value="30719"/>
22-
</php>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="./vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" colors="true">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">./src</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="unit">
10+
<directory>./tests/</directory>
11+
</testsuite>
12+
</testsuites>
13+
<php>
14+
<!-- E_ALL = 30719 -->
15+
<ini name="error_reporting" value="30719"/>
16+
</php>
2317
</phpunit>

src/Fixer/SpecifyArgSeparatorFixer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Lmc\CodingStandard\Fixer;
46

src/Helper/Naming.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
/*
46
* Originally part of https://github.com/symplify/symplify
@@ -79,7 +81,7 @@ public function getClassName(File $file, int $classNameStartPosition): string
7981

8082
$fqnClassName = $this->getFqnClassName($file, $completeClassName, $classNameStartPosition);
8183
if ($fqnClassName !== '') {
82-
return ltrim($fqnClassName, self::NAMESPACE_SEPARATOR);
84+
return mb_ltrim($fqnClassName, self::NAMESPACE_SEPARATOR);
8385
}
8486

8587
return $completeClassName;

src/Helper/SniffClassWrapper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
/*
46
* Originally part of https://github.com/symplify/symplify

0 commit comments

Comments
 (0)