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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<!-- There is always Unreleased section on the top. Subsections (Added, Changed, Fixed, Removed) should be added as needed. -->

## Unreleased
- Remove skip of BlankLineAfterOpeningTagFixer to be PSR-12 compliant.

## 5.0.0 - TBD
- **BC break:** Change namespace from `Lmc\CodingStandard` to `AlmaOss\CodingStandard`. See [UPGRADE-5.0.md](UPGRADE-5.0.md) for step-by-step upgrade howto.
- **BC break:** Remove skip of `BlankLineAfterOpeningTagFixer` to be PSR-12 compliant. A blank line after the opening PHP tag is now required.

## 4.2.0 - 2025-02-28
- Rename the package from "Alma Career Czechia Standard for PHP" to more broad "Alma Career Coding Standard for PHP". 🎉
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ We use [EasyCodingStandard][ecs] to define and execute checks created for both [
## Switching from lmc/coding-standard

The package `almacareer/coding-standard` is 1:1 replacement for the previous deprecated `lmc/coding-standard` package.

⚠️ **Note:** Starting from version 5.0.0, the namespace has changed from `Lmc\CodingStandard` to `AlmaOss\CodingStandard`. See [UPGRADE-5.0.md](UPGRADE-5.0.md) for detailed upgrade instructions.

To change the package, you only need to do the following changes in your project:

### 1. Update dependency in composer.json
```diff
- "lmc/coding-standard": "^4.1",
+ "almacareer/coding-standard": "^4.2",
+ "almacareer/coding-standard": "^5.0",
```

And then run `composer update`.
Expand Down
99 changes: 99 additions & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Upgrading from 4.x to 5.0

### 1. Update dependency in composer.json
In the `require-dev` section of `composer.json` change the version constraint:

```diff
- "almacareer/coding-standard": "^4.2",
+ "almacareer/coding-standard": "^5.0",
```

Then run `composer update almacareer/coding-standard`.

### 2. Update namespace imports

**[BC break]** The namespace has been changed from `Lmc\CodingStandard` to `AlmaOss\CodingStandard`.

Update your `ecs.php` file to use the new namespace:

```diff
<?php

declare(strict_types=1);

-use Lmc\CodingStandard\Set\SetList;
+use AlmaOss\CodingStandard\Set\SetList;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return ECSConfig::configure()
->withSets(
[
SetList::ALMACAREER,
]
);
```

If you are using any custom sniffs or fixers from this package in your configuration, update their namespace as well:

```diff
-use Lmc\CodingStandard\Fixer\SpecifyArgSeparatorFixer;
+use AlmaOss\CodingStandard\Fixer\SpecifyArgSeparatorFixer;

-use Lmc\CodingStandard\Sniffs\Naming\ClassNameSuffixByParentSniff;
+use AlmaOss\CodingStandard\Sniffs\Naming\ClassNameSuffixByParentSniff;
```

### 3. PSR-12 compliance change

**[BC break]** The `BlankLineAfterOpeningTagFixer` is no longer skipped. This means that a blank line after the opening PHP tag (`<?php`) is now required to be PSR-12 compliant.

Before (no longer valid):
```php
<?php
declare(strict_types=1);
```

After (PSR-12 compliant):
```php
<?php

declare(strict_types=1);
```

If your codebase does not follow this convention yet, running `vendor/bin/ecs check --fix` will automatically add the blank lines.

If you want to keep the old behavior and skip this check, you can add it to your `ecs.php`:

```php
use PhpCsFixer\Fixer\Whitespace\BlankLineAfterOpeningTagFixer;

return ECSConfig::configure()
// ...
->withSkip([
BlankLineAfterOpeningTagFixer::class,
]);
```

### 4. Run the code style checks

After updating the namespace, run the code style checks to ensure everything is working correctly:

```bash
vendor/bin/ecs check
```

To automatically fix the code style issues (including the blank line after opening tag):

```bash
vendor/bin/ecs check --fix
```

### 5. Sanity check

You can ensure all predefined checks are loaded by running:

```sh
vendor/bin/ecs list-checkers
```

The output should show all the loaded checkers from both PHP-CS-Fixer and PHP_CodeSniffer.