Phpinspectionsea: Isset, empty, ?? usage detection in global scope

Created on 24 Nov 2017  路  8Comments  路  Source: kalessil/phpinspectionsea

Hello everyone. Is there any way to deny usage of isser, empty and ?? ?
We are against it in html files (templates) .
Maybe this can be a new inspection for Ultimate edition.

question

All 8 comments

What exactly is the reason behind this?

Html files are used as templates in our project. If you use isset in html files (global scope) then you can have a big problems if someone rename or forgot to pass variable. There will be no error and you need manually check site (how does it looks like).

Maybe we can create deprecated functions inspection? I can implement it. Users can specify functions fqn and scopes. (I can do that for ultimate edition)

Ah, ok. Let's dig deeper before doing anything. Are we talking about the specific framework and templating engine?

We are using https://github.com/thephpleague/plates
and custom controllers.

Seems to be lack of templating engine support (or engines in general).
I can not advise anything ATM or say "go ahead" - such inspection is project specific and probably needs custom indexer.

Ok then. I will implement this inspection in closed source plugin. And then
if you /someone will be interested I can just port it to ultimate.

P.S. My idea:

  1. detect specific functions and mark them as deprecated
  2. Configure inspection scope

I'd target the templates invocation and dispatched parameters.
The resolved the template and reported the invocation if not all template params get dispatched.

Then it'll be no need to use the mentioned constructs at all (so the root cause gets reported, not symptoms). EDIT: but for sure you can report both ways.

@kalessil yep. This is my second plan. It is harder to do, but it would be right. Thanks for the help.

Was this page helpful?
0 / 5 - 0 ratings