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

@phpstan-impure does not work on static methods #7210

Closed
jlherren opened this issue May 9, 2022 · 2 comments
Closed

@phpstan-impure does not work on static methods #7210

jlherren opened this issue May 9, 2022 · 2 comments

Comments

@jlherren
Copy link

jlherren commented May 9, 2022

It seems that @phpstan-impure does not work (or is not implemented) for static methods:

<?php declare(strict_types = 1);
class HelloWorld {
	public function doStuff(): int {
		if (self::getBool()) {
			return 1;
		}
		if (self::getBool()) {
			return 2;
		}
		return 3;
	}
	
	/** @phpstan-impure */
	private static function getBool(): bool {
		return mt_rand(0, 1) === 0;
	}
}

https://phpstan.org/r/28a8013d-8b55-4a27-83c6-b739ebd94ef3

Expected output

No error.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@1182199

@github-actions
Copy link

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 Jun 28, 2022
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

2 participants