vehiclefits/vfmagento

PHP Shortcodes

Closed this issue · 6 comments

I just installed VehicleFits on my localhost (For Magento) and it was looking pretty broken until I enabled PHP Shortcodes. I realize this is a stand alone project and it doesn't have to necessarily follow a coding style set by the Magento project, but in all the PHP projects I've been involved in the code style has never allowed for php short codes.

Is there a particular reason VehicleFits has decided to use them? If there's an advantage I don't know about I'd love to learn from your experience in why you've chosen to go this way.

Thanks

We follow PSR-2 standards which forbids short codes. Where are you seeing them in use?

Here is one example:

https://github.com/vehiclefits/Vehicle-Fits-Magento/blob/master/app/design/frontend/default/default/template/vf/vaf/search.phtml#L122

The issue here was that the JS was 404ing with shortcodes disabled due to the fact that the path couldn't be found since PHP wasn't building the proper path.

Here's a screenshot of the search module with shortcodes in PHP Disabled:
screen shot 2013-09-05 at 11 20 48 am

And then the same area with PHP Shortcodes enabled in PHP:
screen shot 2013-09-05 at 11 20 32 am

So to me it looks like short codes are being used in a number of places in the code.

Maybe this will help
#57

Since PHP 5.4.0, <?= is always available. Short open tag refers to "<?" not "<?=", the usage of "<?=" makes the code more readable in my opinion. Furthermore support for php5.3 will be dropped very soon as we begin to use features like short array syntax:

$array = array(
    "foo" => "bar",
    "bar" => "foo",
);

// as of PHP 5.4
$array = [
    "foo" => "bar",
    "bar" => "foo",
];

Both of these features are always on in php5.4, regardless of any ini settings. I've merged your pull request, but in the future we plan to begin using namespaces (dropping support for < php5.3) as well as short array syntax (dropping support for < php5.4). I've merged it for now but we'll probably go back to using "<?=" in a future version.

Strange. okay thanks for the lesson. I am using php 5.3 though, so I wonder why that php.ini setting caused it to break?

the ini setting "short_open_tags" still affects "<?=" on php5.3. As of php5.4 it does not affect it. If you were to run the code on php5.4 it would work regardless of the setting. I'm still supporting php 5.3 though which is why I merged your request. As soon as ubuntu upgrades to php5.4 so will I, just so you know