PHP code example of juliangut / php-cs-fixer-config
1. Go to this page and download the library: Download juliangut/php-cs-fixer-config library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
juliangut / php-cs-fixer-config example snippets
use Jgut\CS\Fixer\FixerConfig80;
use PhpCsFixer\Finder;
$finder = Finder::create()
->ignoreDotFiles(false)
->exclude(['vendor'])
->in(__DIR__)
->name('.php-cs-fixer.php');
return (new FixerConfig80())
->setFinder($finder);
return (new FixerConfig80())
->setHeader(<<<'HEADER'
(c) 2021-{{year}} Julián Gutiérrez <[email protected]>
This file is part of package {{package}}
HEADER);
return (new FixerConfig80())
->enablePhpUnitRules();
return (new FixerConfig80())
->enableDoctrineRules();
return (new FixerConfig80())
->enableTypeInferRules();
use Jgut\CS\Fixer\FixerConfig80;
use PhpCsFixer\Fixer\FunctionNotation\SingleLineThrowFixer;
return (new FixerConfig80())
->setAdditionalRules([
SingleLineThrowFixer::class => true, // Preferred way
'single_line_throw' => true, // Same as above
]);
use Jgut\CS\Fixer\FixerConfig81;
use PhpCsFixer\Fixer\FunctionNotation\SingleLineThrowFixer;
class CustomFixerConfig extends FixerConfig81
{
protected function getFixerRules(): array
{
// Return your custom rules, or add/remove rules from parent's getFixerRules()
return array_merge(
parent::getFixerRules(),
[
SingleLineThrowFixer::class => true, // Preferred way
'single_line_throw' => true, // Same as above
]
);
}
}
diff
--- Original
+++ New
+/*
+ * (c) 2021-2022 Julián Gutiérrez <[email protected]>
+ *
+ * This file is part of package juliangut/php-cs-fixer-config
+ */
+
declare(strict_types=1);
namespace App;
diff
--- Original
+++ New
declare(strict_types=1);
namespace App;
class Foo
{
- /**
- * @var string|null
- */
- protected $foo
+ protected ?string $foo
- /**
- * @var Bar
- */
- protected $bar
+ protected Bar $bar
- /**
- * @var bool
- */
- protected $baz
+ protected bool $baz
/**
* Foo constructor.
- *
- * @param string|null $foo
- * @param Bar $bar
- * @param bool $baz
*/
- public function __construct($foo, $bar, $baz = false)
+ public function __construct(?string $foo, Bar $bar, bool $baz = false)
{
$this->foo = $foo;
$this->bar = $bar;
$this->baz = $baz;
}
- /**
- * @return bool
- *
- public function isBaz()
+ public function isBaz(): bool
{
return $this->baz;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.