Compare commits

...
4 Commits
Author SHA1 Message Date
Casper Bloemendaal 271682a2a6 feat: use generics of return type to determine resulting models (#1653) 2025-01-08 11:01:30 +01:00
Barry vd. Heuvelandlaravel-ide-helper bb1caed698 Check if macro is valid (#1655)
* Check if macro is valid

* composer fix-style

---------

Co-authored-by: laravel-ide-helper <[email protected]>
2025-01-08 11:00:53 +01:00
Barry vd. Heuvelandlaravel-ide-helper 55268cd47a Catch meta, tweak auth (#1654)
* Catch meta, tweak auth

* composer fix-style

* Catch meta, tweak auth

---------

Co-authored-by: laravel-ide-helper <[email protected]>
2025-01-08 11:00:41 +01:00
barryvdh 088968c3fc Update CHANGELOG 2025-01-06 15:42:30 +00:00
4 changed files with 33 additions and 4 deletions
+8
View File
@@ -1,5 +1,13 @@
# Changelog # Changelog
## v3.5.2 - 2025-01-06
### Fixes
Fix empty/anonymous closure in meta command.
**Full Changelog**: https://github.com/barryvdh/laravel-ide-helper/compare/v3.5.1...v3.5.2
## v3.5.1 - 2025-01-06 ## v3.5.1 - 2025-01-06
### What's Changed ### What's Changed
+7 -1
View File
@@ -403,9 +403,15 @@ class Alias
$macros = isset($properties['macros']) ? $properties['macros'] : []; $macros = isset($properties['macros']) ? $properties['macros'] : [];
foreach ($macros as $macro_name => $macro_func) { foreach ($macros as $macro_name => $macro_func) {
if (!in_array($macro_name, $this->usedMethods)) { if (!in_array($macro_name, $this->usedMethods)) {
try {
$method = $this->getMacroFunction($macro_func);
} catch (Throwable $e) {
// Invalid method, skip
continue;
}
// Add macros // Add macros
$this->methods[] = new Macro( $this->methods[] = new Macro(
$this->getMacroFunction($macro_func), $method,
$this->alias, $this->alias,
$reflection, $reflection,
$macro_name, $macro_name,
+12 -1
View File
@@ -233,7 +233,12 @@ class MetaCommand extends Command
], ],
[ [
'class' => ['\Illuminate\Support\Facades\Route', '\Illuminate\Support\Facades\Auth', 'Illuminate\Foundation\Auth\Access\Authorizable'], 'class' => ['\Illuminate\Support\Facades\Route', '\Illuminate\Support\Facades\Auth', 'Illuminate\Foundation\Auth\Access\Authorizable'],
'method' => ['can', 'cannot'], 'method' => ['can', 'cannot', 'cant'],
'argumentSet' => 'auth',
],
[
'class' => ['Illuminate\Contracts\Auth\Access\Authorizable'],
'method' => ['can'],
'argumentSet' => 'auth', 'argumentSet' => 'auth',
], ],
[ [
@@ -308,7 +313,13 @@ class MetaCommand extends Command
{ {
if (!isset($this->templateCache[$name])) { if (!isset($this->templateCache[$name])) {
$file = __DIR__ . '/../../php-templates/' . basename($name) . '.php'; $file = __DIR__ . '/../../php-templates/' . basename($name) . '.php';
try {
$value = $this->files->requireOnce($file) ?: []; $value = $this->files->requireOnce($file) ?: [];
} catch (\Throwable $e) {
$value = [];
$this->warn('Cannot load template for ' . $name . ': ' . $e->getMessage());
}
if (!$value instanceof Collection) { if (!$value instanceof Collection) {
$value = collect($value); $value = collect($value);
} }
+5 -1
View File
@@ -819,10 +819,14 @@ class ModelsCommand extends Command
$relation === 'morphTo' $relation === 'morphTo'
) )
) { ) {
$matches = [];
$returnType = $this->getReturnTypeFromDocBlock($reflection);
preg_match('/MorphTo<(.+?)(?:,|>)/i', $returnType, $matches);
// Model isn't specified because relation is polymorphic // Model isn't specified because relation is polymorphic
$this->setProperty( $this->setProperty(
$method, $method,
$this->getClassNameInDestinationFile($model, Model::class) . '|\Eloquent', $matches[1] ?? $this->getClassNameInDestinationFile($model, Model::class) . '|\Eloquent',
true, true,
null, null,
$comment, $comment,