Skip to content

Commit

Permalink
Apply "@psr12" in php-cs-fixer (#1150)
Browse files Browse the repository at this point in the history
* Apply "@psr12" in php-cs-fixer

* Run fix-style
  • Loading branch information
yaegassy authored Feb 5, 2021
1 parent f0959c1 commit 4f42af1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
6 changes: 2 additions & 4 deletions .php_cs.common.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

// Share common rules between non-test and test files
return [
// PSR12 from https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4943
'@PSR2' => true,
'@PSR12' => true,
'blank_line_after_opening_tag' => true,
'braces' => [
// Not-yet-implemented
// 'allow_single_line_anonymous_class_with_empty_body' => true,
'allow_single_line_anonymous_class_with_empty_body' => true,
],
'compact_nullable_typehint' => true,
'declare_equal_normalize' => true,
Expand Down
1 change: 0 additions & 1 deletion src/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ protected function addMagicMethods()
*/
protected function detectMethods()
{

foreach ($this->classes as $class) {
$reflection = new \ReflectionClass($class);

Expand Down
24 changes: 10 additions & 14 deletions src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ protected function getOptions()

protected function generateDocs($loadModels, $ignore = '')
{


$output = "<?php
// @formatter:off
Expand Down Expand Up @@ -313,7 +311,6 @@ protected function loadModels()

$dirs = glob($dir, GLOB_ONLYDIR);
foreach ($dirs as $dir) {

if (!is_dir($dir)) {
$this->error("Cannot locate directory '{'$dir}'");
continue;
Expand Down Expand Up @@ -757,7 +754,6 @@ protected function setMethod($name, $type = '', $arguments = [])
*/
protected function createPhpDocs($class)
{

$reflection = new ReflectionClass($class);
$namespace = $reflection->getNamespaceName();
$classname = $reflection->getShortName();
Expand Down Expand Up @@ -1019,7 +1015,7 @@ protected function getReturnTypeFromReflection(\ReflectionMethod $reflection): ?

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

if($returnType->allowsNull()){
if ($returnType->allowsNull()) {
$type .='|null';
}

Expand Down Expand Up @@ -1050,7 +1046,7 @@ protected function getSoftDeleteMethods($model)
*/
protected function getFactoryMethods($model)
{
if(!class_exists(Factory::class)) {
if (!class_exists(Factory::class)) {
return;
}

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

if($reflectionType === 'static' || $reflectionType === '$this') {
if ($reflectionType === 'static' || $reflectionType === '$this') {
$reflectionType = $type;
}

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

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

if($paramType->allowsNull()){
if(count($types)==1){
if ($paramType->allowsNull()) {
if (count($types)==1) {
$type = '?' . $type;
}else{
} else {
$type .='|null';
}
}
Expand Down Expand Up @@ -1293,12 +1289,12 @@ protected function getParamType(\ReflectionMethod $method, \ReflectionParameter

protected function extractReflectionTypes(ReflectionType $reflection_type)
{
if($reflection_type instanceof ReflectionNamedType){
if ($reflection_type instanceof ReflectionNamedType) {
$types[] = $this->getReflectionNamedType($reflection_type);
}else{
} else {
$types = [];
foreach ($reflection_type->getTypes() as $named_type){
if($named_type->getName()==='null'){
foreach ($reflection_type->getTypes() as $named_type) {
if ($named_type->getName()==='null') {
continue;
}

Expand Down

0 comments on commit 4f42af1

Please sign in to comment.