Skip to content

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

@jlherren

Description

@jlherren

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions