From 721a7cd3f7a1eb22f3cbc621a673df2ff4f72315 Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Sat, 2 Sep 2017 21:25:00 +0100 Subject: [PATCH 01/55] The 'artisan optimize' command is deprecated --- readme.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 25dcb11..fbdc6db 100644 --- a/readme.md +++ b/readme.md @@ -66,7 +66,7 @@ You can now re-generate the docs yourself (for future updates) php artisan ide-helper:generate ``` -Note: `bootstrap/compiled.php` has to be cleared first, so run `php artisan clear-compiled` before generating (and `php artisan optimize` after). +Note: `bootstrap/compiled.php` has to be cleared first, so run `php artisan clear-compiled` before generating. You can configure your composer.json to do this after each commit: @@ -75,8 +75,7 @@ You can configure your composer.json to do this after each commit: "post-update-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postUpdate", "php artisan ide-helper:generate", - "php artisan ide-helper:meta", - "php artisan optimize" + "php artisan ide-helper:meta" ] }, ``` From 6b0e9ec48d0406c7bfb9d63122a29002af96f669 Mon Sep 17 00:00:00 2001 From: Yulia Kostrikova Date: Thu, 21 Sep 2017 00:40:49 +0300 Subject: [PATCH 02/55] Add notice about "Package Auto-Discovery" to docs --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 25dcb11..edc5548 100644 --- a/readme.md +++ b/readme.md @@ -37,6 +37,7 @@ After updating composer, add the service provider to the `providers` array in `c ```php Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class, ``` +**Laravel 5.5** uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider. To install this package on only development systems, add the `--dev` flag to your composer command: From b0abafb8c783c371d256069e817e32ada162ae58 Mon Sep 17 00:00:00 2001 From: Mariusz Date: Wed, 11 Oct 2017 11:43:16 +0100 Subject: [PATCH 03/55] Changed overwriting confirmation message When running php artisan ide-helper:models below message was presented: "Do you want to overwrite the existing model files? Choose no to write to _ide_helper_models.php instead? (Yes/No): (yes/no) [no]:" This commit changes message to: "Do you want to overwrite the existing model files? Choose no to write to _ide_helper_models.php instead? (yes/no) [no]:" --- src/Console/ModelsCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 7359a84..7ed44a7 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -91,7 +91,7 @@ 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? (Yes/No): " + "Do you want to overwrite the existing model files? Choose no to write to $filename instead?" ) ) { $this->write = true; From d45b02efb1a76ce8924d8b23b819ed5d1564d5da Mon Sep 17 00:00:00 2001 From: Chris Morrell Date: Fri, 13 Oct 2017 11:41:30 -0400 Subject: [PATCH 04/55] Support for ::fake() calls --- src/Alias.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Alias.php b/src/Alias.php index 4902f80..cd0e852 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -53,6 +53,7 @@ class Alias } $this->addClass($this->root); + $this->detectFake(); $this->detectNamespace(); $this->detectClassType(); $this->detectExtendsNamespace(); @@ -167,6 +168,30 @@ class Alias return $this->methods; } + /** + * Detect class returned by ::fake() + */ + protected function detectFake() + { + $facade = $this->facade; + + if (!method_exists($facade, 'fake')) { + return; + } + + $real = $facade::getFacadeRoot(); + + try { + $facade::fake(); + $fake = $facade::getFacadeRoot(); + if ($fake !== $real) { + $this->addClass(get_class($fake)); + } + } finally { + $facade::swap($real); + } + } + /** * Detect the namespace */ From 76a1952c41b65ade39d564422d0f8a7da919cf6a Mon Sep 17 00:00:00 2001 From: Markus Fischer Date: Sat, 28 Oct 2017 18:01:18 +0200 Subject: [PATCH 05/55] Keep "null"-ness of column even with model casts A cast in Laravel should only affect the type, but not the database intrinsics whether a column accepts `null` or not. As an example, consider this table (Postgres syntax): ```sql CREATE TABLE foo ( some_column jsonb ); ``` This will be generated as: `@property string|null $some_column` When providing a the following casts on the model: ```php protected $casts = [ 'some_column' => 'array', ]; ``` then the generated property changes to: `@property array $some_column` However the DB still accepts `null`, but this can't be expressed via the casts. This change will make the null "sticky" and generate: `@property array|null $some_column` --- src/Console/ModelsCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 7359a84..47b6677 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -291,6 +291,10 @@ class ModelsCommand extends Command continue; } else { $this->properties[$name]['type'] = $this->getTypeOverride($realType); + + if (isset($this->nullableColumns[$name])) { + $this->properties[$name]['type'] .= '|null'; + } } } } From df6b1b6f8289322bb2b178178c9c74a6c2df3a72 Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 27 Dec 2017 17:17:00 -0500 Subject: [PATCH 06/55] Use Illuminate\Support\Carbon instead of Carbon\Carbon --- src/Console/ModelsCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 7359a84..cc35914 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -277,7 +277,7 @@ class ModelsCommand extends Command break; case 'date': case 'datetime': - $realType = '\Carbon\Carbon'; + $realType = '\Illuminate\Support\Carbon'; break; case 'collection': $realType = '\Illuminate\Support\Collection'; @@ -337,7 +337,7 @@ class ModelsCommand extends Command foreach ($columns as $column) { $name = $column->getName(); if (in_array($name, $model->getDates())) { - $type = '\Carbon\Carbon'; + $type = '\Illuminate\Support\Carbon'; } else { $type = $column->getType()->getName(); switch ($type) { From d65f1cedcdcb55511615b446aa99e07452d6a743 Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 27 Dec 2017 17:25:44 -0500 Subject: [PATCH 07/55] Use Illuminate\Support\Carbon instead of Carbon\Carbon in readme.md --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 25dcb11..3202d73 100644 --- a/readme.md +++ b/readme.md @@ -122,8 +122,8 @@ php artisan ide-helper:models Post * @property integer $author_id * @property string $title * @property string $text - * @property \Carbon\Carbon $created_at - * @property \Carbon\Carbon $updated_at + * @property \Illuminate\Support\Carbon $created_at + * @property \Illuminate\Support\Carbon $updated_at * @property-read \User $author * @property-read \Illuminate\Database\Eloquent\Collection|\Comment[] $comments */ From b6f525b3206f6dfba3b69e084bb114437be9f1ce Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 27 Dec 2017 17:26:16 -0500 Subject: [PATCH 08/55] Use Illuminate\Support\Carbon instead of Carbon\Carbon in config/ide-helper.php --- config/ide-helper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/ide-helper.php b/config/ide-helper.php index 48a06db..38013a2 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -153,13 +153,13 @@ return array( | | For example, normally you would see this: | - | * @property \Carbon\Carbon $created_at - | * @property \Carbon\Carbon $updated_at + | * @property \Illuminate\Support\Carbon $created_at + | * @property \Illuminate\Support\Carbon $updated_at | | With this enabled, the properties will be this: | - | * @property \Carbon\Carbon $createdAt - | * @property \Carbon\Carbon $updatedAt + | * @property \Illuminate\Support\Carbon $createdAt + | * @property \Illuminate\Support\Carbon $updatedAt | | Note, it is currently an all-or-nothing option. | From 7b067198a677e66147426763907e51fe6e11c735 Mon Sep 17 00:00:00 2001 From: Xiang Liu Date: Mon, 15 Jan 2018 12:44:44 +0800 Subject: [PATCH 09/55] Sort keys for generating stable .phpstorm.meta.php --- src/Console/MetaCommand.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Console/MetaCommand.php b/src/Console/MetaCommand.php index 13c9ed0..fe77e38 100644 --- a/src/Console/MetaCommand.php +++ b/src/Console/MetaCommand.php @@ -122,7 +122,11 @@ class MetaCommand extends Command $abstracts = $this->laravel->getBindings(); // Return the abstract names only - return array_keys($abstracts); + $keys = array_keys($abstracts); + + sort($keys); + + return $keys; } /** From 76bd86dbafef9bbfbcfa125b38c31f39088cde4b Mon Sep 17 00:00:00 2001 From: Sune Westphalen Date: Tue, 23 Jan 2018 13:56:22 +0700 Subject: [PATCH 10/55] Added Validator and Gate facades for Lumen. --- src/Generator.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Generator.php b/src/Generator.php index 1624fc5..2c7f2d1 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -209,14 +209,14 @@ class Generator if (array_key_exists($name, $this->extra)) { $alias->addClass($this->extra[$name]); } - + $aliases[] = $alias; } } return $aliases; } - + /** * Regroup aliases by namespace of extended classes * @@ -228,7 +228,7 @@ class Generator return $alias->getExtendsNamespace(); }); } - + /** * Regroup aliases by namespace of alias * @@ -265,7 +265,8 @@ class Generator 'Schema' => 'Illuminate\Support\Facades\Schema', 'Session' => 'Illuminate\Support\Facades\Session', 'Storage' => 'Illuminate\Support\Facades\Storage', - //'Validator' => 'Illuminate\Support\Facades\Validator', + 'Validator' => 'Illuminate\Support\Facades\Validator', + 'Gate' => 'Illuminate\Support\Facades\Gate', ]; $facades = array_merge($facades, $this->config->get('app.aliases', [])); From 7b2786ac2b9e1120fade8d76751ea4b2b2307c34 Mon Sep 17 00:00:00 2001 From: Jurrien Dokter Date: Sat, 27 Jan 2018 13:01:07 +0100 Subject: [PATCH 11/55] Fixing issue #253 --- src/Console/ModelsCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 7359a84..5870a55 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -182,7 +182,7 @@ class ModelsCommand extends Command $reflectionClass = new \ReflectionClass($name); if (!$reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Model') - || $reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Relations\Pivot')) { + || !$reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Relations\Pivot')) { continue; } From e29e0351355684ad51d1358b3be6cace4213d11f Mon Sep 17 00:00:00 2001 From: Jonas De Smet Date: Thu, 1 Feb 2018 15:53:32 +0100 Subject: [PATCH 12/55] Add DocBlocks for classes too --- resources/views/helper.php | 1 + src/Alias.php | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/resources/views/helper.php b/resources/views/helper.php index a41a8d9..8bfbfb6 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -15,6 +15,7 @@ namespace { + getDocComment(' ')) ?> getClassType() ?> getExtendsClass() ?> { getMethods() as $method): ?> diff --git a/src/Alias.php b/src/Alias.php index 4902f80..12d23cc 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -10,6 +10,11 @@ namespace Barryvdh\LaravelIdeHelper; +use Barryvdh\Reflection\DocBlock; +use Barryvdh\Reflection\DocBlock\Context; +use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer; +use ReflectionClass; + class Alias { protected $alias; @@ -27,6 +32,7 @@ class Alias protected $valid = false; protected $magicMethods = array(); protected $interfaces = array(); + protected $phpdoc = null; /** * @param string $alias @@ -56,7 +62,13 @@ class Alias $this->detectNamespace(); $this->detectClassType(); $this->detectExtendsNamespace(); - + + if(!empty($this->namespace)) { + //Create a DocBlock and serializer instance + $this->phpdoc = new DocBlock(new ReflectionClass($alias), new Context($this->namespace)); + } + + if ($facade === '\Illuminate\Database\Eloquent\Model') { $this->usedMethods = array('decrement', 'increment'); } @@ -333,6 +345,18 @@ class Alias } } + /** + * Get the docblock for this alias + * + * @param string $prefix + * @return mixed + */ + public function getDocComment($prefix = "\t\t") + { + $serializer = new DocBlockSerializer(1, $prefix); + return ($this->phpdoc) ? $serializer->getDocComment($this->phpdoc) : ''; + } + /** * Output an error. * From 8ab907f219579677f622f30ea0ac21b8d628398e Mon Sep 17 00:00:00 2001 From: Ezra Pool Date: Fri, 2 Feb 2018 10:37:47 +0100 Subject: [PATCH 13/55] Support php's array callable format for macro's. This allows you to define methods like this as well: Str::macro('name', [$this, 'method']); --- src/Alias.php | 18 ++++++++++++++++-- src/Macro.php | 11 ++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/Alias.php b/src/Alias.php index 4902f80..171f373 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -319,10 +319,9 @@ class Alias $properties = $reflection->getStaticProperties(); $macros = isset($properties['macros']) ? $properties['macros'] : []; foreach ($macros as $macro_name => $macro_func) { - $function = new \ReflectionFunction($macro_func); // Add macros $this->methods[] = new Macro( - $function, + $this->getMacroFunction($macro_func), $this->alias, $reflection, $macro_name, @@ -333,6 +332,21 @@ class Alias } } + /** + * @param $macro_func + * + * @return \ReflectionFunctionAbstract + * @throws \ReflectionException + */ + protected function getMacroFunction($macro_func) + { + if (is_array($macro_func) && is_callable($macro_func)) { + return new \ReflectionMethod($macro_func[0], $macro_func[1]); + } + + return new \ReflectionFunction($macro_func); + } + /** * Output an error. * diff --git a/src/Macro.php b/src/Macro.php index 521a3f0..2d6081e 100644 --- a/src/Macro.php +++ b/src/Macro.php @@ -10,14 +10,19 @@ class Macro extends Method /** * Macro constructor. * - * @param \ReflectionFunction $method + * @param \ReflectionFunctionAbstract $method * @param string $alias * @param \ReflectionClass $class * @param null $methodName * @param array $interfaces */ - public function __construct(\ReflectionFunction $method, $alias, $class, $methodName = null, $interfaces = array()) - { + public function __construct( + \ReflectionFunctionAbstract $method, + $alias, + $class, + $methodName = null, + $interfaces = array() + ) { $this->method = $method; $this->interfaces = $interfaces; $this->name = $methodName ?: $method->name; From 387efb9b42b90f4380d773362972b619f6ba9b58 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 7 Feb 2018 09:31:35 +0100 Subject: [PATCH 14/55] Allow L5.6 --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 1af907b..49b35c1 100644 --- a/composer.json +++ b/composer.json @@ -11,15 +11,15 @@ ], "require": { "php": ">=5.4.0", - "illuminate/support": "^5.0,<5.6", - "illuminate/console": "^5.0,<5.6", - "illuminate/filesystem": "^5.0,<5.6", + "illuminate/support": "^5.0,<5.7", + "illuminate/console": "^5.0,<5.7", + "illuminate/filesystem": "^5.0,<5.7", "barryvdh/reflection-docblock": "^2.0.4", "symfony/class-loader": "^2.3|^3.0" }, "require-dev": { - "illuminate/config": "^5.0,<5.6", - "illuminate/view": "^5.0,<5.6", + "illuminate/config": "^5.0,<5.7", + "illuminate/view": "^5.0,<5.7", "phpunit/phpunit" : "4.*", "scrutinizer/ocular": "~1.1", "squizlabs/php_codesniffer": "~2.3", From ea113e8c0bd915aad961dc9999fdce7f58e486bf Mon Sep 17 00:00:00 2001 From: Patrick <943484+iPaat@users.noreply.github.com> Date: Wed, 7 Feb 2018 13:17:03 +0100 Subject: [PATCH 15/55] Fixes a bug where a missing DocBlock caused errors --- src/Eloquent.php | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/src/Eloquent.php b/src/Eloquent.php index c27b1c1..9e5e2bc 100644 --- a/src/Eloquent.php +++ b/src/Eloquent.php @@ -32,27 +32,57 @@ class Eloquent $reflection = new \ReflectionClass($class); $namespace = $reflection->getNamespaceName(); $originalDoc = $reflection->getDocComment(); + if (!$originalDoc) { $command->info('Unexpected no document on ' . $class); } $phpdoc = new DocBlock($reflection, new Context($namespace)); $mixins = $phpdoc->getTagsByName('mixin'); - foreach ($mixins as $m) { - if ($m->getContent() === '\Eloquent') { - $command->info('Tag Exists: @mixin \Eloquent in ' . $class); + $expectedMixins = [ + '\Eloquent' => false, + '\Illuminate\Database\Eloquent\Builder' => false, + '\Illuminate\Database\Query\Builder' => false, + ]; - return; + foreach ($mixins as $m) { + $mixin = $m->getContent(); + + if(isset($expectedMixins[$mixin])) { + $command->info('Tag Exists: @mixin ' . $mixin . ' in ' . $class); + + $expectedMixins[$mixin] = true; } } - // add the Eloquent mixin - $phpdoc->appendTag(Tag::createInstance("@mixin \\Eloquent", $phpdoc)); + $changed = false; + foreach($expectedMixins as $expectedMixin => $present) { + if($present === false) { + $phpdoc->appendTag(Tag::createInstance('@mixin ' . $expectedMixin, $phpdoc)); + + $changed = true; + } + } + + // If nothing's changed, stop here. + if(!$changed) { + return; + } $serializer = new DocBlockSerializer(); $serializer->getDocComment($phpdoc); $docComment = $serializer->getDocComment($phpdoc); + /* + The new DocBlock is appended to the beginning of the class declaration. + Since there is no DocBlock, the declaration is used as a guide. + */ + if (!$originalDoc) { + $originalDoc = 'abstract class Model implements'; + + $docComment .= "\nabstract class Model implements"; + } + $filename = $reflection->getFileName(); if ($filename) { $contents = $files->get($filename); @@ -61,7 +91,7 @@ class Eloquent $contents = str_replace($originalDoc, $docComment, $contents, $count); if ($count > 0) { if ($files->put($filename, $contents)) { - $command->info('Wrote @mixin \Eloquent to ' . $filename); + $command->info('Wrote expected docblock to ' . $filename); } else { $command->error('File write failed to ' . $filename); } From 1fc4284af6dec64e978e61c3117036d008836c23 Mon Sep 17 00:00:00 2001 From: Patrick <943484+iPaat@users.noreply.github.com> Date: Wed, 7 Feb 2018 13:24:36 +0100 Subject: [PATCH 16/55] Fixes for Travis. --- src/Eloquent.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Eloquent.php b/src/Eloquent.php index 9e5e2bc..d84435d 100644 --- a/src/Eloquent.php +++ b/src/Eloquent.php @@ -48,7 +48,7 @@ class Eloquent foreach ($mixins as $m) { $mixin = $m->getContent(); - if(isset($expectedMixins[$mixin])) { + if (isset($expectedMixins[$mixin])) { $command->info('Tag Exists: @mixin ' . $mixin . ' in ' . $class); $expectedMixins[$mixin] = true; @@ -56,8 +56,8 @@ class Eloquent } $changed = false; - foreach($expectedMixins as $expectedMixin => $present) { - if($present === false) { + foreach ($expectedMixins as $expectedMixin => $present) { + if ($present === false) { $phpdoc->appendTag(Tag::createInstance('@mixin ' . $expectedMixin, $phpdoc)); $changed = true; @@ -65,7 +65,7 @@ class Eloquent } // If nothing's changed, stop here. - if(!$changed) { + if (!$changed) { return; } From 2d56afce8e6dc9b495f092fa3029f8d75f8f05d6 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 8 Feb 2018 17:00:48 +0100 Subject: [PATCH 17/55] Revert "Fixes a bug where a missing DocBlock caused errors" --- src/Eloquent.php | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/src/Eloquent.php b/src/Eloquent.php index d84435d..c27b1c1 100644 --- a/src/Eloquent.php +++ b/src/Eloquent.php @@ -32,57 +32,27 @@ class Eloquent $reflection = new \ReflectionClass($class); $namespace = $reflection->getNamespaceName(); $originalDoc = $reflection->getDocComment(); - if (!$originalDoc) { $command->info('Unexpected no document on ' . $class); } $phpdoc = new DocBlock($reflection, new Context($namespace)); $mixins = $phpdoc->getTagsByName('mixin'); - $expectedMixins = [ - '\Eloquent' => false, - '\Illuminate\Database\Eloquent\Builder' => false, - '\Illuminate\Database\Query\Builder' => false, - ]; - foreach ($mixins as $m) { - $mixin = $m->getContent(); + if ($m->getContent() === '\Eloquent') { + $command->info('Tag Exists: @mixin \Eloquent in ' . $class); - if (isset($expectedMixins[$mixin])) { - $command->info('Tag Exists: @mixin ' . $mixin . ' in ' . $class); - - $expectedMixins[$mixin] = true; + return; } } - $changed = false; - foreach ($expectedMixins as $expectedMixin => $present) { - if ($present === false) { - $phpdoc->appendTag(Tag::createInstance('@mixin ' . $expectedMixin, $phpdoc)); - - $changed = true; - } - } - - // If nothing's changed, stop here. - if (!$changed) { - return; - } + // add the Eloquent mixin + $phpdoc->appendTag(Tag::createInstance("@mixin \\Eloquent", $phpdoc)); $serializer = new DocBlockSerializer(); $serializer->getDocComment($phpdoc); $docComment = $serializer->getDocComment($phpdoc); - /* - The new DocBlock is appended to the beginning of the class declaration. - Since there is no DocBlock, the declaration is used as a guide. - */ - if (!$originalDoc) { - $originalDoc = 'abstract class Model implements'; - - $docComment .= "\nabstract class Model implements"; - } - $filename = $reflection->getFileName(); if ($filename) { $contents = $files->get($filename); @@ -91,7 +61,7 @@ class Eloquent $contents = str_replace($originalDoc, $docComment, $contents, $count); if ($count > 0) { if ($files->put($filename, $contents)) { - $command->info('Wrote expected docblock to ' . $filename); + $command->info('Wrote @mixin \Eloquent to ' . $filename); } else { $command->error('File write failed to ' . $filename); } From 8852b1ca9d2d0df39c3c97fb9f49fd5d0939b736 Mon Sep 17 00:00:00 2001 From: Steve Guns Date: Sun, 11 Feb 2018 19:09:33 +0100 Subject: [PATCH 18/55] Added "smart-reset": Reset properties/methods, but keep the docBlock text, if any --- src/Console/ModelsCommand.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 7359a84..ee56810 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -56,6 +56,7 @@ class ModelsCommand extends Command protected $write = false; protected $dirs = array(); protected $reset; + protected $keep_text; /** * @var bool[string] */ @@ -86,6 +87,9 @@ class ModelsCommand extends Command $model = $this->argument('model'); $ignore = $this->option('ignore'); $this->reset = $this->option('reset'); + if ($this->option('smart-reset')) { + $this->keep_text = $this->reset = true; + } $this->write_model_magic_where = $this->laravel['config']->get('ide-helper.write_model_magic_where', true); //If filename is default and Write is not specified, ask what to do @@ -136,6 +140,7 @@ class ModelsCommand extends Command array('write', 'W', InputOption::VALUE_NONE, 'Write to Model file'), array('nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'), array('reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'), + array('smart-reset', 'r', InputOption::VALUE_NONE, 'Remove the original phpdocs properties/methods, but keep the text'), array('ignore', 'I', InputOption::VALUE_OPTIONAL, 'Which models to ignore', ''), ); } @@ -582,6 +587,11 @@ class ModelsCommand extends Command if ($this->reset) { $phpdoc = new DocBlock('', new Context($namespace)); + if ($this->keep_text) { + $phpdoc->setText( + (new DocBlock($reflection, new Context($namespace)))->getText() + ); + } } else { $phpdoc = new DocBlock($reflection, new Context($namespace)); } From d961482d2229d6bf4c3418ab8fd46e35837357ef Mon Sep 17 00:00:00 2001 From: Steve Guns Date: Wed, 14 Feb 2018 08:59:19 +0100 Subject: [PATCH 19/55] Fixed PHPCS PSR2 issues --- src/Alias.php | 8 ++++---- src/Console/ModelsCommand.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Alias.php b/src/Alias.php index 12d23cc..af4c1bf 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -63,7 +63,7 @@ class Alias $this->detectClassType(); $this->detectExtendsNamespace(); - if(!empty($this->namespace)) { + if (!empty($this->namespace)) { //Create a DocBlock and serializer instance $this->phpdoc = new DocBlock(new ReflectionClass($alias), new Context($this->namespace)); } @@ -119,7 +119,7 @@ class Alias { return $this->extends; } - + /** * Get the class short name which this alias extends * @@ -129,7 +129,7 @@ class Alias { return $this->extendsClass; } - + /** * Get the namespace of the class which this alias extends * @@ -192,7 +192,7 @@ class Alias $this->short = $this->alias; } } - + /** * Detect the extends namespace */ diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index ee56810..9ef1973 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -140,7 +140,7 @@ class ModelsCommand extends Command array('write', 'W', InputOption::VALUE_NONE, 'Write to Model file'), array('nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'), array('reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'), - array('smart-reset', 'r', InputOption::VALUE_NONE, 'Remove the original phpdocs properties/methods, but keep the text'), + array('smart-reset', 'r', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'), array('ignore', 'I', InputOption::VALUE_OPTIONAL, 'Which models to ignore', ''), ); } From bda5120e9a942ee0de7867d0516d0378ea5bdcd7 Mon Sep 17 00:00:00 2001 From: Jeppe Knockaert Date: Wed, 14 Feb 2018 12:06:34 +0100 Subject: [PATCH 20/55] Add morphedByMany relationship --- src/Console/ModelsCommand.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 7359a84..4b7aa5b 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -460,7 +460,8 @@ class ModelsCommand extends Command 'morphOne', 'morphTo', 'morphMany', - 'morphToMany' + 'morphToMany', + 'morphedByMany' ) as $relation) { $search = '$this->' . $relation . '('; if ($pos = stripos($code, $search)) { @@ -470,7 +471,7 @@ class ModelsCommand extends Command if ($relationObj instanceof Relation) { $relatedModel = '\\' . get_class($relationObj->getRelated()); - $relations = ['hasManyThrough', 'belongsToMany', 'hasMany', 'morphMany', 'morphToMany']; + $relations = ['hasManyThrough', 'belongsToMany', 'hasMany', 'morphMany', 'morphToMany', 'morphedByMany']; if (in_array($relation, $relations)) { //Collection or array of models (because Collection is Arrayable) $this->setProperty( From 17982029f06cb229829332599148dc792b4fb7b7 Mon Sep 17 00:00:00 2001 From: Jeppe Knockaert Date: Wed, 14 Feb 2018 12:15:38 +0100 Subject: [PATCH 21/55] Move long one-line array to multiple lines --- src/Console/ModelsCommand.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 4b7aa5b..91f9886 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -471,7 +471,14 @@ class ModelsCommand extends Command if ($relationObj instanceof Relation) { $relatedModel = '\\' . get_class($relationObj->getRelated()); - $relations = ['hasManyThrough', 'belongsToMany', 'hasMany', 'morphMany', 'morphToMany', 'morphedByMany']; + $relations = [ + 'hasManyThrough', + 'belongsToMany', + 'hasMany', + 'morphMany', + 'morphToMany', + 'morphedByMany', + ]; if (in_array($relation, $relations)) { //Collection or array of models (because Collection is Arrayable) $this->setProperty( From c7b7ebf1b578c57a437bb586a3059674e99c6e85 Mon Sep 17 00:00:00 2001 From: Jackey Cheung Date: Wed, 21 Mar 2018 11:36:02 +0800 Subject: [PATCH 22/55] suppress PHPStorm formatter --- src/Console/ModelsCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 7359a84..7a79083 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -145,6 +145,7 @@ class ModelsCommand extends Command $output = " Date: Thu, 3 May 2018 16:02:16 -0400 Subject: [PATCH 23/55] Remove dependecy to Symfony\Component\ClassLoader\ClassMapGenerator and replace it with Composer\Autoload\ClassMapGenerator. --- composer.json | 2 +- src/Console/ModelsCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 49b35c1..cfaedee 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "illuminate/console": "^5.0,<5.7", "illuminate/filesystem": "^5.0,<5.7", "barryvdh/reflection-docblock": "^2.0.4", - "symfony/class-loader": "^2.3|^3.0" + "composer/composer": "^1.6", }, "require-dev": { "illuminate/config": "^5.0,<5.7", diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 7359a84..71c08d3 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -10,6 +10,7 @@ namespace Barryvdh\LaravelIdeHelper\Console; +use Composer\Autoload\ClassMapGenerator; use Illuminate\Console\Command; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Support\Str; @@ -17,7 +18,6 @@ use Illuminate\Filesystem\Filesystem; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\ClassLoader\ClassMapGenerator; use Barryvdh\Reflection\DocBlock; use Barryvdh\Reflection\DocBlock\Context; use Barryvdh\Reflection\DocBlock\Tag; From 4691bc5fbdcebc6a1ae0fe865292ccf654be6b00 Mon Sep 17 00:00:00 2001 From: Timur Zurbaev Date: Sat, 5 May 2018 10:09:30 +0800 Subject: [PATCH 24/55] Remove `mixed` typehint from `Fluent::default` method --- resources/views/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/helper.php b/resources/views/helper.php index 8bfbfb6..e517a60 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -72,7 +72,7 @@ namespace Illuminate\Support { * @method Fluent charset(string $charset) Add the character set modifier * @method Fluent collation(string $collation) Add the collation modifier * @method Fluent comment(string $comment) Add comment - * @method Fluent default(mixed $value) Add the default modifier + * @method Fluent default($value) Add the default modifier * @method Fluent first() Select first row * @method Fluent index(string $name = null) Add the in dex clause * @method Fluent on(string $table) `on` of a foreign key From 265f00c322ece573fb3aab8f731039c68a3bca97 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 11:20:53 +0200 Subject: [PATCH 25/55] Update LICENSE.md --- LICENSE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 9c4b8a2..c0ffe02 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # The MIT License (MIT) -Copyright (c) 2016 Barry vd. Heuvel +Copyright (c) Barry vd. Heuvel > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ Copyright (c) 2016 Barry vd. Heuvel > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. \ No newline at end of file +> THE SOFTWARE. From 1b70277203f98ad47700b570a5b51aaa7d4bb8b6 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 11:25:19 +0200 Subject: [PATCH 26/55] Typo --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cfaedee..ed7f329 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "illuminate/console": "^5.0,<5.7", "illuminate/filesystem": "^5.0,<5.7", "barryvdh/reflection-docblock": "^2.0.4", - "composer/composer": "^1.6", + "composer/composer": "^1.6" }, "require-dev": { "illuminate/config": "^5.0,<5.7", From 50ecd8b8151f6a9124d495d290597ec6b181c766 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 11:38:57 +0200 Subject: [PATCH 27/55] Update CS, typo --- composer.json | 8 +++++--- grumphp.yml | 15 +++++++++++++++ src/Alias.php | 10 ++++++++-- src/Console/ModelsCommand.php | 2 +- 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 grumphp.yml diff --git a/composer.json b/composer.json index ed7f329..ceab9f4 100644 --- a/composer.json +++ b/composer.json @@ -20,9 +20,10 @@ "require-dev": { "illuminate/config": "^5.0,<5.7", "illuminate/view": "^5.0,<5.7", + "phpro/grumphp": "^0.14", "phpunit/phpunit" : "4.*", "scrutinizer/ocular": "~1.1", - "squizlabs/php_codesniffer": "~2.3", + "squizlabs/php_codesniffer": "^3", "doctrine/dbal": "~2.3" }, "suggest": { @@ -35,12 +36,13 @@ }, "autoload-dev": { "psr-4": { - ":vendor\\:package_name\\": "tests" + "Barryvdh\\LaravelIdeHelper\\": "tests" } }, "scripts": { "test": "phpunit", - "cs": "phpcs --standard=psr2 src/" + "check-style": "phpcs -p --standard=PSR2 src/", + "fix-style": "phpcbf -p --standard=PSR2 src/" }, "extra": { "branch-alias": { diff --git a/grumphp.yml b/grumphp.yml new file mode 100644 index 0000000..4b767a0 --- /dev/null +++ b/grumphp.yml @@ -0,0 +1,15 @@ +parameters: + git_dir: . + bin_dir: vendor/bin + tasks: + phpunit: + config_file: ~ + testsuite: ~ + group: [] + always_execute: false + phpcs: + standard: PSR2 + warning_severity: ~ + ignore_patterns: + - tests/ + triggered_by: [php] \ No newline at end of file diff --git a/src/Alias.php b/src/Alias.php index 3c6be30..a7c5b70 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -383,7 +383,8 @@ class Alias return new \ReflectionFunction($macro_func); } - + + /* * Get the docblock for this alias * * @param string $prefix @@ -392,7 +393,12 @@ class Alias public function getDocComment($prefix = "\t\t") { $serializer = new DocBlockSerializer(1, $prefix); - return ($this->phpdoc) ? $serializer->getDocComment($this->phpdoc) : ''; + + if ($this->phpdoc) { + return $serializer->getDocComment($this->phpdoc); + } + + return ''; } /** diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index c5c1f70..7edc282 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -300,7 +300,7 @@ class ModelsCommand extends Command if (isset($this->nullableColumns[$name])) { $this->properties[$name]['type'] .= '|null'; - } + } } } } From 930d258cd46f21203a9d4ab84715da4b7f31ed4e Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 11:48:47 +0200 Subject: [PATCH 28/55] Update composer.json --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index ceab9f4..e127d32 100644 --- a/composer.json +++ b/composer.json @@ -10,16 +10,16 @@ } ], "require": { - "php": ">=5.4.0", - "illuminate/support": "^5.0,<5.7", - "illuminate/console": "^5.0,<5.7", - "illuminate/filesystem": "^5.0,<5.7", + "php": ">=5.6.0", + "illuminate/support": "^5.1,<5.7", + "illuminate/console": "^5.1,<5.7", + "illuminate/filesystem": "^5.1,<5.7", "barryvdh/reflection-docblock": "^2.0.4", "composer/composer": "^1.6" }, "require-dev": { - "illuminate/config": "^5.0,<5.7", - "illuminate/view": "^5.0,<5.7", + "illuminate/config": "^5.1,<5.7", + "illuminate/view": "^5.1,<5.7", "phpro/grumphp": "^0.14", "phpunit/phpunit" : "4.*", "scrutinizer/ocular": "~1.1", From 930e5bd3019fdd1784c609c98f31dc10e6c00305 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 11:49:06 +0200 Subject: [PATCH 29/55] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e127d32..85f2d48 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ }, "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "2.5-dev" }, "laravel": { "providers": [ From cbacb28f19a9cd5ff12988ac599f74718fd47691 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 11:55:44 +0200 Subject: [PATCH 30/55] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3b741ba..c6ad38f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,10 @@ language: php php: - - 5.5 - 5.6 - 7.0 - 7.1 + - 7.2 # This triggers builds to run on the new TravisCI infrastructure. # See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ From d2f29d997b459666f894320c7b388395103379cc Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 11:56:03 +0200 Subject: [PATCH 31/55] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c6ad38f..d3960e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ cache: matrix: include: - - php: 5.5 + - php: 5.6 env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"' before_script: From 83852e9de00adf0f5f73e38316d23b762db91c89 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 12:41:54 +0200 Subject: [PATCH 32/55] Update .travis.yml --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d3960e1..2871fdc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,3 @@ before_script: script: - vendor/bin/phpcs --standard=psr2 src/ - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover; fi From a665961fb9afa3604f31cf5352cfa8a7e89cee6a Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 12:56:29 +0200 Subject: [PATCH 33/55] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2871fdc..c19c4fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,4 +25,4 @@ before_script: script: - vendor/bin/phpcs --standard=psr2 src/ - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + - vendor/bin/phpunit From b02a0bc6c91bb89d0b474733210ba73dcffda48c Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 7 May 2018 13:03:54 +0200 Subject: [PATCH 34/55] Update phpunit.xml.dist --- phpunit.xml.dist | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e6f4d37..edcb9d7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,7 @@ processIsolation="false" stopOnFailure="false"> - + tests @@ -19,11 +19,4 @@ src/ - - - - - - - - \ No newline at end of file + From ba28841870d3ab61f773cc527cadb824d8fa563a Mon Sep 17 00:00:00 2001 From: Huy Dang Date: Tue, 22 May 2018 13:26:27 +0700 Subject: [PATCH 35/55] fix case relation method has parameter --- src/Console/ModelsCommand.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index ad575ca..c6ace3d 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -476,6 +476,11 @@ class ModelsCommand extends Command $search = '$this->' . $relation . '('; if ($pos = stripos($code, $search)) { //Resolve the relation's model to a Relation object. + $methodReflection = new \ReflectionMethod($model, $method); + if ($methodReflection->getNumberOfParameters()) { + return; + } + $relationObj = $model->$method(); if ($relationObj instanceof Relation) { From 93630fdf6239555f730884c68cebc76930183928 Mon Sep 17 00:00:00 2001 From: Jeppe Knockaert Date: Thu, 24 May 2018 11:41:22 +0200 Subject: [PATCH 36/55] Only skip non-models when generating docs The fix made in PR https://github.com/barryvdh/laravel-ide-helper/pull/614 for issue https://github.com/barryvdh/laravel-ide-helper/issues/253 was incorrect as it resulted in comments no longer being generated for Models that are not Pivot Rlations. This PR allow comments to be generated for both Pivot Models (as they are a subclass of Eloquent\Model) and normal Models. --- src/Console/ModelsCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index c6ace3d..0f8e97c 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -187,8 +187,7 @@ class ModelsCommand extends Command // handle abstract classes, interfaces, ... $reflectionClass = new \ReflectionClass($name); - if (!$reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Model') - || !$reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Relations\Pivot')) { + if (!$reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Model')) { continue; } From 1a3d32f0d1bcd4aa21063e1680c6042d0e6b055b Mon Sep 17 00:00:00 2001 From: BinotaLIU Date: Tue, 29 May 2018 22:28:49 +0800 Subject: [PATCH 37/55] nullable actually support an argument --- resources/views/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/helper.php b/resources/views/helper.php index e517a60..edc3daf 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -80,7 +80,7 @@ namespace Illuminate\Support { * @method Fluent onUpdate(string $action) `on update` of a foreign key * @method Fluent primary() Add the primary key modifier * @method Fluent references(string $column) `references` of a foreign key - * @method Fluent nullable() Add the nullable modifier + * @method Fluent nullable(bool $value = true) Add the nullable modifier * @method Fluent unique(string $name = null) Add unique index clause * @method Fluent unsigned() Add the unsigned modifier * @method Fluent useCurrent() Add the default timestamp value From 217b8989c215caa71c62da2705fcd023d68520d5 Mon Sep 17 00:00:00 2001 From: Jan Alfred Richter Date: Thu, 31 May 2018 15:39:22 +1200 Subject: [PATCH 38/55] Added support for abstract/final models. --- src/Console/ModelsCommand.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 0f8e97c..20edfc7 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -15,6 +15,7 @@ use Illuminate\Console\Command; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Support\Str; use Illuminate\Filesystem\Filesystem; +use ReflectionClass; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; @@ -185,7 +186,7 @@ class ModelsCommand extends Command if (class_exists($name)) { try { // handle abstract classes, interfaces, ... - $reflectionClass = new \ReflectionClass($name); + $reflectionClass = new ReflectionClass($name); if (!$reflectionClass->isSubclassOf('Illuminate\Database\Eloquent\Model')) { continue; @@ -597,10 +598,11 @@ class ModelsCommand extends Command protected function createPhpDocs($class) { - $reflection = new \ReflectionClass($class); + $reflection = new ReflectionClass($class); $namespace = $reflection->getNamespaceName(); $classname = $reflection->getShortName(); $originalDoc = $reflection->getDocComment(); + $keyword = $this->getClassKeyword($reflection); if ($this->reset) { $phpdoc = new DocBlock('', new Context($namespace)); @@ -688,7 +690,7 @@ class ModelsCommand extends Command } } - $output = "namespace {$namespace}{\n{$docComment}\n\tclass {$classname} extends \Eloquent {}\n}\n\n"; + $output = "namespace {$namespace}{\n{$docComment}\n\t{$keyword}class {$classname} extends \Eloquent {}\n}\n\n"; return $output; } @@ -791,4 +793,21 @@ class ModelsCommand extends Command $this->setMethod('onlyTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []); } } + + /** + * @param ReflectionClass $reflection + * @return string + */ + private function getClassKeyword(ReflectionClass $reflection) + { + if ($reflection->isFinal()) { + $keyword = 'final '; + } elseif ($reflection->isAbstract()) { + $keyword = 'abstract '; + } else { + $keyword = ''; + } + + return $keyword; + } } From 6c7bc371f9e91483828804d7446be232d111b2dc Mon Sep 17 00:00:00 2001 From: Jackey Cheung Date: Wed, 13 Jun 2018 10:21:51 +0800 Subject: [PATCH 39/55] suppress formatter in meta file --- resources/views/meta.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/meta.php b/resources/views/meta.php index 38ef3a6..5c4ab2a 100644 --- a/resources/views/meta.php +++ b/resources/views/meta.php @@ -1,4 +1,5 @@ +//@formatter:off namespace PHPSTORM_META { From 6577af8464451b437fcf30e5974b5bd30da02fec Mon Sep 17 00:00:00 2001 From: Jackey Cheung Date: Wed, 13 Jun 2018 10:24:58 +0800 Subject: [PATCH 40/55] suppress formatter in helper file --- resources/views/helper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/helper.php b/resources/views/helper.php index edc3daf..0e78441 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -1,4 +1,5 @@ +//@formatter:off /** * A helper file for Laravel 5, to provide autocomplete information to your IDE From e1d1352ac534f63536527f126e279bb277a8bbf2 Mon Sep 17 00:00:00 2001 From: Jonas De Smet Date: Tue, 19 Jun 2018 14:59:59 +0200 Subject: [PATCH 41/55] bugfix - Space/Enter between starting php tag and comment for PHPStan --- resources/views/helper.php | 3 ++- resources/views/meta.php | 3 ++- src/Console/ModelsCommand.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/views/helper.php b/resources/views/helper.php index 0e78441..1ea9e0f 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -1,5 +1,6 @@ -//@formatter:off + +// @formatter:off /** * A helper file for Laravel 5, to provide autocomplete information to your IDE diff --git a/resources/views/meta.php b/resources/views/meta.php index 5c4ab2a..df53ebd 100644 --- a/resources/views/meta.php +++ b/resources/views/meta.php @@ -1,5 +1,6 @@ -//@formatter:off + +// @formatter:off namespace PHPSTORM_META { diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 20edfc7..d3fdfd8 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -151,7 +151,8 @@ class ModelsCommand extends Command $output = " Date: Thu, 5 Jul 2018 19:29:28 +0800 Subject: [PATCH 42/55] add change modifier --- resources/views/helper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/helper.php b/resources/views/helper.php index 1ea9e0f..dee6278 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -86,6 +86,7 @@ namespace Illuminate\Support { * @method Fluent unique(string $name = null) Add unique index clause * @method Fluent unsigned() Add the unsigned modifier * @method Fluent useCurrent() Add the default timestamp value + * @method Fluent change() Add the change modifier */ class Fluent {} } From d55b48476e818dbd4bd5cf4337e5fe4b6fe416ee Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 15 Aug 2018 09:57:53 +0200 Subject: [PATCH 43/55] Laravel 5.7 support Added Laravel 5.7 support --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 85f2d48..a284376 100644 --- a/composer.json +++ b/composer.json @@ -11,15 +11,15 @@ ], "require": { "php": ">=5.6.0", - "illuminate/support": "^5.1,<5.7", - "illuminate/console": "^5.1,<5.7", - "illuminate/filesystem": "^5.1,<5.7", + "illuminate/support": "^5.1,<5.8", + "illuminate/console": "^5.1,<5.8", + "illuminate/filesystem": "^5.1,<5.8", "barryvdh/reflection-docblock": "^2.0.4", "composer/composer": "^1.6" }, "require-dev": { - "illuminate/config": "^5.1,<5.7", - "illuminate/view": "^5.1,<5.7", + "illuminate/config": "^5.1,<5.8", + "illuminate/view": "^5.1,<5.8", "phpro/grumphp": "^0.14", "phpunit/phpunit" : "4.*", "scrutinizer/ocular": "~1.1", From 09db8c9a76711e98c61af0795934fb15955223fb Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 31 Aug 2018 15:28:09 +0200 Subject: [PATCH 44/55] Update composer.json --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index a284376..6102959 100644 --- a/composer.json +++ b/composer.json @@ -10,10 +10,10 @@ } ], "require": { - "php": ">=5.6.0", - "illuminate/support": "^5.1,<5.8", - "illuminate/console": "^5.1,<5.8", - "illuminate/filesystem": "^5.1,<5.8", + "php": ">=7", + "illuminate/support": "^5.5,<5.8", + "illuminate/console": "^5.5,<5.8", + "illuminate/filesystem": "^5.5,<5.8", "barryvdh/reflection-docblock": "^2.0.4", "composer/composer": "^1.6" }, From 1989d0e794f227d6472c825fbae96d64e54f5137 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 4 Sep 2018 16:19:48 +0200 Subject: [PATCH 45/55] Update .travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c19c4fe..69b139f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.6 - 7.0 - 7.1 - 7.2 @@ -17,7 +16,7 @@ cache: matrix: include: - - php: 5.6 + - php: 7.0 env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"' before_script: From 7db1843473e1562d8e0490b51db847d3a1415140 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 6 Sep 2018 20:41:09 +0200 Subject: [PATCH 46/55] Remove Eloquent mixin thing --- src/Console/GeneratorCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Console/GeneratorCommand.php b/src/Console/GeneratorCommand.php index 02cce24..c6db5be 100644 --- a/src/Console/GeneratorCommand.php +++ b/src/Console/GeneratorCommand.php @@ -115,7 +115,6 @@ class GeneratorCommand extends Command if ($written !== false) { $this->info("A new helper file was written to $filename"); - Eloquent::writeEloquentModelHelper($this, $this->files); } else { $this->error("The helper file could not be created at $filename"); } From 5318f485e23983c69a7ae3fa39e2d078bcdee4b1 Mon Sep 17 00:00:00 2001 From: Brent Roose Date: Fri, 7 Sep 2018 10:27:20 +0200 Subject: [PATCH 47/55] Add ::query support --- src/Console/ModelsCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index d3fdfd8..3e15915 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -409,6 +409,7 @@ class ModelsCommand extends Command protected function getPropertiesFromMethods($model) { $methods = get_class_methods($model); + if ($methods) { sort($methods); foreach ($methods as $method) { @@ -444,6 +445,9 @@ class ModelsCommand extends Command array_shift($args); $this->setMethod($name, '\Illuminate\Database\Eloquent\Builder|\\' . $reflection->class, $args); } + } elseif (in_array($method, ['query', 'newQuery', 'newModelQuery'])) { + $reflection = new \ReflectionClass($model); + $this->setMethod($method, '\Illuminate\Database\Eloquent\Builder|\\' . $reflection->getName()); } elseif (!method_exists('Illuminate\Database\Eloquent\Model', $method) && !Str::startsWith($method, 'get') ) { From e7d4cb322fb370c4f2d06292c6a22202f8b32149 Mon Sep 17 00:00:00 2001 From: Brent Roose Date: Fri, 7 Sep 2018 10:29:59 +0200 Subject: [PATCH 48/55] Update ModelsCommand.php --- src/Console/ModelsCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 3e15915..306c176 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -409,7 +409,6 @@ class ModelsCommand extends Command protected function getPropertiesFromMethods($model) { $methods = get_class_methods($model); - if ($methods) { sort($methods); foreach ($methods as $method) { From 30e5300e49f1452d1d7d1b827453e215bea902f8 Mon Sep 17 00:00:00 2001 From: Manabu Matsui Date: Fri, 14 Sep 2018 10:16:13 +0900 Subject: [PATCH 49/55] Fix alias class existence determination --- src/Generator.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Generator.php b/src/Generator.php index 2c7f2d1..f497b6b 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -272,9 +272,13 @@ class Generator $facades = array_merge($facades, $this->config->get('app.aliases', [])); // Only return the ones that actually exist - return array_filter($facades, function ($alias) { - return class_exists($alias); - }); + return array_filter( + $facades, + function ($alias) { + return class_exists($alias); + }, + ARRAY_FILTER_USE_KEY + ); } /** From 5d8d93273f67797f61b92cc32690d058b6c6b4d9 Mon Sep 17 00:00:00 2001 From: Pavlo Zhukov Date: Mon, 1 Oct 2018 00:02:03 +0300 Subject: [PATCH 50/55] Fix missed helpers for abstract methods the same name but different classes --- resources/views/helper.php | 2 +- src/Alias.php | 2 +- src/Macro.php | 1 + src/Method.php | 12 ++++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/resources/views/helper.php b/resources/views/helper.php index dee6278..d76952e 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -28,7 +28,7 @@ namespace { //Method inherited from getDeclaringClass() ?> - shouldReturn() ? 'return ': '' ?>getRoot() ?>::getName() ?>(getParams() ?>); + shouldReturn() ? 'return ': '' ?>getRoot() ?>::getRealName() ?>(getParams() ?>); } } diff --git a/src/Alias.php b/src/Alias.php index a7c5b70..22c14dc 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -310,7 +310,7 @@ class Alias $method = new \ReflectionMethod($className, $name); $class = new \ReflectionClass($className); - if (!in_array($method->name, $this->usedMethods)) { + if (!in_array($magic, $this->usedMethods)) { if ($class !== $this->root) { $this->methods[] = new Method($method, $this->alias, $class, $magic, $this->interfaces); } diff --git a/src/Macro.php b/src/Macro.php index 2d6081e..96ed968 100644 --- a/src/Macro.php +++ b/src/Macro.php @@ -26,6 +26,7 @@ class Macro extends Method $this->method = $method; $this->interfaces = $interfaces; $this->name = $methodName ?: $method->name; + $this->real_name = $method->name; $this->namespace = $class->getNamespaceName(); //Create a DocBlock and serializer instance diff --git a/src/Method.php b/src/Method.php index fd2dd65..8a5117d 100644 --- a/src/Method.php +++ b/src/Method.php @@ -31,6 +31,7 @@ class Method protected $params = array(); protected $params_with_default = array(); protected $interfaces = array(); + protected $real_name; protected $return = null; /** @@ -45,6 +46,7 @@ class Method $this->method = $method; $this->interfaces = $interfaces; $this->name = $methodName ?: $method->name; + $this->real_name = $method->name; $this->namespace = $method->getDeclaringClass()->getNamespaceName(); //Create a DocBlock and serializer instance @@ -112,6 +114,16 @@ class Method return $this->name; } + /** + * Get the real method name + * + * @return string + */ + public function getRealName() + { + return $this->real_name; + } + /** * Get the parameters for this method * From d7359b86d4299b1b8070e563f5165746007a1628 Mon Sep 17 00:00:00 2001 From: Pavlo Zhukov Date: Mon, 1 Oct 2018 00:20:54 +0300 Subject: [PATCH 51/55] Avoid code duplication in constructors --- src/Macro.php | 39 ++++++++++++++++----------------------- src/Method.php | 32 +++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/Macro.php b/src/Macro.php index 96ed968..95f214e 100644 --- a/src/Macro.php +++ b/src/Macro.php @@ -17,37 +17,30 @@ class Macro extends Method * @param array $interfaces */ public function __construct( - \ReflectionFunctionAbstract $method, + $method, $alias, $class, $methodName = null, $interfaces = array() ) { - $this->method = $method; - $this->interfaces = $interfaces; - $this->name = $methodName ?: $method->name; - $this->real_name = $method->name; - $this->namespace = $class->getNamespaceName(); + parent::__construct($method, $alias, $class, $methodName, $interfaces); + } - //Create a DocBlock and serializer instance + /** + * @param \ReflectionFunctionAbstract $method + */ + protected function initPhpDoc($method) + { $this->phpdoc = new DocBlock($method); + } - //Normalize the description and inherit the docs from parents/interfaces - try { - $this->normalizeParams($this->phpdoc); - $this->normalizeReturn($this->phpdoc); - $this->normalizeDescription($this->phpdoc); - } catch (\Exception $e) { - } - - //Get the parameters, including formatted default values - $this->getParameters($method); - - //Make the method static - $this->phpdoc->appendTag(Tag::createInstance('@static', $this->phpdoc)); - - //Reference the 'real' function in the declaringclass + /** + * @param \ReflectionFunctionAbstract $method + * @param \ReflectionClass $class + */ + protected function initClassDefinedProperties($method, \ReflectionClass $class) + { + $this->namespace = $class->getNamespaceName(); $this->declaringClassName = '\\' . ltrim($class->name, '\\'); - $this->root = '\\' . ltrim($class->getName(), '\\'); } } diff --git a/src/Method.php b/src/Method.php index 8a5117d..d0876cf 100644 --- a/src/Method.php +++ b/src/Method.php @@ -26,6 +26,7 @@ class Method protected $method; protected $output = ''; + protected $declaringClassName; protected $name; protected $namespace; protected $params = array(); @@ -35,22 +36,22 @@ class Method protected $return = null; /** - * @param \ReflectionMethod $method + * @param \ReflectionMethod|\ReflectionFunctionAbstract $method * @param string $alias * @param \ReflectionClass $class * @param string|null $methodName * @param array $interfaces */ - public function __construct(\ReflectionMethod $method, $alias, $class, $methodName = null, $interfaces = array()) + public function __construct($method, $alias, $class, $methodName = null, $interfaces = array()) { $this->method = $method; $this->interfaces = $interfaces; $this->name = $methodName ?: $method->name; $this->real_name = $method->name; - $this->namespace = $method->getDeclaringClass()->getNamespaceName(); + $this->initClassDefinedProperties($method, $class); //Create a DocBlock and serializer instance - $this->phpdoc = new DocBlock($method, new Context($this->namespace)); + $this->initPhpDoc($method); //Normalize the description and inherit the docs from parents/interfaces try { @@ -66,12 +67,29 @@ class Method //Make the method static $this->phpdoc->appendTag(Tag::createInstance('@static', $this->phpdoc)); - //Reference the 'real' function in the declaringclass - $declaringClass = $method->getDeclaringClass(); - $this->declaringClassName = '\\' . ltrim($declaringClass->name, '\\'); + //Reference the 'real' function in the declaring class $this->root = '\\' . ltrim($class->getName(), '\\'); } + /** + * @param \ReflectionMethod $method + */ + protected function initPhpDoc($method) + { + $this->phpdoc = new DocBlock($method, new Context($this->namespace)); + } + + /** + * @param \ReflectionMethod $method + * @param \ReflectionClass $class + */ + protected function initClassDefinedProperties($method, \ReflectionClass $class) + { + $declaringClass = $method->getDeclaringClass(); + $this->namespace = $declaringClass->getNamespaceName(); + $this->declaringClassName = '\\' . ltrim($declaringClass->name, '\\'); + } + /** * Get the class wherein the function resides * From 1fdc866fb0520f1c734a71fc47b281ffdb33f143 Mon Sep 17 00:00:00 2001 From: Pavlo Zhukov Date: Mon, 1 Oct 2018 00:39:40 +0300 Subject: [PATCH 52/55] Fix missed autocomplete in helper view --- resources/views/helper.php | 6 ++++++ src/Alias.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/views/helper.php b/resources/views/helper.php index dee6278..f081529 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -1,4 +1,10 @@ + // @formatter:off diff --git a/src/Alias.php b/src/Alias.php index a7c5b70..e6d7577 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -171,7 +171,7 @@ class Alias /** * Get the methods found by this Alias * - * @return array + * @return array|Method[] */ public function getMethods() { From b14d983f74fc11db7ecc737440b3c2bec15c232a Mon Sep 17 00:00:00 2001 From: Pavlo Zhukov Date: Mon, 1 Oct 2018 00:50:28 +0300 Subject: [PATCH 53/55] Change comments style to allow folding and make its clear --- resources/views/helper.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resources/views/helper.php b/resources/views/helper.php index f081529..d0934e3 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -1,9 +1,11 @@ // @formatter:off From eff51d41b34d045e9470fcfd7f27e16cbf59109d Mon Sep 17 00:00:00 2001 From: Pavlo Zhukov Date: Mon, 1 Oct 2018 03:25:34 +0300 Subject: [PATCH 54/55] Add missed getRealName() call for $namespaces_by_alias group --- resources/views/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/helper.php b/resources/views/helper.php index d76952e..edbdd24 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -50,7 +50,7 @@ namespace { //Method inherited from getDeclaringClass() ?> - shouldReturn() ? 'return ': '' ?>getRoot() ?>::getName() ?>(getParams() ?>); + shouldReturn() ? 'return ': '' ?>getRoot() ?>::getRealName() ?>(getParams() ?>); } } From 2ab961e7340c7711078968aace9efb1d81e25fd4 Mon Sep 17 00:00:00 2001 From: Jeppe Knockaert Date: Tue, 23 Oct 2018 15:45:59 +0200 Subject: [PATCH 55/55] Prevent duplicate function declarations in docblocks When a method is declared both in the phpdoc and in the class itself, PhpStorm (2018.3) complains about duplicate function declarations, preventing correct code hinting. To solve this, I remove the already declared functions from the generated dockblocks. --- composer.json | 2 +- src/Alias.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6102959..7cb9e15 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "illuminate/support": "^5.5,<5.8", "illuminate/console": "^5.5,<5.8", "illuminate/filesystem": "^5.5,<5.8", - "barryvdh/reflection-docblock": "^2.0.4", + "barryvdh/reflection-docblock": "^2.0.5", "composer/composer": "^1.6" }, "require-dev": { diff --git a/src/Alias.php b/src/Alias.php index 80f8d2f..f14bb12 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -13,6 +13,7 @@ namespace Barryvdh\LaravelIdeHelper; use Barryvdh\Reflection\DocBlock; use Barryvdh\Reflection\DocBlock\Context; use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer; +use Barryvdh\Reflection\DocBlock\Tag\MethodTag; use ReflectionClass; class Alias @@ -395,12 +396,33 @@ class Alias $serializer = new DocBlockSerializer(1, $prefix); if ($this->phpdoc) { + $this->removeDuplicateMethodsFromPhpDoc(); return $serializer->getDocComment($this->phpdoc); } return ''; } + /** + * Removes method tags from the doc comment that already appear as functions inside the class. + * This prevents duplicate function errors in the IDE. + * + * @return void + */ + protected function removeDuplicateMethodsFromPhpDoc() + { + $methods = count($this->methods) > 0 ? $this->methods : $this->getMethods(); + $methodNames = array_map(function (Method $method) { + return $method->getName(); + }, $methods); + + foreach ($this->phpdoc->getTags() as $tag) { + if ($tag instanceof MethodTag && in_array($tag->getMethodName(), $methodNames)) { + $this->phpdoc->deleteTag($tag); + } + } + } + /** * Output an error. *