When using base classes, the generated type-hints for relationships can be incorrectly typed as the base class rather than the child class.
This only seems to happen when you have 2 properties named which contain a like-string, e.g.
/**
* @property User $manager
* @property UserType $userType
*/
class User extends Model
{
}
During template construction (\Reliese\Coders\Model\Factory, specifically line 275) when the dependency imports are being shortened, the use of str_replace causes all instances of the User FQCN string to be replaced with the imported version. This unintentionally picks up more than the 1 instance it should be replacing for the import. A simple fix would be to use preg_replace instead with a word boundary (\b).
When using base classes, the generated type-hints for relationships can be incorrectly typed as the base class rather than the child class.
This only seems to happen when you have 2 properties named which contain a like-string, e.g.
During template construction (
\Reliese\Coders\Model\Factory
, specifically line 275) when the dependency imports are being shortened, the use ofstr_replace
causes all instances of theUser
FQCN string to be replaced with the imported version. This unintentionally picks up more than the 1 instance it should be replacing for the import. A simple fix would be to usepreg_replace
instead with a word boundary (\b
).