Skip to content

Conversation

@Ayesh
Copy link
Member

@Ayesh Ayesh commented Jul 6, 2020

Related to: #5473
Bug: 79382

For disabled functions, there is currently a test:

--INI--
disable_functions=strlen
--FILE--
<?php

function strlen(string $x): int {
    $len = 0;
    while (isset($x[$len])) $len++;
    return $len;
}

var_dump(strlen("foobar"));

?>
--EXPECT--
int(6)

This test passes, but I think PHP is still using the internal strlen implementation here because even if I change the user-land function declaration to return another value, the test still passes.

This PR adds a new test that re-declares disbaled substr function (which has no internal optimizations).

Thank you 🙏🏿.

php-pulls pushed a commit that referenced this pull request Jul 8, 2020
@nikic
Copy link
Member

nikic commented Jul 8, 2020

Nice catch! I've fixed this issue in 2af1d36.

With that done, I don't think we need the extra test for substr(), as the strlen() case now also works as it is supposed to.

@nikic nikic closed this Jul 8, 2020
@Ayesh Ayesh deleted the tests/79382-2 branch July 10, 2020 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants