Open
Description
Versions:
- ide-helper Version: 3.5.4
- Laravel Version: 11.42.1
- PHP Version: 8.3.16
Description:
When adding mixin on Facade in the boot
method of the AppServiceProvider
, the methods provided by the mixin are not properly added to the _ide_helper.php
file anymore.
Steps To Reproduce:
- Add a mixin on a Facade in your
AppServiceProvider
// AppServiceProvider
public function boot(): void
{
Cache::mixin(new CacheMixin());
}
- Create the Mixin class
// CacheMixin
class CacheMixin
{
public function networkFirst(): Closure
{
/**
* @param string $key
* @param \Closure $callback
* @return mixed
*/
return function (string $key, Closure $callback) {
$value = $callback();
if (is_null($value)) {
return $this->get($key);
}
$this->forever($key, $value);
return $value;
};
}
}
-
Generate the
_ide_helper.php
file -
When using
Cache::networkFirst()
anywhere in the code phpstorm will say
Method 'networkFirst' not found in \Illuminate\Support\Facades\Cache
When forcing barryvdh/laravel-ide-helper
to 3.4.0
, it seems to work fine.
Here's the the part of my _ide_helper.php
file in 3.5.4.
namespace Illuminate\Cache {
/**
*
*
* @mixin \Illuminate\Contracts\Cache\Store
*/
class Repository {
/**
*
*
* @param string $key
* @param \Closure $callback
* @return mixed
* @see \App\Support\Cache\CacheMixin::networkFirst()
* @static
*/
public static function networkFirst($key, $callback)
{
return \Illuminate\Cache\Repository::networkFirst($key, $callback);
}
}
}
Here's the the part of my _ide_helper.php
file in 3.4.0.
namespace Illuminate\Support\Facades {
....
/**
*
*
* @see \Illuminate\Cache\CacheManager
* @see \Illuminate\Cache\Repository
*/
class Cache {
/**
*
*
* @param string $key
* @param \Closure $callback
* @return mixed
* @see \App\Support\Cache\CacheMixin::networkFirst()
* @static
*/
public static function networkFirst($key, $callback)
{
return \Illuminate\Cache\Repository::networkFirst($key, $callback);
}
....
}
}
namespace Illuminate\Cache {
/**
*
*
* @mixin \Illuminate\Contracts\Cache\Store
*/
class Repository {
/**
*
*
* @param string $key
* @param \Closure $callback
* @return mixed
* @see \App\Support\Cache\CacheMixin::networkFirst()
* @static
*/
public static function networkFirst($key, $callback)
{
return \Illuminate\Cache\Repository::networkFirst($key, $callback);
}
}
}