Lançada em 1994
https://kinsta.com/php-market-share/
$ sudo mkdir --parents /opt/php-cs-fixer
$ sudo composer require --working-dir=/opt/php-cs-fixer
friendsofphp/php-cs-fixer
$ sudo ln -s /opt/php-cs-fixer/vendor/bin/php-cs-fixer
/usr/bin/php-cs-fixer
.php_cs.dist
.php_cs.dist
<?php
declare(strict_types=1);
$finder = PhpCsFixer\Finder::create();
$csFixer = PhpCsFixer\Config::create();
$csFixer
->setFinder($finder)
->setUsingCache(false)
->setRiskyAllowed(true);
return $csFixer;
.php_cs.dist
<?php
declare(strict_types=1);
$finder = PhpCsFixer\Finder::create();
$finder
->in('src')
->notPath('index.php');
$csFixer = PhpCsFixer\Config::create();
$csFixer->setFinder($finder);
return $csFixer;
<?php
declare(strict_types=1);
$rules = [
'@Symfony' => true,
'@PHP71Migration' => true,
'array_syntax' => ['syntax' => 'short'],
'declare_strict_types' => true,
'void_return' => true,
'yoda_style' => false,
'increment_style' => ['style' => 'post'],
];
$csFixer = PhpCsFixer\Config::create();
$csFixer->setRules($rules);
return $csFixer;
<?php
declare(strict_types=1);
$finder = PhpCsFixer\Finder::create();
$finder->in('src')->notPath('index.php');
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@PHP71Migration' => true,
'array_syntax' => ['syntax' => 'short'],
'declare_strict_types' => true,
'void_return' => true,
'yoda_style' => false,
'increment_style' => ['style' => 'post'],
])
->setFinder($finder)
->setUsingCache(false)
->setRiskyAllowed(true);
<?php
$word = 'Acordeon';
//sem yoda style
if ($word === 'Acordeon') {
}
//com yoda style
if ('Acordeon' === $word) {
}
<?php
$persons = [
'Chiquim',
'Zezim',
'Joaozim',
];
//sem yoda style
if (in_array('Zezim', $persons)) {
}
//com yoda style
if (true === in_array('Zezim', $persons)) {
}
https://mlocati.github.io/php-cs-fixer-configurator/
slides.com/alessandrofeitoza
www.alessandrofeitoza.eu
twitter.com/FeitozaAle