kalimatas / php-liquid

A PHP port of Ruby's Liquid Templates
http://www.delacap.com/artikel/Liquid-Templates/
MIT License
168 stars 58 forks source link

fatal error on php 7.4.x - PHP expects '{' but got '|'... it works on php 8.x #194

Closed apazureck closed 1 year ago

apazureck commented 1 year ago

Hi,

I am using your liquid parser in a wordpress plugin. I developed that plugin unsing the latest docker image of wordpress, which uses php 8.

When I tried to deploy it on our production wordpress, which still uses php 7.4 and I got a syntax error in

liquid/vendor/thecodingmachine/safe/lib/special_cases.php:434

I fixed it like this:

// special_cases.php
- function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false
+ function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\")

It seems php 7.4 does not know the pipe symbol. Version 8 does know that.

I am not a php programmer, so I don't know what the best fix for that is. I just deleted the type definition of the function and it works now on my wordpress using php 7.

Composer says the package is compatible with php 7.3+, so I just wanted to let you know.

sanmai commented 1 year ago

As you can see, this isn't an issue with this package but rather with thecodingmachine/safe.

apazureck commented 1 year ago

OK, but it comes with your package.

sanmai commented 1 year ago

It is not. You are responsible for files in vendor. You can see they are nowhere in this repository. There's nothing I can do.

https://github.com/kalimatas/php-liquid/tree/master/vendor