Skip to content

Commit

Permalink
Merge pull request #205 from sanmai/pr/php-cs-fixer
Browse files Browse the repository at this point in the history
Update PHP Coding Standards Fixer, bump PHP version support
  • Loading branch information
sanmai authored Aug 7, 2023
2 parents 8000aed + 80eda02 commit 44942ae
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 257 deletions.
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view
# https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt

72c7e3f4e34d2ed474b1399f2a7ab427fb6f3b14
6 changes: 3 additions & 3 deletions .github/workflows/cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
php-version: ['7.3']
php-version: ['8.2']

name: PHP ${{ matrix.php-version }}

Expand All @@ -23,9 +23,9 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions:
extensions:
coverage: pcov
tools: composer:v1
tools: composer:v2

- name: Cache dependencies
uses: actions/cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
php-version: ['7.4']
php-version: ['8.2']
dependencies: ['']

name: PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:

strategy:
matrix:
php-version: ['7.3', '7.4', '8.0', '8.1', '8.2']
php-version: ['7.4', '8.0', '8.1', '8.2']
include:
- { php-version: '7.3', dependencies: '--prefer-lowest', legend: 'with lowest dependencies' }
- { php-version: '7.4', dependencies: '--prefer-lowest', legend: 'with lowest dependencies' }

name: PHP ${{ matrix.php-version }} ${{ matrix.legend }}

Expand Down
11 changes: 8 additions & 3 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
@package Liquid
EOF;

return PhpCsFixer\Config::create()
$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'psr4' => true,
'psr_autoloading' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
Expand All @@ -30,13 +31,17 @@
'php_unit_mock' => true,
'php_unit_namespaced' => true,
'php_unit_no_expectation_annotation' => true,
'php_unit_ordered_covers' => true,
"phpdoc_order_by_value" => ['annotations' => ['covers']],
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
'no_whitespace_in_blank_line' => true,
])
->setIndent("\t")
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
)
;


return $config;
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
}
],
"require": {
"php": "^7.3 || ^8.0"
"php": "^7.4 || ^8.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.8",
"friendsofphp/php-cs-fixer": "^2.16.4",
"ergebnis/composer-normalize": ">=2.8",
"friendsofphp/php-cs-fixer": "^3.22",
"infection/infection": ">=0.17.6",
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^9.2.6"
Expand Down
2 changes: 1 addition & 1 deletion src/Liquid/CustomFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class CustomFilters
{

/**
* Sort an array by key.
*
Expand Down
18 changes: 9 additions & 9 deletions src/Liquid/Liquid.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ public static function get($key)
}
// This case is needed for compound settings
switch ($key) {
case 'QUOTED_FRAGMENT':
return '(?:' . self::get('QUOTED_STRING') . '|[^\s,\|\'"]+)';
case 'TAG_ATTRIBUTES':
return '/(\w+)\s*\:\s*(' . self::get('QUOTED_FRAGMENT') . ')/';
case 'TOKENIZATION_REGEXP':
return '/(' . self::$config['TAG_START'] . '.*?' . self::$config['TAG_END'] . '|' . self::$config['VARIABLE_START'] . '.*?' . self::$config['VARIABLE_END'] . ')/s';
default:
return null;
}
case 'QUOTED_FRAGMENT':
return '(?:' . self::get('QUOTED_STRING') . '|[^\s,\|\'"]+)';
case 'TAG_ATTRIBUTES':
return '/(\w+)\s*\:\s*(' . self::get('QUOTED_FRAGMENT') . ')/';
case 'TOKENIZATION_REGEXP':
return '/(' . self::$config['TAG_START'] . '.*?' . self::$config['TAG_END'] . '|' . self::$config['VARIABLE_START'] . '.*?' . self::$config['VARIABLE_END'] . ')/s';
default:
return null;
}
}

/**
Expand Down
Loading

0 comments on commit 44942ae

Please sign in to comment.