diff --git a/CHANGELOG.md b/CHANGELOG.md index ffb3068..d9dfde6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. [Next release](https://github.com/barryvdh/laravel-ide-helper/compare/v2.14.0...master) -------------- +### Fixed +- Fix case issue in `ModelsCommand::unsetMethod()` [#1453 / leo108](https://github.com/barryvdh/laravel-ide-helper/pull/1453) + ### Changed - Removed support for Laravel 8 and therefore for PHP < 8.0 [#1504 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1504) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index fd34432..a2439b1 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -892,7 +892,12 @@ class ModelsCommand extends Command public function unsetMethod($name) { - unset($this->methods[strtolower($name)]); + foreach ($this->methods as $k => $v) { + if (strtolower($k) === strtolower($name)) { + unset($this->methods[$k]); + return; + } + } } public function getMethodType(Model $model, string $classType) diff --git a/tests/Console/ModelsCommand/ModelHooks/Hooks/UnsetMethod.php b/tests/Console/ModelsCommand/ModelHooks/Hooks/UnsetMethod.php index 6dfad54..23b53d1 100644 --- a/tests/Console/ModelsCommand/ModelHooks/Hooks/UnsetMethod.php +++ b/tests/Console/ModelsCommand/ModelHooks/Hooks/UnsetMethod.php @@ -12,6 +12,6 @@ class UnsetMethod implements ModelHookInterface { public function run(ModelsCommand $command, Model $model): void { - $command->unsetMethod('query'); + $command->unsetMethod('newmodelquery'); } } diff --git a/tests/Console/ModelsCommand/ModelHooks/Test.php b/tests/Console/ModelsCommand/ModelHooks/Test.php index 05ffea2..fadaf6c 100644 --- a/tests/Console/ModelsCommand/ModelHooks/Test.php +++ b/tests/Console/ModelsCommand/ModelHooks/Test.php @@ -76,8 +76,8 @@ use Illuminate\Database\Eloquent\Model; * @property int $id * @property-read string $custom * @method static \Illuminate\Database\Eloquent\Builder|Simple custom($custom) - * @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery() + * @method static \Illuminate\Database\Eloquent\Builder|Simple query() * @method static \Illuminate\Database\Eloquent\Builder|Simple whereId($value) * @mixin \Eloquent */