Skip to content

Draft: hide class-level template types from static members#2232

Open
jiripudil wants to merge 5 commits intophpstan:1.10.xfrom
jiripudil:no-static-template-types
Open

Draft: hide class-level template types from static members#2232
jiripudil wants to merge 5 commits intophpstan:1.10.xfrom
jiripudil:no-static-template-types

Conversation

@jiripudil
Copy link
Copy Markdown
Contributor

This is a solution I was talking about previously.

The failing test discovered exactly the kind of class-string magic I was afraid people might be doing. I don't know how many actual real-life use cases there are, but it puts doubt in my mind about this.

Nevertheless, I still firmly believe this is a must for static properties, which, sadly, I have no idea how to cover in this way.

@ondrejmirtes
Copy link
Copy Markdown
Member

Added a few commits so that this is ready for static methods if we decide to go with it :) But yeah, the CarFactoryProcessor example is somewhat reasonable even for static method.

About static properties - yeah, that might not be trivial at all :/ Because when retrieving PHPDocs, FileTypeMapper is handed these parameters:

	public function getResolvedPhpDoc(
		?string $fileName,
		?string $className,
		?string $traitName,
		?string $functionName,
		string $docComment,
	): ResolvedPhpDocBlock

We don't know when we're getting a PHPDoc for a property, they're not stored separately :/

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 this pull request may close these issues.

2 participants