Category
stdlib
Problem
strip_tags() in Zend throws TypeError when $string is not a string. This compiler raises LogicException (strip_tags() only supports strings in this compiler build) on VM and JIT paths (ext/standard/strip_tags.php).
The second argument $allowed_tags must also throw TypeError when neither string nor null (Zend allows null).
php-src reference
Repro (failure today)
<?php
declare(strict_types=1);
function expect_type_error(callable $fn): void {
try {
$fn();
echo "no throw\n";
} catch (TypeError $e) {
echo "TypeError\n";
} catch (Throwable $e) {
echo get_class($e), ':', $e->getMessage(), "\n";
}
}
expect_type_error(fn () => strip_tags([]));
expect_type_error(fn () => strip_tags(new stdClass()));
expect_type_error(fn () => strip_tags(123));
expect_type_error(fn () => strip_tags('ok', []));
echo strip_tags('<b>x</b>'), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro_strip_tags_type.php
php bin/vm.php repro_strip_tags_type.php
php bin/jit.php repro_strip_tags_type.php
'
| Call |
Zend PHP 8.x |
This compiler VM/JIT |
strip_tags([]) |
TypeError |
LogicException |
strip_tags(new stdClass()) |
TypeError |
LogicException |
strip_tags(123) |
TypeError |
LogicException |
strip_tags('ok', []) |
TypeError |
LogicException |
strip_tags('<b>x</b>') |
x |
OK |
Scope (this repo)
| Module |
Path |
| VM |
ext/standard/strip_tags.php |
| JIT/AOT |
lib/JIT/Builtin/Type.php / __compiler_strip_tags in lib/AOT/runtime/ |
| Tests |
test/repro-maintainer/parity_strip_tags_type.php, new test/compliance/cases/stdlib/strip_tags_type.phpt |
Use shared TypeError throw helpers from other stdlib parity issues (#4578 wordwrap pattern).
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter strip_tags'
Category
stdlibProblem
strip_tags()in Zend throwsTypeErrorwhen$stringis not a string. This compiler raisesLogicException(strip_tags() only supports strings in this compiler build) on VM and JIT paths (ext/standard/strip_tags.php).The second argument
$allowed_tagsmust also throwTypeErrorwhen neither string nor null (Zend allows null).php-src reference
ext/standard/string.c—PHP_FUNCTION(strip_tags)ext/standard/basic_functions.stub.phpRepro (failure today)
strip_tags([])TypeErrorLogicExceptionstrip_tags(new stdClass())TypeErrorLogicExceptionstrip_tags(123)TypeErrorLogicExceptionstrip_tags('ok', [])TypeErrorLogicExceptionstrip_tags('<b>x</b>')xScope (this repo)
ext/standard/strip_tags.phplib/JIT/Builtin/Type.php/__compiler_strip_tagsinlib/AOT/runtime/test/repro-maintainer/parity_strip_tags_type.php, newtest/compliance/cases/stdlib/strip_tags_type.phptUse shared
TypeErrorthrow helpers from other stdlib parity issues (#4578 wordwrap pattern).Done when
TypeErroron VM and JIT/AOTstrip_tags('<b>x</b>')still printsx./script/ci-fast.sh --filter strip_tagsgreenVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter strip_tags'