Re: Question about adding !function_identifier
| From: | Robert Hickman | Date: | Fri, 05 Apr 2019 10:30:37 +0000 |
| Subject: | Re: Question about adding !function_identifier | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105105@lists.php.net to get a copy of this message | ||
>
> The tricky part is that PHP is a highly dynamic language, so there's a lot
> of cases where the analysis can only return "maybe". My understanding is
> that this is what a lot of the work on Hack is doing: creating a language
> which looks a lot like PHP, but doesn't have as many ambiguous cases which
> can't be analysed statically.
>
Quite a lot of code that apparently cannot be statically analysed
could be if the static analyser was programmable. To give a simple
example:
$result = mysqli_query ($conn, 'select * from some_table');
$arr = mysqli_fetch_assoc ($result);
The contents of '$arr' cannot be known using only the data provided in
this code, however it's contents is statically knowable. If a static
analyser were programmable, it could parse the SQL query and query the
database to find out what keys exist in some_table. Thus it could
check for references to non-existing keys.
I suspect this is the case for a lot of 'non analysable code', it can
only function within a known set of states, but the type system is
unaware of those states.