"Unresolved variable" for markup in PHP echo; "Unresolved function..." for jQuery methods

Yeah, I know my code is very old with no separation of concerns (most of it written before PHPStorm was even invented), but it works, and I can't immediately refactor it all, so bear with me. Much of the HTML markup is output with PHP echo statements because multiple variables are used to construct it. Example (again, please don't cringe):

echo "<form name=\"donationform\" id=\"donationform\" method=\"POST\" action=\"${_SERVER['PHP_SELF']}?pid=${_GET['pid']}#donations\" onSubmit=\"return ValidateDonation()\">\n";

The code itself works fine, but PHPStorm doesn't recognize the markup, so I get a pile of PHPStorm inspection errors in the Javascript sections like "Unresolved variable donationform". My code is littered with this stuff, making it hard to spot real errors. I'm gradually refactoring, but meanwhile, are there any suggestions about how to deal with this? Can I turn off certain types of inspections on a per-file basis (i.e. not-yet-refactored files), for example?

I also get "Unresolved function or method" errors for some methods like ajaxError(), post(), etc. that are in jQuery and a couple other JS files. I can only assume that is because of something else old-fashioned in my code, but I can't figure out what - my links to those JS files are not in echo statements. I am using minified versions, but surely PHPStorm can still read them. Some methods in minified files are found by PHPStorm with no problem, so it's not that simple.

Clues are appreciated.

0

Hi there,

>Can I turn off certain types of inspections on a per-file basis (i.e. not-yet-refactored files), for example?

Yes. On per-inspection basis.

  • Create custom scope first that will include all such files
  • Find that particular Inspection and configure it by turning it off for that scope.

https://stackoverflow.com/a/46345422/783119 or https://stackoverflow.com/a/22959267/783119 -- they have screenshots and help pages links.

 

>I also get "Unresolved function or method" errors for some methods like ajaxError(), post(), etc. that are in jQuery and a couple other JS files.

Try placing normal (not minified) version of jQuery in your project .. and make it a JavaScript library in IDE settings (together with minified version)

Some of these official blog posts are old, but may still be useful:

Official help pages:

 

0

请先登录再写评论。