0

Using Eclipse Luna PHP bundle (v4.4.1) with PDT (v3.3.1), array short tags are marked as syntax errors.

E.g. in

$test = [ 4, 'some string' ];

both square brackets are errors. Is there a way make Eclipse aware of this syntax?

2 Answers 2

2

You have this message because syntax errors are raised on PHP < 5.4. Therefore you need to say to Eclipse to look for a syntax of PHP 5.4 or greater.

You can change this in Eclipse > Window > Preference > PHP > PHP Interpreter > PHP Version.

Make sure your PHP version is 5.4 or greater as well.

Eclipse Settings for PHP Interpreter

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

1 Comment

On newer versions of Eclipse it is under Eclipse -> Window -> Preferences -> PHP -> Validation
1

The question is not accurate. Eclipse does not always mark these square brackets as syntax errors. This is probably a bug in the syntax checker.

This is what I found and a workaround which is a bit of a hassle. If you know of a better way to overcome this, please share.

So, when I open an existing file that uses this syntax, all occurrences of [ and ] are errors. When I type in new array definitions using this syntax, they are fine, no error shown.

One workaround I found to get rid of the errors in an existing file:

  • open
  • select all
  • cut
  • save
  • paste
  • save

After this, there are no errors shown and if indentation and tabulation settings in Eclipse editor are matching present in the original file, you end up with an identical, unchanged file (i.e. not seen as changed by a version control system).

Comments

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.