Skip to content

Commit 4f42af1

Browse files
authored
Apply "@psr12" in php-cs-fixer (#1150)
* Apply "@psr12" in php-cs-fixer * Run fix-style
1 parent f0959c1 commit 4f42af1

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

.php_cs.common.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
// Share common rules between non-test and test files
44
return [
5-
// PSR12 from https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4943
6-
'@PSR2' => true,
5+
'@PSR12' => true,
76
'blank_line_after_opening_tag' => true,
87
'braces' => [
9-
// Not-yet-implemented
10-
// 'allow_single_line_anonymous_class_with_empty_body' => true,
8+
'allow_single_line_anonymous_class_with_empty_body' => true,
119
],
1210
'compact_nullable_typehint' => true,
1311
'declare_equal_normalize' => true,

src/Alias.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ protected function addMagicMethods()
344344
*/
345345
protected function detectMethods()
346346
{
347-
348347
foreach ($this->classes as $class) {
349348
$reflection = new \ReflectionClass($class);
350349

src/Console/ModelsCommand.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ protected function getOptions()
212212

213213
protected function generateDocs($loadModels, $ignore = '')
214214
{
215-
216-
217215
$output = "<?php
218216
219217
// @formatter:off
@@ -313,7 +311,6 @@ protected function loadModels()
313311

314312
$dirs = glob($dir, GLOB_ONLYDIR);
315313
foreach ($dirs as $dir) {
316-
317314
if (!is_dir($dir)) {
318315
$this->error("Cannot locate directory '{'$dir}'");
319316
continue;
@@ -757,7 +754,6 @@ protected function setMethod($name, $type = '', $arguments = [])
757754
*/
758755
protected function createPhpDocs($class)
759756
{
760-
761757
$reflection = new ReflectionClass($class);
762758
$namespace = $reflection->getNamespaceName();
763759
$classname = $reflection->getShortName();
@@ -1019,7 +1015,7 @@ protected function getReturnTypeFromReflection(\ReflectionMethod $reflection): ?
10191015

10201016
$type = implode('|', $types);
10211017

1022-
if($returnType->allowsNull()){
1018+
if ($returnType->allowsNull()) {
10231019
$type .='|null';
10241020
}
10251021

@@ -1050,7 +1046,7 @@ protected function getSoftDeleteMethods($model)
10501046
*/
10511047
protected function getFactoryMethods($model)
10521048
{
1053-
if(!class_exists(Factory::class)) {
1049+
if (!class_exists(Factory::class)) {
10541050
return;
10551051
}
10561052

@@ -1128,7 +1124,7 @@ protected function checkForCustomLaravelCasts(string $type): ?string
11281124
$reflectionType = $this->getReturnTypeFromDocBlock($methodReflection);
11291125
}
11301126

1131-
if($reflectionType === 'static' || $reflectionType === '$this') {
1127+
if ($reflectionType === 'static' || $reflectionType === '$this') {
11321128
$reflectionType = $type;
11331129
}
11341130

@@ -1217,10 +1213,10 @@ protected function getParamType(\ReflectionMethod $method, \ReflectionParameter
12171213

12181214
$type = implode('|', $types);
12191215

1220-
if($paramType->allowsNull()){
1221-
if(count($types)==1){
1216+
if ($paramType->allowsNull()) {
1217+
if (count($types)==1) {
12221218
$type = '?' . $type;
1223-
}else{
1219+
} else {
12241220
$type .='|null';
12251221
}
12261222
}
@@ -1293,12 +1289,12 @@ protected function getParamType(\ReflectionMethod $method, \ReflectionParameter
12931289

12941290
protected function extractReflectionTypes(ReflectionType $reflection_type)
12951291
{
1296-
if($reflection_type instanceof ReflectionNamedType){
1292+
if ($reflection_type instanceof ReflectionNamedType) {
12971293
$types[] = $this->getReflectionNamedType($reflection_type);
1298-
}else{
1294+
} else {
12991295
$types = [];
1300-
foreach ($reflection_type->getTypes() as $named_type){
1301-
if($named_type->getName()==='null'){
1296+
foreach ($reflection_type->getTypes() as $named_type) {
1297+
if ($named_type->getName()==='null') {
13021298
continue;
13031299
}
13041300

0 commit comments

Comments
 (0)