chore: psr12 (#964)

This commit is contained in:
feek
2020-06-23 06:59:56 +02:00
committed by GitHub
parent 4cd3362dfd
commit 4aa919c09f
11 changed files with 46 additions and 27 deletions
+1
View File
@@ -1,4 +1,5 @@
<?php
/**
* Laravel IDE Helper Generator - Eloquent Model Mixin
*
+5 -2
View File
@@ -1,4 +1,5 @@
<?php
/**
* Laravel IDE Helper Generator
*
@@ -76,9 +77,11 @@ class GeneratorCommand extends Command
*/
public function handle()
{
if (file_exists(base_path() . '/vendor/compiled.php') ||
if (
file_exists(base_path() . '/vendor/compiled.php') ||
file_exists(base_path() . '/bootstrap/cache/compiled.php') ||
file_exists(base_path() . '/storage/framework/compiled.php')) {
file_exists(base_path() . '/storage/framework/compiled.php')
) {
$this->error(
'Error generating IDE Helper: first delete your compiled file (php artisan clear-compiled)'
);
+2 -1
View File
@@ -1,4 +1,5 @@
<?php
/**
* Laravel IDE Helper Generator
*
@@ -98,7 +99,7 @@ class MetaCommand extends Command
}
} catch (\Throwable $e) {
if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$this->comment("Cannot make '$abstract': ".$e->getMessage());
$this->comment("Cannot make '$abstract': " . $e->getMessage());
}
}
}
+24 -17
View File
@@ -1,4 +1,5 @@
<?php
/**
* Laravel IDE Helper Generator
*
@@ -109,9 +110,10 @@ class ModelsCommand extends Command
//If filename is default and Write is not specified, ask what to do
if (!$this->write && $filename === $this->filename && !$this->option('nowrite')) {
if ($this->confirm(
"Do you want to overwrite the existing model files? Choose no to write to $filename instead"
)
if (
$this->confirm(
"Do you want to overwrite the existing model files? Choose no to write to $filename instead"
)
) {
$this->write = true;
}
@@ -254,7 +256,7 @@ class ModelsCommand extends Command
if (!$hasDoctrine) {
$this->error(
'Warning: `"doctrine/dbal": "~2.3"` is required to load database information. '.
'Warning: `"doctrine/dbal": "~2.3"` is required to load database information. ' .
'Please require that in your composer.json and run `composer update`.'
);
}
@@ -455,10 +457,11 @@ class ModelsCommand extends Command
if ($methods) {
sort($methods);
foreach ($methods as $method) {
if (Str::startsWith($method, 'get') && Str::endsWith(
$method,
'Attribute'
) && $method !== 'getAttribute'
if (
Str::startsWith($method, 'get') && Str::endsWith(
$method,
'Attribute'
) && $method !== 'getAttribute'
) {
//Magic get<name>Attribute
$name = Str::snake(substr($method, 3, -9));
@@ -468,10 +471,11 @@ class ModelsCommand extends Command
$type = $this->getTypeInModel($model, $type);
$this->setProperty($name, $type, true, null);
}
} elseif (Str::startsWith($method, 'set') && Str::endsWith(
$method,
'Attribute'
) && $method !== 'setAttribute'
} elseif (
Str::startsWith($method, 'set') && Str::endsWith(
$method,
'Attribute'
) && $method !== 'setAttribute'
) {
//Magic set<name>Attribute
$name = Str::snake(substr($method, 3, -9));
@@ -500,7 +504,8 @@ class ModelsCommand extends Command
$builder = $this->getClassNameInModel($model, get_class($model->newModelQuery()));
$this->setMethod($method, $builder . "|" . $this->getClassNameInModel($model, get_class($model)));
} elseif (!method_exists('Illuminate\Database\Eloquent\Model', $method)
} elseif (
!method_exists('Illuminate\Database\Eloquent\Model', $method)
&& !Str::startsWith($method, 'get')
) {
//Use reflection to inspect the code, based on Illuminate/Support/SerializableClosure.php
@@ -527,7 +532,8 @@ class ModelsCommand extends Command
$begin = strpos($code, 'function(');
$code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
foreach (array(
foreach (
array(
'hasMany' => '\Illuminate\Database\Eloquent\Relations\HasMany',
'hasManyThrough' => '\Illuminate\Database\Eloquent\Relations\HasManyThrough',
'hasOneThrough' => '\Illuminate\Database\Eloquent\Relations\HasOneThrough',
@@ -539,7 +545,8 @@ class ModelsCommand extends Command
'morphMany' => '\Illuminate\Database\Eloquent\Relations\MorphMany',
'morphToMany' => '\Illuminate\Database\Eloquent\Relations\MorphToMany',
'morphedByMany' => '\Illuminate\Database\Eloquent\Relations\MorphToMany'
) as $relation => $impl) {
) as $relation => $impl
) {
$search = '$this->' . $relation . '(';
if (stripos($code, $search) || ltrim($impl, '\\') === ltrim((string)$type, '\\')) {
//Resolve the relation's model to a Relation object.
@@ -662,7 +669,7 @@ class ModelsCommand extends Command
if ($type !== null) {
$newType = $this->getTypeOverride($type);
if ($nullable) {
$newType .='|null';
$newType .= '|null';
}
$this->properties[$name]['type'] = $newType;
}
@@ -865,7 +872,7 @@ class ModelsCommand extends Command
}
/** @var \Illuminate\Database\Eloquent\Model $model */
$model = new $className;
$model = new $className();
return '\\' . get_class($model->newCollection());
}