mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
chore: psr12 (#964)
This commit is contained in:
+2
-2
@@ -60,8 +60,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"analyze": "psalm",
|
||||
"check-style": "phpcs -p --standard=PSR2 src/",
|
||||
"fix-style": "phpcbf -p --standard=PSR2 src/",
|
||||
"check-style": "phpcs -p --standard=PSR12 src/",
|
||||
"fix-style": "phpcbf -p --standard=PSR12 src/",
|
||||
"test": "phpunit"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ grumphp:
|
||||
group: []
|
||||
always_execute: false
|
||||
phpcs:
|
||||
standard: PSR2
|
||||
standard: PSR12
|
||||
warning_severity: ~
|
||||
ignore_patterns:
|
||||
- tests/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator - Eloquent Model Mixin
|
||||
*
|
||||
|
||||
@@ -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)'
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator
|
||||
*
|
||||
@@ -109,7 +110,8 @@ 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(
|
||||
if (
|
||||
$this->confirm(
|
||||
"Do you want to overwrite the existing model files? Choose no to write to $filename instead"
|
||||
)
|
||||
) {
|
||||
@@ -455,7 +457,8 @@ class ModelsCommand extends Command
|
||||
if ($methods) {
|
||||
sort($methods);
|
||||
foreach ($methods as $method) {
|
||||
if (Str::startsWith($method, 'get') && Str::endsWith(
|
||||
if (
|
||||
Str::startsWith($method, 'get') && Str::endsWith(
|
||||
$method,
|
||||
'Attribute'
|
||||
) && $method !== 'getAttribute'
|
||||
@@ -468,7 +471,8 @@ class ModelsCommand extends Command
|
||||
$type = $this->getTypeInModel($model, $type);
|
||||
$this->setProperty($name, $type, true, null);
|
||||
}
|
||||
} elseif (Str::startsWith($method, 'set') && Str::endsWith(
|
||||
} elseif (
|
||||
Str::startsWith($method, 'set') && Str::endsWith(
|
||||
$method,
|
||||
'Attribute'
|
||||
) && $method !== 'setAttribute'
|
||||
@@ -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.
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* @author Charles A. Peterson <[email protected]>
|
||||
*/
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
+5
-2
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator
|
||||
*
|
||||
@@ -123,8 +124,10 @@ class Generator
|
||||
$this->interfaces['\Illuminate\Contracts\Auth\Authenticatable'] = $defaultUserModel;
|
||||
|
||||
try {
|
||||
if (class_exists('Auth') && is_a('Auth', '\Illuminate\Support\Facades\Auth', true)
|
||||
&& app()->bound('auth')) {
|
||||
if (
|
||||
class_exists('Auth') && is_a('Auth', '\Illuminate\Support\Facades\Auth', true)
|
||||
&& app()->bound('auth')
|
||||
) {
|
||||
if (class_exists('\Illuminate\Foundation\Application')) {
|
||||
$authMethod = version_compare(Application::VERSION, '5.2', '>=') ? 'guard' : 'driver';
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel IDE Helper Generator
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user