Skip to content

Feature request: Checking type hint of fields against Doctrine metadata #31

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

Closed
arnaud-lb opened this issue Jul 19, 2018 · 8 comments
Closed

Comments

@arnaud-lb
Copy link
Contributor

phpstan-doctrine could check if a field's typehint matches Doctrine's metadata.

In the following example, the plugin could emit a warning telling that int does not match string:

/**
 * @var int
 *
 * @Column(type="string")
 */
 private $var;

In the following examples, the plugin could emit a warning telling that the field is nullable:

/**
 * @var int // Should be nullable
 *
 * @Column(type="integer", nullable=true)
 */
 private $var;

/**
 * @var Foo // Should be nullable
 *
 * @OneToOne(targetEntity="Foo")
@lookyman
Copy link
Contributor

We have exactly this in our company, I might be able to release it publicly.

@ondrejmirtes
Copy link
Member

It'd be cool to have it a part of phpstan-doctrine as rules.neon.

@lookyman
Copy link
Contributor

Problem with this is it would most likely require to have doctrine in composer.json as a require dependency, so I'm thinking a separate package instead? Thoughts, @ondrejmirtes?

@ondrejmirtes
Copy link
Member

This should now be possible in a nice way thanks to #49.

@ondrejmirtes
Copy link
Member

Basic version for @ORM\Column implemented in #74 :)

@ondrejmirtes
Copy link
Member

We consider this done :) #75 #76 Please test the hell out of it :)

@arnaud-lb
Copy link
Contributor Author

Awesome ! Thanks @lookyman

@github-actions
Copy link

github-actions bot commented May 1, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants