[Solution] The "Undefined function" message was actually coming from SonarLint. I added type hinting to the function, and SonarLint no longer complains.
I would like to switch to Visual Studio Code for PHP development.
All of my files start with require_once with this syntax
require_once(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR . 'RequireCommonStuff.php');
and debugging won't launch, presumably because VSC says that there are problems with the file to be debugged, along the lines of
Undefined function 'DumpGetAndPostParametersIfDebugging'.
where that function is declared in one of my required files.
Strangely, there are no problems reported for the require_once statements, but I can think of no other explanation for the function not being found.
The code works just fine with PHPstorm, I am testing on localhost - any ideas as to what I am doing wrongly?
[Update] the error is happenig with every function which is declared in a required file. Here's what leads to the first example.
in RequireCommonStuff.php, I just have more require_onces :
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'constants.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'third_party' . DIRECTORY_SEPARATOR .'ChromePhp.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'errorHandling.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'trace.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'parseAndValidateUrlGetParameters.php');
The last of those is causing the error I discuss (although all of them cause erros). It's contents are (note: no classes involved), header comment stripped
function ParseAndValidateUrlGetParameters($url,
$inputType,
$filter,
$debug,
$reportIndicent=true,
$allFieldsMandatory=true)
{
require_once __DIR__ . '/constants.php'format instead? Just in case VSC is having trouble parsing that out. It'd be weird, but it is good to rule out.