Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStorm inspection rules

Tags:

phpstorm

I am using PHPStorm IDE, and it has a very useful feature, inspect the errors, problems in php code.

I know how can i turn off the options globally. For example, here is a simple code:

require_once ('../config/configuration.inc');
define ("LIB_PATH", BASE_PATH . '/libraries/') ; //originally in conf i put here for test
require_once (LIB_PATH.'JFMF/Core/JFMF_APP.php');

$App = new JFMF_App();

The inspector warn me, i should define the JFMF_APP class, and also notice me about: i shold define LIB_PATH, what i don't undestand, because the definition is there, and if it is not enough, require_once warn me to use PHPDoc to resolve this problem (if i do that doesn't helps), and some other annoying warnings.

Anyhow, focus on the problem, originally the definition of LIB_PATH in the configuration.inc.

My question is, how can i tell to PHPStorm, if there are an include statement, process it, and register the classes, so my objects come from defined classes. I hope it's understable, my english is not so good.

The code is working code, and run without errors.

Maybe other PHPStorm beginners would know this also.

like image 766
vaso123 Avatar asked Dec 25 '11 21:12

vaso123


1 Answers

To turn off errors in the inpection for a single line hit F2 to go the error. Then hit Alt-Enter to bring up the inspections menu, then navigate from the popup menu to the error menU (this can usually be done by simply hitting the right arrow) and select "Suppress for statement". A comment will appear in your code to suppress the error for that statement.

Comment Example: An annotation like /** @noinspection Php[...]Inspection */

If you haven't included the library within your project, you can add it to your "External Libraries" and all the class and objects will be indexed and available to your project. To do this click anywhere within the Project Window and hit F4. Or go to the project window, right click on the "External Libraries" (it will be at the bottom)

enter image description here

and select "Configure PHP Include Paths".

enter image description here

like image 116
Kris Erickson Avatar answered Oct 05 '22 01:10

Kris Erickson