--level used: 7Unexpected error message when running phpstan:
"Class replica was not found while trying to analyse it - autoloading is probably not configured properly."
Here "replica" is a param, not a class, so I have no idea where this is coming from but thought I should raise it.
Snippets of relevant code:
From Controller:
$lends = auth()->user()->lendsNotDeletedFromReplica();
From User:
/**
* All non-deleted lends from the replica connection
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function lendsNotDeletedFromReplica(): HasMany
{
return $this->hasManyFromConnection('replica', LendingRequest::class)
->where('status', '!=', 'deleted');
}
User inherits from Model:
/**
* Allows use of different DB connections for relationships
*
* @param string $connection
* @param string $related
* @param string $foreignKey
* @param string $localKey
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function hasManyFromConnection(
string $connection,
string $related,
string $foreignKey = null,
string $localKey = null
): HasMany {
$foreignKey = $foreignKey ?: $this->getForeignKey();
$instance = new $related;
$instance->setConnection($connection);
$localKey = $localKey ?: $this->getKeyName();
return new HasMany($instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey);
}
Hi,
This should be fixed now: https://github.com/nunomaduro/larastan/commit/cd5ce84d7853a9805cbdfa08f1dbb2528981fd6c
Tested and this has resolved the issue.
Most helpful comment
Hi,
This should be fixed now: https://github.com/nunomaduro/larastan/commit/cd5ce84d7853a9805cbdfa08f1dbb2528981fd6c