A
A
Alexander Kouznetsov2012-01-17 12:30:22
PHP
Alexander Kouznetsov, 2012-01-17 12:30:22

PHP script dependencies

I sit and look at a pile of PHP files.

There is a feeling that half can be erased. Well, or at least half of the contents of the files, given that many implement the standard functions that PHP has natively (apparently, a heavy legacy of past versions).

In general, the question is the following: is there a tool that, having received a PHP script as input, will reveal the entire chain of dependencies in the form of “function A uses function B from file Zu”, “function B from file Zyu uses function C from file Mu " etc.

Answer the question

In order to leave comments, you need to log in

8 answer(s)
N
NeX, 2012-01-17
@NeX

php is a scripting language, dependencies are determined at runtime.

I
Iskander Giniyatullin, 2012-01-17
@rednaxi

It seems to me that the tools from this review can help you , in particular Dead Code Detector (DCD) for PHP code

A
Anatoly, 2012-01-17
@taliban

It will be difficult to foresee such situations:
call_user_func( $neededFunc, $params );

L
lashtal, 2012-01-17
@lashtal

xdebug_start_code_coverage(); // back to top
...
...
$includes = array_keys(array_keys(xdebug_get_code_coverage())); // In the end

S
shagguboy, 2012-01-17
@shagguboy

phpstorm does something like that. maybe he draws diagrams.

W
wartur, 2012-01-17
@wartur

Well, I don't know such tools, but you can do this:
Put debug_backtrace in each function, and save it somewhere. Further, during normal operation, collect data about what causes where, analyze and find out something. Due to my ignorance, this is the first option that comes to my mind. If you find such a tool, please throw in the answer. THX.

E
egorinsk, 2012-01-17
@egorinsk

Take any IDE with file search, enter the name of the function, see where it is used, delete it, check if everything works. Then delete the next one. Etc.

S
Sergey Beresnev, 2012-01-19
@sectus

Write tests, refactor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question