Add PHP CS fixer
parent
850d5496f7
commit
51c2d60f20
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
name: Lint
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
xml-linters:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Download schema
|
||||||
|
run: wget https://apps.nextcloud.com/schema/apps/info.xsd
|
||||||
|
- name: Lint info.xml
|
||||||
|
uses: ChristophWurst/xmllint-action@v1
|
||||||
|
with:
|
||||||
|
xml-file: ./appinfo/info.xml
|
||||||
|
xml-schema-file: ./info.xsd
|
||||||
|
php-cs-fixer:
|
||||||
|
name: PHP-CS-Fixer
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: PHP-CS-Fixer
|
||||||
|
uses: docker://oskarstark/php-cs-fixer-ga
|
||||||
|
with:
|
||||||
|
args: --dry-run --diff lib
|
|
@ -18,6 +18,7 @@ js/
|
||||||
build/
|
build/
|
||||||
coverage/
|
coverage/
|
||||||
.php_cs.cache
|
.php_cs.cache
|
||||||
|
.php-cs-fixer.cache
|
||||||
vendor
|
vendor
|
||||||
memories.tar.gz
|
memories.tar.gz
|
||||||
/test-results/
|
/test-results/
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of PHP CS Fixer.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
||||||
|
*
|
||||||
|
* This source file is subject to the MIT license that is bundled
|
||||||
|
* with this source code in the file LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$finder = PhpCsFixer\Finder::create()
|
||||||
|
->ignoreDotFiles(false)
|
||||||
|
->ignoreVCSIgnored(true)
|
||||||
|
->exclude('tests/Fixtures')
|
||||||
|
->in(__DIR__)
|
||||||
|
->append([
|
||||||
|
__DIR__.'/dev-tools/doc.php',
|
||||||
|
// __DIR__.'/php-cs-fixer', disabled, as we want to be able to run bootstrap file even on lower PHP version, to show nice message
|
||||||
|
])
|
||||||
|
;
|
||||||
|
|
||||||
|
$config = new PhpCsFixer\Config();
|
||||||
|
$config
|
||||||
|
->setRiskyAllowed(true)
|
||||||
|
->setRules([
|
||||||
|
'@PHP71Migration' => false,
|
||||||
|
'@PHP71Migration:risky' => false,
|
||||||
|
'@PHPUnit75Migration:risky' => true,
|
||||||
|
'@PhpCsFixer' => true,
|
||||||
|
'@PhpCsFixer:risky' => true,
|
||||||
|
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], // one should use PHPUnit built-in method instead
|
||||||
|
'modernize_strpos' => false, // needs PHP 8+ or polyfill
|
||||||
|
])
|
||||||
|
->setFinder($finder)
|
||||||
|
;
|
||||||
|
|
||||||
|
// special handling of fabbot.io service if it's using too old PHP CS Fixer version
|
||||||
|
if (false !== getenv('FABBOT_IO')) {
|
||||||
|
try {
|
||||||
|
PhpCsFixer\FixerFactory::create()
|
||||||
|
->registerBuiltInFixers()
|
||||||
|
->registerCustomFixers($config->getCustomFixers())
|
||||||
|
->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
|
||||||
|
;
|
||||||
|
} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
|
||||||
|
$config->setRules([]);
|
||||||
|
} catch (UnexpectedValueException $e) {
|
||||||
|
$config->setRules([]);
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
$config->setRules([]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
Loading…
Reference in New Issue