0

We have a function that is being defined on a host but not locally which is causing a name collision. The function is go() and it's in Kirby and somewhere else. When we deploy to Vercel we get an error saying go() is already defined. This is not an issue locally or on other hosts (we tried Dreamhost as an example).

We tried this to find where the original is called:

$reflFunc = new ReflectionFunction('function_name');
print $reflFunc->getFileName() . ':' . $reflFunc->getStartLine();

But we get literally: :

As if it's not defined. If we wrap the function in if (!function_exists('go')) it does break for other reasons but the redeclaration error is alleviated so we know the function exists but we can't find it.

In JavaScript you can do like console.log(someFunction) and it'll output the function in string form. Example:

enter image description here

Can we do this in PHP? This would allow us to try to at least search for the code signature in the project or on the web to find what code is colliding.

Oscar Godson
  • 31,662
  • 41
  • 121
  • 201
  • You might be able to use reflection for this. https://www.php.net/manual/en/class.reflectionfunction.php or possibly this post will help. https://stackoverflow.com/questions/7026690/reconstruct-get-code-of-php-function – bassxzero Nov 17 '20 at 00:55
  • Yeah I agree but with the code above we get no output. We can try that specific code though but seems really similar to ours – Oscar Godson Nov 17 '20 at 00:57
  • Honestly the reflection code is not well documented and a little annoying to use sometimes. I would try the exact code in the post to see if it can work at all. – bassxzero Nov 17 '20 at 01:00
  • Check if you have `auto_prepend_file` enabled, that may be where it's defined. – Barmar Nov 17 '20 at 01:11

1 Answers1

0

I thought the go function was in an extension so your way to do it with ReflectionFunction was not found. The ReflectionFunction class has lots of get functions to get information about the function, you can call all of them to see more information and maybe luckily smile at you.

I tried a function mysqli_query in the mysql extension and it didn't find filename or fileline either but it gave me the function list when I called $ref->getExtension();

laguf1.mobi
  • 171
  • 6