mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad7e37676f | ||
|
|
9027494e97 | ||
|
|
c3f795e909 | ||
|
|
2fba281b14 | ||
|
|
39bcb60b7c | ||
|
|
16f685aa9f |
@@ -1,4 +1,5 @@
|
||||
.phpunit.result.cache
|
||||
/auth.json
|
||||
/build
|
||||
/.idea
|
||||
/.php-cs-fixer.cache
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.5-dev"
|
||||
"dev-master": "3.6-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
|
||||
+1
-1
@@ -187,7 +187,7 @@ class Alias
|
||||
public function shouldExtendParentClass()
|
||||
{
|
||||
return $this->parentClass
|
||||
&& $this->getExtendsNamespace() !== '\\Illuminate\\Support\\Facades';
|
||||
&& !is_subclass_of($this->extends, Facade::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -195,6 +195,18 @@ class MetaCommand extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't throw when class existence is being checked via class_exists(),
|
||||
// interface_exists(), trait_exists(), or enum_exists(). These functions
|
||||
// expect the autoloader to return gracefully when the class doesn't exist.
|
||||
// Throwing here would break libraries that use class_exists() to check for
|
||||
// optional dependencies (e.g. Doctrine ORM checking for removed classes).
|
||||
$existsFunctions = ['class_exists', 'interface_exists', 'trait_exists', 'enum_exists'];
|
||||
foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3) as $frame) {
|
||||
if (isset($frame['function']) && in_array($frame['function'], $existsFunctions, true)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new \ReflectionException("Class '$class' not found.");
|
||||
};
|
||||
|
||||
|
||||
@@ -1206,7 +1206,7 @@ class ModelsCommand extends Command
|
||||
// declaration, insert the docblock before the first attribute so that
|
||||
// the resulting order is: docblock → attributes → class.
|
||||
$before = substr($contents, 0, $pos);
|
||||
if (preg_match('/(\s*(?:#\[.+?\]\s*)+)$/s', $before, $matches)) {
|
||||
if (preg_match('/((?:#\[.+?\]\s*)+)$/s', $before, $matches)) {
|
||||
$pos -= strlen($matches[1]);
|
||||
$replace = "{$modelDocComment}\n";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
// Tests: final class + attribute with nested array argument (e.g. ObservedBy([...]))
|
||||
#[ObservedByStub([StubObserver::class])]
|
||||
final class FinalWithNested extends Model
|
||||
{
|
||||
protected $table = 'simples';
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
// Tests: multiple consecutive PHP 8 attributes before the class declaration
|
||||
#[\AllowDynamicProperties]
|
||||
#[SecondAttribute]
|
||||
class MultipleAttributes extends Model
|
||||
{
|
||||
protected $table = 'simples';
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[\AllowDynamicProperties]
|
||||
class Simple extends Model
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass;
|
||||
|
||||
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||
|
||||
class Test extends AbstractModelsCommand
|
||||
{
|
||||
public function test(): void
|
||||
{
|
||||
$command = $this->app->make(ModelsCommand::class);
|
||||
|
||||
$tester = $this->runCommand($command, [
|
||||
'--write' => true,
|
||||
]);
|
||||
|
||||
$this->assertSame(0, $tester->getStatusCode());
|
||||
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
|
||||
$this->assertMatchesMockedSnapshot();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
// Tests: final class + attribute with nested array argument (e.g. ObservedBy([...]))
|
||||
/**
|
||||
* @property int $id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|FinalWithNested newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|FinalWithNested newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|FinalWithNested query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|FinalWithNested whereId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
#[ObservedByStub([StubObserver::class])]
|
||||
final class FinalWithNested extends Model
|
||||
{
|
||||
protected $table = 'simples';
|
||||
}
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
// Tests: multiple consecutive PHP 8 attributes before the class declaration
|
||||
/**
|
||||
* @property int $id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|MultipleAttributes newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|MultipleAttributes newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|MultipleAttributes query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|MultipleAttributes whereId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
#[SecondAttribute]
|
||||
class MultipleAttributes extends Model
|
||||
{
|
||||
protected $table = 'simples';
|
||||
}
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PhpAttributesBeforeClass\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple whereId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class Simple extends Model
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user