phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

Draft: hide class-level template types from static members

Open jiripudil opened this issue 3 years ago • 1 comments

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.

jiripudil avatar Feb 12 '23 10:02 jiripudil

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 :/

ondrejmirtes avatar Feb 12 '23 19:02 ondrejmirtes