Skip to content
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

uopz_get_return incorrectly returns null if the method/function name contains upper-case characters #163

Closed
darrenedale opened this issue Aug 28, 2022 · 1 comment
Labels

Comments

@darrenedale
Copy link
Contributor

Issue can be reproduced with the following PHP code:

echo "Method SplFileInfo::getSize():\n";
echo "uopz_set_return(SplFileInfo::class, \"getSize\", 42): " . (uopz_set_return(SplFileInfo::class, "getSize", 42) ? "true" : "false") . "\n";
echo "(new SplFileInfo(\"any-file\"))->getSize(): " . (new SplFileInfo("any-file"))->getSize() . "\n";
echo "uopz_get_return(SplFileInfo::class, \"getSize\"): " . uopz_get_return(SplFileInfo::class, "getSize") . "\n";
echo "uopz_get_return(SplFileInfo::class, \"getsize\"): " . uopz_get_return(SplFileInfo::class, "getsize") . "\n";

Expected output:

Method SplFileInfo::getSize():
uopz_set_return(SplFileInfo::class, "getSize", 42): true
(new SplFileInfo("any-file"))->getSize(): 42
uopz_get_return(SplFileInfo::class, "getSize"): 42
uopz_get_return(SplFileInfo::class, "getsize"): 42

Actual output:

Method SplFileInfo::getSize():
uopz_set_return(SplFileInfo::class, "getSize", 42): true
(new SplFileInfo("any-file"))->getSize(): 42
uopz_get_return(SplFileInfo::class, "getSize"): 
uopz_get_return(SplFileInfo::class, "getsize"): 42

The root cause is that function names are lower-cased when they are inserted into the returns hash in uopz_get_return(), but are not lower-cased in the lookup in uopz_get_return().

@darrenedale
Copy link
Contributor Author

I have a branch with a fix ready to roll. Are you interested in receiving a PR?

@cmb69 cmb69 added the bug label Aug 29, 2022
@cmb69 cmb69 closed this as completed in 6db6be8 Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants