Larastan: Does not support dynamic type

Created on 2 Aug 2018  路  8Comments  路  Source: nunomaduro/larastan

  • Larastan Version: v0.2.4
  • --level used: default

Description:

Parameter #1 ...$patterns of method Illuminate\Http\Request::is() expects Illuminate\Http\dynamic, string given.

I have this helper function:

/**
 * Check if navigation item active.
 *
 * @param  string $path
 * @param  bool   $wildcard
 * @return string
 */
function isNavItemActive($path, $wildcard = false)
{
    if ($wildcard) {
        $path .= '*';
    }

    return request()->is($path) ? 'true' : 'false';
}

Laravel code where the issue was found:

/**
 * Determine if the current request URI matches a pattern.
 *
 * @param  dynamic  $patterns
 * @return bool
 */
public function is(...$patterns)
{
    foreach ($patterns as $pattern) {
        if (Str::is($pattern, $this->decodedPath())) {
            return true;
        }
    }

    return false;
}

Most helpful comment

BTW: This will be possible to solve in a clean way in PHPStan 0.10.3 with PHPStan\PhpDoc\TypeNodeResolverExtension.

All 8 comments

BTW: This will be possible to solve in a clean way in PHPStan 0.10.3 with PHPStan\PhpDoc\TypeNodeResolverExtension.

Laravel is the ONLY PHP basecode that uses dynamic instead of mixed. IMO that must be fixed there, not supporting it.

This is Larastan, a tool designed with the goal of wrapping phpstan for Laravel. Supporting whatever Laravel has is the whole essence of this project.

@carusogabriel is correct that this is a Laravel issue, rather than Laravel magic...
It's fine though ,it's in the process of being fixed, this was merged 4 days ago :) https://github.com/laravel/framework/pull/26164

@phh Could you try with laravel master?

Have not gotten the error since I posted this issues, so closing.

Sorry to reopen old issue, but since it's related I thought it might be better than to open a new one.

 133    Function cache invoked with 1 parameter, 0 required.
 160    Function cache invoked with 2 parameters, 0 required.

There is a dynamic definition for the cache helper

 * @param  dynamic  key|key,default|data,expiration|null

 * @return mixed|\Illuminate\Cache\CacheManager

Which side would be the best place to fix something liket his?

Was this page helpful?
0 / 5 - 0 ratings