Skip to content

Incorrect result in substr #16636

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

Closed
YuanchengJiang opened this issue Oct 29, 2024 · 2 comments
Closed

Incorrect result in substr #16636

YuanchengJiang opened this issue Oct 29, 2024 · 2 comments

Comments

@YuanchengJiang
Copy link

Description

The following code:

<?php
namespace foo;
const foo = 1;
const foo = 2;
interface MyInterface {
    const TEST_CONSTANT = true;
}
class ParentClass implements MyInterface { }
class ChildClass extends ParentClass { }
echo (is_subclass_of('ChildClass', 'MyInterface') ? 'true' : 'false') . "\n";
echo (defined('ChildClass::TEST_CONSTANT') ? 'true' : 'false') . "\n";
echo (is_subclass_of('ParentClass', 'MyInterface') ? 'true' : 'false') . "\n";
echo (defined('ParentClass::TEST_CONSTANT') ? 'true' : 'false') . "\n";
$x1=1;
$x2=1;
var_dump('substr');
$callret=substr($x1,$x2,$x1);
print_r($callret);
var_export($callret);
debug_zval_dump($callret);
?>

Resulted in this output (non-JIT):

false
false
false
false
string(6) "substr"
''string(0) "" interned

and (JIT 1211):

false
false
false
false
string(6) "substr"

Fatal error: Uncaught TypeError: substr(): Argument #2 ($offset) must be of type int, string given in /tmp/test.php:17

PHP Version

nightly

Operating System

ubuntu 22.04

@devnexen
Copy link
Member

Not sure how much this is an actual bug, cc @iluuu1994

@nielsdos
Copy link
Member

This is another duplicate of #15981

@nielsdos nielsdos closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants