Skip to content

Commit

Permalink
Update rules of PHP-CS-Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
s-damian committed Jan 5, 2023
1 parent 5014679 commit dd9d8c1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"php": " ^8.1"
},
"scripts": {
"fix-all": "./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php-cs-fixer.dist.php",
"fix-all-dry": "./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php-cs-fixer.dist.php -vv --dry-run --diff"
"fix-all": "php8.1 ./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php-cs-fixer.dist.php",
"fix-all-dry": "php8.1 ./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php-cs-fixer.dist.php -vv --dry-run --diff"
}
}
3 changes: 0 additions & 3 deletions src/1_single-responsibility-principle/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@
* In this example, we see that each class has only one responsibility.
*/


$article = new Article();


$jsonFormatter = new JsonFormatter();

// return string - Returns the content of the article in JSON format.
echo '<pre>';
var_dump($jsonFormatter->format($article));


$xmlFormatter = new XmlFormatter();

// return string - Returns the content of the article in XML format.
Expand Down
3 changes: 0 additions & 3 deletions src/2_open-closed-principle/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@
* and closed to modification .
*/


$sport = new Sport();


$football = new Football();

// return string - Rules of soccer.
echo '<pre>';
var_dump($sport->rules($football));


$basketball = new Basketball();

// return string - Rules of basketball.
Expand Down
3 changes: 0 additions & 3 deletions src/3_liskov-substitution-principle/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* and vice versa without changing the consistency of the program.
*/


$rectangle = new Rectangle();
$rectangle->setWidth(4);
$rectangle->setHeight(6);
Expand All @@ -46,10 +45,8 @@
echo '<pre>';
var_dump($square->getHeight());


echo '<hr>';


$graphic = new Graphic();
$graphic->resizeByPercentage($rectangle, 25);
$graphic->resizeByPercentage($square, 25);
Expand Down
3 changes: 0 additions & 3 deletions src/4_interface-segregation-principle/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@
* In this example, we can therefore see that each class has a specific interface which they themselves can extend from a more generic interface.
*/


$employee = new Employee();


$developer = new Developer();

// return string - Action (job + action of this job).
echo '<pre>';
var_dump($employee->action($developer));


$webdesigner = new Webdesigner();

// return string - Action (job + action of this job).
Expand Down
3 changes: 0 additions & 3 deletions src/5_dependency-inversion-principle/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,17 @@
* In this example, we therefore see that we are replacing the dependency injected into the constructor of "\Mailing\SendMail".
*/


$swiftMailer = new SwiftMailer();

$sendMail = new SendMail($swiftMailer);
// return string - Returns SwiftMailer's confirmation message.
echo '<pre>';
var_dump($sendMail->sendMessage());


/**
* We can therefore replace the injected dependency "\Mailing\Mailers\SwiftMailer" by "\Mailing\Mailers\PHPMailer".
*/


$phpMailer = new PHPMailer();

$sendMail = new SendMail($phpMailer);
Expand Down
18 changes: 18 additions & 0 deletions tools/php-cs-fixer/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,23 @@
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'exit', 'return', 'throw', 'try'],
],
'no_extra_blank_lines' => [
'tokens' => ['curly_brace_block', 'extra', 'use'],
],
'no_multiline_whitespace_around_double_arrow' => true,
'no_spaces_around_offset' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'space_after_semicolon' => true,
'strict_comparison' => false,
'ternary_operator_spaces' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => false,
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder);

0 comments on commit dd9d8c1

Please sign in to comment.