Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Circular referencing of class constants causes PHPStan to stop responding #9172

@internalsystemerror

Description

@internalsystemerror

Bug report

Constants inside a parameter typehint are unable to reference each other. Whereas this would be a nice feature, the bug is that PHPstan locks up and fails to respond.

Code snippet that reproduces the problem

<?php declare(strict_types = 1);

final class HelloWorld
{
	/** @var int<0, self::MAX_DEPOSIT> */
	public const MIN_DEPOSIT = 1_000;

	/** @var int<self::MIN_DEPOSIT, max> */
	public const MAX_DEPOSIT = 20_000;
}

Unable to post a demo link due to the website erroring when using this code. Note that changing self::MIN_DEPOSIT to any integer value below self::MAX_DEPOSIT allows it to work without errors as expected.

Expected output

PHPStan should warn about the circular reference, or use it.

Did PHPStan help you today? Did it make you happy in any way?

I'd be interested in attempting a fix to this one too. My time is stretched pretty thin right now, but if you're able to point me in the right direction then I will follow that time permitting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions