Skip to content

Commit

Permalink
Revert "assert a invalid constant turns into mixed"
Browse files Browse the repository at this point in the history
This reverts commit 42307ce.
  • Loading branch information
staabm committed Mar 6, 2024
1 parent 42307ce commit 3365cde
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
1 change: 0 additions & 1 deletion e2e/bug10483/bootstrap.php
Expand Up @@ -3,4 +3,3 @@
// constant that's used in the Filter extension that was introduced in a later version of PHP.
// on earlier php version introduce the same constant via a bootstrap file but with a wrong type
if(!defined("FILTER_SANITIZE_ADD_SLASHES"))define("FILTER_SANITIZE_ADD_SLASHES",false);
if(!defined("FILTER_SANITIZE_MAGIC_QUOTES"))define("FILTER_SANITIZE_MAGIC_QUOTES",false);
8 changes: 1 addition & 7 deletions e2e/bug10483/src/bug10483.php
@@ -1,11 +1,5 @@
<?php

use function PHPStan\Testing\assertType;

function doFoo(mixed $filter): void {
assertType('non-falsy-string|false', filter_var("no", FILTER_VALIDATE_REGEXP));

// if FILTER_SANITIZE_MAGIC_QUOTES would contain a valid value, the following line would yield "string|false".
// but since in phpstan bootstrap file the constant was miss-defined with a invalid value, PHPStan does not know the constant and returns "mixed", like for regular unknown constants.
assertType('mixed', filter_var($filter, FILTER_SANITIZE_MAGIC_QUOTES));
\PHPStan\Testing\assertType('non-falsy-string|false', filter_var("no", FILTER_VALIDATE_REGEXP));
}

0 comments on commit 3365cde

Please sign in to comment.