PHP: Detect "undefined function" errors before running?

Is there any tool to help detect potential errors such as the "undefined function" in a PHP script before execution?

For example, consider:

<?php
zarfnutz ( 'blah' );
?>

If you ask the PHP command line interface to verify that for syntax errors, it answers that they are not. But of course, the script will fail if you try to run it because there is no function called "zarfnutz".

I understand that if the language is sufficiently referential, then in the literal sense it is impossible to create a tool that is guaranteed to be accurate (I do not know whether PHP is actually really referential enough). But in any case, there can definitely be a tool that can at least warn you that "zarfnutz" can be undefined, and such a tool will be very useful to me.

Does anyone know about this?

Thanks in advance.

+3
source share
4 answers

I believe this is one of the features of PHPLint .

+3
source

Well, I do not know how to do this, but function_existsthey get_defined_functionsare part of the core of PHP.

0

php lint ( ):

php -l FILE
0

You can check function_exists(). It is not as flexible as checking through php -l, but it will do the job.

0
source

Source: https://habr.com/ru/post/1703771/


All Articles