Skip to content

Additional test for disabled function re-declare #5817

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
wants to merge 1 commit into from
Closed

Additional test for disabled function re-declare #5817

wants to merge 1 commit into from

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