1

I'm trying to understand unexpected behavior by PHPstorm. I've two files without any include or required definitions.

// file1.php <?php $var = new class1();

// file2.php <?php class class1 { }

I would expect that class1 is undefined in file1, because file2 is not included. But phpstorm shows no warning. CTRL-B jumps to the declaration in file2. The option "Ignore include and require statements" is unchecked. Could someone explain this to me?

1
  • PhpStorm does not really care about include/require statements, especially for classes/interfaces/traits. Class autoloading is normal practice these days: you may have just single require in your whole project (in entry/bootstrap file) and all classes will be loaded automatically (for example, by autoloader generated by Composer). Therefore: it's not a bug at all. Commented Oct 31, 2014 at 9:49

2 Answers 2

2

phpstorm doesn't know everything about your context. it is possible that the files are required by some other file one after another so everything will just work. Also there is a good chance, that you are using autoloader/composer (who doesn't?) which will take care of the issue.

So, I think they wouldn't consider this an error, as they wouldn't be able to properly filter false-positives if they enabled such warning

Sign up to request clarification or add additional context in comments.

Comments

0

This is most likely a bug in PHPStorm itself, since PHP throws an exception.

Fatal error: Class 'class1' not found in /srv/www/htdocs/swaggityswoogityswoo/f1.php on line 5 Call Stack: 0.0003 629360 1. {main}() /srv/www/htdocs/swaggityswoogityswoo/f1.php:0 

Since I upgraded to the latest versions, it seems to behave strange. For example, when i try to merge a file where the deployed adn the local file both contain contain 'text-align: left', he wants to merge it into 'text-align: center'.

Just wait until they release another version, maybe they'll be able to fix this bug.

1 Comment

1) It's not a bug but the way how IDE works with classes 2) Other issues you have mentioned have nothing to do with the actual question. If you found an issue -- please report to their Issue Tracker at youtrack.jetbrains.com/issues/WI

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.