Skip to content

Commit

Permalink
Merge pull request #152 from tighten/drift/update-custom-order-class
Browse files Browse the repository at this point in the history
[3.x] Fix issue with new PHP CS Fixer
  • Loading branch information
driftingly authored Jun 24, 2024
2 parents 8301311 + a92b053 commit 0128c2e
Show file tree
Hide file tree
Showing 20 changed files with 11,291 additions and 442 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
coverage: none

- name: Install dev dependencies
run: COMPOSER=composer-dev.json composer install
shell: bash
run: export COMPOSER=composer-dev.json && composer install

- name: Run Duster
run: ./builds/duster lint --using="tlint,phpcodesniffer,phpcsfixer,pint"
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/composer-dev.lock
/vendor
.phpunit.result.cache
.phpunit.cache
Expand Down
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,23 @@ When working locally you will need to install the dev dependencies.
```bash
COMPOSER=composer-dev.json composer install
```

## Dependencies

To update dependencies to latest:

```bash
# Production
composer require friendsofphp/php-cs-fixer laravel/pint squizlabs/php_codesniffer tightenco/tlint --dev

# Development
COMPOSER=composer-dev.json composer require friendsofphp/php-cs-fixer laravel/pint squizlabs/php_codesniffer tightenco/tlint --dev
```

## PHPStan

If PHPStan fails locally, try increasing the memory:

```bash
./vendor/bin/phpstan analyze --memory-limit 1G
```
3 changes: 1 addition & 2 deletions app/Actions/Clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class Clean
public function __construct(
protected string $mode,
protected array $tools,
) {
}
) {}

public function execute(): int
{
Expand Down
4 changes: 1 addition & 3 deletions app/Contracts/PintInputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use Symfony\Component\Console\Input\InputInterface;

interface PintInputInterface extends InputInterface
{
}
interface PintInputInterface extends InputInterface {}
69 changes: 35 additions & 34 deletions app/Fixer/ClassNotation/CustomControllerOrderFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,6 @@ public function getName(): string
return 'Tighten/custom_controller_order';
}

public function configure(array $configuration): void
{
$configuration['order'] = [
'use_trait',
'property_public_static',
'property_protected_static',
'property_private_static',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'method:__invoke',
'method_public_static',
'method_protected_static',
'method_private_static',
'method:index',
'method:create',
'method:store',
'method:show',
'method:edit',
'method:update',
'method:destroy',
'method_public',
'method_protected',
'method_private',
'magic',
];

parent::configure($configuration);
}

/**
* {@inheritdoc}
*
Expand Down Expand Up @@ -103,6 +69,41 @@ public function isControllerClass(Tokens $tokens, int $index): bool
return false;
}

/**
* @param array<string, mixed> $configuration
*/
protected function configurePreNormalisation(array &$configuration): void
{
$configuration['order'] = $configuration['order'] ?? [
'use_trait',
'property_public_static',
'property_protected_static',
'property_private_static',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'method:__invoke',
'method_public_static',
'method_protected_static',
'method_private_static',
'method:index',
'method:create',
'method:store',
'method:show',
'method:edit',
'method:update',
'method:destroy',
'method_public',
'method_protected',
'method_private',
'magic',
];
}

protected function applyFix(SplFileInfo $file, Tokens $tokens): void
{
for ($index = $tokens->count() - 1; $index > 0; $index--) {
Expand Down
Loading

0 comments on commit 0128c2e

Please sign in to comment.