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

Skip to content

rememberPossiblyImpureFunctionValues breaks class_exists check #8579

@UCIS

Description

@UCIS

Bug report

Using phpstan version 1.9.4, setting rememberPossiblyImpureFunctionValues to false incorrectly fails on use of nonexistent classes guarded by class_exists.

Code snippet that reproduces the problem

test-class_exists.php

<?php
if (!class_exists('nonexistentclass')) throw new \Exception('nonexistentclass');
$x = new \nonexistentclass();

phpstan.neon

parameters:
  phpVersion: 80024
  level: 5
  paths: [ . ]
  rememberPossiblyImpureFunctionValues: false

(I could not reproduce the issue on phpstan.org/try because this does not allow to specify the config parameters)

Expected output

phpstan should not report any errors, as it does with rememberPossiblyImpureFunctionValues: true. Instead it reports Instantiated class nonexistentclass not found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions