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

Memory leak with self-referencing constants #10147

Closed
YourKey opened this issue Nov 17, 2023 · 2 comments
Closed

Memory leak with self-referencing constants #10147

YourKey opened this issue Nov 17, 2023 · 2 comments
Labels

Comments

@YourKey
Copy link

YourKey commented Nov 17, 2023

Bug report

In my code, an abstract class uses a constant that refers to itself, forcing the subclass to mandatorily reassign it. This causes a memory leak issue in PHPStan, as the check gets stuck in an infinite loop.

Example:

abstract class AbstractClass
{
    const BASE_URL = self::BASE_URL;
}

final class TestClass extends AbstractClass
{
   const BASE_URL = 'http://example.com';
}

PHPStan version: 1.10.41
PHP version: 8.2
Operating System: MacOS 12.6.3

Code snippet that reproduces the problem

https://phpstan.org/r/8196a92c-91c1-475f-b322-4622fec090d2

Expected output

Recognition of self-referencing constants and reporting it as an error.
Cannot declare self-referencing constant self::BASE_URL

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

No response

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@93af41b

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 Dec 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants