Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type-hints on properties when using base classes #278

Closed
finiteinfinity opened this issue May 10, 2024 · 0 comments · Fixed by #279
Closed

Incorrect type-hints on properties when using base classes #278

finiteinfinity opened this issue May 10, 2024 · 0 comments · Fixed by #279

Comments

@finiteinfinity
Copy link
Contributor

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant