* Generate noinspections PHPStorm tags
* Add comments about PHPStorm noinspection tags
* Fix line to long warnings
* Add tests for PHPStorm noinspection
Co-authored-by: Michał Zgliński <[email protected]>
These two methods are already regular methods on the trait, there's no
need to add them and additionally they're not static, so their
definition was changed for the worse.
The other methods are magic so it's fine to keep them.
Fixes https://github.com/barryvdh/laravel-ide-helper/issues/917
* Add custom collection support for get and all methods
* Only add get and all when using custom collection
* Use static instead of class name
* Add missing custom collection test with relation
* Use class reference over string
Co-Authored-By: Markus Podar <[email protected]>
* Fix when using class reference
Co-authored-by: Markus Podar <[email protected]>
* Add ignored_models as config option
* Add README.md entry
* Add tests
* Change name of test class
* Add Ignored to the return values from the mocked filesystem
* Improve test speed by adding prestissimo
* Revert "Improve test speed by adding prestissimo"
This reverts commit 246a9f2a78.
If the property name matches the foreign key name
creating a BelongsTo relation triggers an undefined
property error. Disabling constraints prevents
accessing the property and thus prevents the error.
Laravel 5.8 introduced a feature to support a custom date class via
`Date::use()`, see https://github.com/laravel/framework/pull/25320
When e.g. using `Date::use(CarbonImmutable)` in a project, it means
all date casts are not returning `\Illuminate\Support\Carbon` anymore
but `\Carbon\CarbonImmutable`, which means all the generated type hints
for dates are now wrong.
This change tries to be still backwards compatible with Laravel < 5.8
which do not have the Date facade.
* x to Many relationships are detected via a `Many` keyword in the relationship object class name
* reason: example: `belongsTo` was incorrectly recognized as `belongsToMany`
* adds `@property-read int|null $x2Many_relationship_method_name_count` model class docBlock comment
* when model makes use of `withCount` or `loadCount` there is a property on the resource `$instance->relationship_method_count` that states the count of related models
* can be `NULL` when `withCount` or `loadCount` aren't used
See my comment https://github.com/barryvdh/laravel-ide-helper/pull/765#issuecomment-471014271:
The change in #765 made anonymous functions get reflected with `ReflectionMethod` instead of `ReflectionFunction`, which makes it lose the doc comment. This means that the generated helpers are missing their return types. This is because Closure is also an object and callable.
To fix it, Closure should be excluded from that new condition.
Macros can be used with invokable classes, like so.
```
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Response;
class ResponseMacroServiceProvider extends ServiceProvider
{
public function boot()
{
Response::macro('foo', new Foo());
}
}
class Foo
{
public function __invoke()
{
return 'foobar';
}
}
```
When running `ide-helper:generate` the following fatal error was thrown.
``` Symfony\Component\Debug\Exception\FatalThrowableError : ReflectionFunction::__construct() expects parameter 1 to be string, object given```
This commit fixes this error.