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

[3.x] Fix issue with new PHP CS Fixer #152

Merged
merged 9 commits into from
Jun 24, 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
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