Skip to content

Commit dba1c78

Browse files
leo108barryvdhlaravel-ide-helper
authored andcommitted
Fix unsetMethod in ModelsCommand (barryvdh#1453)
* Fix unsetMethod in ModelsCommand * composer fix-style --------- Co-authored-by: Barry vd. Heuvel <barry@fruitcake.nl> Co-authored-by: laravel-ide-helper <laravel-ide-helper@users.noreply.github.com>
1 parent 8bd5f9a commit dba1c78

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
55
[Next release](https://github.com/barryvdh/laravel-ide-helper/compare/v2.14.0...master)
66
--------------
77

8+
### Fixed
9+
- Fix case issue in `ModelsCommand::unsetMethod()` [#1453 / leo108](https://github.com/barryvdh/laravel-ide-helper/pull/1453)
10+
811
### Changed
912
- Removed support for Laravel 8 and therefore for PHP < 8.0 [#1504 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1504)
1013

src/Console/ModelsCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,12 @@ public function setMethod($name, $type = '', $arguments = [], $comment = '')
903903

904904
public function unsetMethod($name)
905905
{
906-
unset($this->methods[strtolower($name)]);
906+
foreach ($this->methods as $k => $v) {
907+
if (strtolower($k) === strtolower($name)) {
908+
unset($this->methods[$k]);
909+
return;
910+
}
911+
}
907912
}
908913

909914
public function getMethodType(Model $model, string $classType)

tests/Console/ModelsCommand/ModelHooks/Hooks/UnsetMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class UnsetMethod implements ModelHookInterface
1212
{
1313
public function run(ModelsCommand $command, Model $model): void
1414
{
15-
$command->unsetMethod('query');
15+
$command->unsetMethod('newmodelquery');
1616
}
1717
}

tests/Console/ModelsCommand/ModelHooks/Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public function test(): void
7676
* @property int $id
7777
* @property-read string $custom
7878
* @method static \Illuminate\Database\Eloquent\Builder|Simple custom($custom)
79-
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
8079
* @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery()
80+
* @method static \Illuminate\Database\Eloquent\Builder|Simple query()
8181
* @method static \Illuminate\Database\Eloquent\Builder|Simple whereId($value)
8282
* @mixin \Eloquent
8383
*/

0 commit comments

Comments
 (0)