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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
groups:
all-dependencies:
patterns:
- "*"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHP CS Fixer
name: Lint

on:
push:
Expand All @@ -7,18 +7,21 @@ on:
workflow_dispatch:

jobs:
php-cs-fixer:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

- uses: shivammathur/setup-php@v2
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
php-version: '8.3'

- name: Install dependencies
run: composer install --no-interaction --no-progress

- name: Run PHP CS Fixer
- name: PHP CS Fixer
run: php vendor/bin/php-cs-fixer fix --diff --dry-run

- name: Rector
run: php vendor/bin/rector -c .rector.php --dry-run
24 changes: 0 additions & 24 deletions .github/workflows/rector.yml

This file was deleted.

22 changes: 19 additions & 3 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
<?php

$config = new PhpCsFixer\Config();

return $config
->setRiskyAllowed(true)
->setParallelConfig(new PhpCsFixer\Runner\Parallel\ParallelConfig())
->setRules([
// see https://cs.symfony.com/doc/ruleSets/PER-CS2.0.html
'@PER-CS2.0' => true,
// RISKY: Use && and || logical operators instead of and and or.
'logical_operators' => true,
// RISKY: Replaces intval, floatval, doubleval, strval and boolval function calls with according type casting operator.
'modernize_types_casting' => true,
// PHP84: Adds or removes ? before single type declarations or |null at the end of union types when parameters have a default null value.
'nullable_type_declaration_for_default_null_value' => true,
// Convert double quotes to single quotes for simple strings.
'single_quote' => true,
// PHPdoc stuff
'phpdoc_indent' => true,
'phpdoc_param_order' => true,
'phpdoc_single_line_var_spacing' => true,
Expand All @@ -19,8 +24,19 @@
])
->setFinder(
PhpCsFixer\Finder::create()
->in([__DIR__ . '/app'])
->name(['*.php'])
// Same canonical list as the maho repo; only the dirs that exist in
// this repo are scanned, so the one config works for app-only modules.
->in(array_values(array_filter([
__DIR__ . '/app',
__DIR__ . '/lib',
__DIR__ . '/public',
__DIR__ . '/tests',
__DIR__ . '/src',
], 'is_dir')))
// Root-level entry points (e.g. the infra tool's sync.php / config.php).
// glob skips dotfiles, so these very config files aren't included.
->append(glob(__DIR__ . '/*.php') ?: [])
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
);
99 changes: 57 additions & 42 deletions .rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,65 @@

declare(strict_types=1);

use Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector;
use Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector;
use Rector\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector;
use Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector;
use Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector;
use Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector;
use Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector;
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\CodeQuality\Rector as CodeQuality;
use Rector\CodingStyle\Rector as CodingStyle;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector;
use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
use Rector\DeadCode\Rector as DeadCode;
use Rector\EarlyReturn\Rector as EarlyReturn;
use Rector\TypeDeclaration\Rector as TypeDeclaration;

// Shared by every repo that consumes the org baseline. Only standard Rector
// rules, so it needs no extra dependency: maho's own .rector.php (with the
// Maho\Rector\* rules and the Varien->Maho migration) stays in maho and is not
// synced. Only the paths that exist in a given repo are scanned, so the one
// config works for app-only modules and the infra tool's src/ alike.
return RectorConfig::configure()
->withPaths([__DIR__ . '/app'])
->withPhpSets(php83: true)
->withPaths(array_values(array_merge(
array_filter([
__DIR__ . '/app',
__DIR__ . '/lib',
__DIR__ . '/public',
__DIR__ . '/src',
], 'is_dir'),
// Root-level entry points (e.g. the infra tool's sync.php / config.php).
// glob skips dotfiles, so this very config file isn't included.
glob(__DIR__ . '/*.php') ?: [],
)))
// No argument: Rector reads the target PHP version from composer.json
// (require.php's floor, else config.platform.php), kept at 8.3 by the sync.
->withPhpSets()
->withRules([
ReplaceMultipleBooleanNotRector::class,
UnusedForeachValueToArrayKeysRector::class,
ChangeArrayPushToArrayAssignRector::class,
CompactToVariablesRector::class,
SimplifyArraySearchRector::class,
SimplifyConditionsRector::class,
StrlenZeroToIdenticalEmptyStringRector::class,
CommonNotEqualRector::class,
LogicalToBooleanRector::class,
SimplifyTautologyTernaryRector::class,
SwitchNegatedTernaryRector::class,
MakeInheritedMethodVisibilitySameAsParentRector::class,
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
RemoveNullArgOnNullDefaultParamRector::class,
RemoveUselessVarTagRector::class,
ChangeNestedIfsToEarlyReturnRector::class,
RemoveAlwaysElseRector::class,
AddOverrideAttributeToOverriddenMethodsRector::class,
DeclareStrictTypesRector::class,
CodeQuality\BooleanNot\ReplaceMultipleBooleanNotRector::class,
CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class,
CodeQuality\FuncCall\ChangeArrayPushToArrayAssignRector::class,
CodeQuality\FuncCall\CompactToVariablesRector::class,
CodeQuality\Identical\SimplifyArraySearchRector::class,
CodeQuality\Identical\SimplifyConditionsRector::class,
CodeQuality\Identical\StrlenZeroToIdenticalEmptyStringRector::class,
CodeQuality\LogicalAnd\LogicalToBooleanRector::class,
CodeQuality\NotEqual\CommonNotEqualRector::class,
CodeQuality\Ternary\SimplifyTautologyTernaryRector::class,
CodeQuality\Ternary\SwitchNegatedTernaryRector::class,
CodingStyle\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector::class,
DeadCode\ClassMethod\RemoveUselessParamTagRector::class,
DeadCode\ClassMethod\RemoveUselessReturnTagRector::class,
DeadCode\MethodCall\RemoveNullArgOnNullDefaultParamRector::class,
DeadCode\Property\RemoveUselessVarTagRector::class,
EarlyReturn\If_\ChangeNestedIfsToEarlyReturnRector::class,
EarlyReturn\If_\RemoveAlwaysElseRector::class,
Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector::class,
Rector\Php71\Rector\List_\ListToArrayDestructRector::class,
Rector\Php74\Rector\Assign\NullCoalescingOperatorRector::class,
Rector\Php80\Rector\Class_\StringableForToStringRector::class,
Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector::class,
Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class,
Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class,
Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector::class,
TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class,
TypeDeclaration\StmtsAwareInterface\SafeDeclareStrictTypesRector::class,
])
->withConfiguredRule(Rector\Php82\Rector\Param\AddSensitiveParameterAttributeRector::class, [
'sensitive_parameters' => [
'token', 'apiKey', 'email', 'useremail', 'username', 'password',
],
]);
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"config": {
"allow-plugins": {
"mahocommerce/maho-composer-plugin": true
},
"platform": {
"php": "8.3"
}
}
}