lisachenko / z-engine

:zap: PHP Engine Direct API
MIT License
448 stars 22 forks source link

Dead code detection? #35

Closed garex closed 4 years ago

garex commented 4 years ago

Is it possible to use this lib for dead-code detection? If it is, then it will be good to state it in README. Or provide some example.

lisachenko commented 4 years ago

@garex I think it is impossible to detect dead-code with this tool or I don't know how to do it right now. I know about phan, it uses ast extension to work with PHP native structures. With this library you could access AST information and analyze it somehow to detect dead-code. But it is very complex task...

garex commented 4 years ago
  1. Add aspect to all methods in some dir.
  2. When code goes inside it mark once somehow, that method X is alive somewhere.
  3. After some time, gather info about live methods from somewhere, gather info about all methods (statically). Diff it and you will see walking deads.
lisachenko commented 4 years ago

Ok, I see now what you want. In theory, this should be doable, but in practice there will be a lot of pain to do that. Therefore I can start with method hooks. Because current implementation can only replace existing method or function with closure. And AOP requires an ability to call original code (but how?).

garex commented 4 years ago

I dunno ))


Alexander Ustimenko +7 (952) 918-02-20

ср, 12 февр. 2020 г. в 17:21, Alexander Lisachenko <notifications@github.com

:

Ok, I see now what you want. In theory, this should be doable, but in practice there will be a lot of pain to do that. Therefore I can start with method hooks. Because current implementation can only replace existing method or function with closure. And AOP requires an ability to call original code (but how?).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lisachenko/z-engine/issues/35?email_source=notifications&email_token=AAATBHIYP7J3IHJOYVDLRTLRCPESRA5CNFSM4KSHMZOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELQHLBY#issuecomment-585135495, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATBHPC7B5EATAHXDBPHBTRCPESRANCNFSM4KSHMZOA .

lisachenko commented 4 years ago

This is question for me to solve :) I’ll comment here when method hooks will be available.

dzentota commented 4 years ago

Maybe you can find answer here https://github.com/krakjoe/tombs

garex commented 4 years ago

Maybe you can find answer here https://github.com/krakjoe/tombs

We already was there )) https://github.com/krakjoe/tombs/graphs/contributors