0

On Heroku I'm getting a "Parse error: syntax error, unexpected '[' in /app/www/Embed/UrlResolver.php on line 35" at this file: https://github.com/oscarotero/Embed/blob/master/Embed/UrlResolver.php

The strange thing is it works fine on my local environment,(MAMP). One difference is Heroku is using PHP 5.3.27 and my MAMP version is 5.4.10, but it seems unlikely that that's the problem (the script calls for 'PHP 5.3+'). I'd love to test it but I haven't found a 5.4 buildpack that doesn't make everything go kablooey.

Does anything in this terminal output explain the error?

-----> Removing .DS_Store files
-----> PHP app detected
-----> Bundling mcrypt version 2.5.8
-----> Bundling Apache version 2.2.25
-----> Bundling PHP version 5.3.27
-----> Discovering process types
   Procfile declares types -> (none)
   Default types for PHP   -> web

Does anybody know why this is happening?

1 Answer 1

1

iirc correctly PHP 5.4 supports

$value = somethingWhichReturnsAnArray()[37];

whereas PHP 5.3 does not and would report an unexpected '['. This might be that. Perhaps the library you're using which says it's 5.3+ actually isn't. Look up line 35 of that file and see if it's doing that. If so, it should be easily fixable by using an intermediate variable for the array/collection returned.

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

2 Comments

Line 35 is: return [$content, $result];
That's definitely a 5.4 feature. Change it to return array($content, $result); and you should be fine. Though it's likely the author has also used 5.4+ language features elsewhere in the code as well. Either way, it's worth reporting as a bug to whoever wrote it.

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.