mustangostang / spyc

A simple YAML loader/dumper class for PHP
MIT License
701 stars 206 forks source link

PHP 5.4 code breaks PHP 5.3.1+ compatibility #86

Open IvoWams opened 4 years ago

IvoWams commented 4 years ago

https://github.com/mustangostang/spyc/blob/4627c838b16550b666d15aeae1e5289dd5b77da0/Spyc.php#L188

This line and others has PHP 5.4+ style array brackets, however the version in composer.json still has requires >= 5.3.1.

kAlvaro commented 4 years ago

There're only two occurrences (I'm unfortunately not familiar with git as to submit a pull request):

Index: Spyc.php
===================================================================
--- Spyc.php    (revision 1370)
+++ Spyc.php    (revision 1371)
@@ -155,7 +155,7 @@
      * @param string $input Path of YAML file or string containing YAML
      * @param array set options
      */
-  public static function YAMLLoad($input, $options = []) {
+  public static function YAMLLoad($input, $options = array()) {
     $Spyc = new Spyc;
     foreach ($options as $key => $value) {
         if (property_exists($Spyc, $key)) {
@@ -185,7 +185,7 @@
      * @param string $input String containing YAML
      * @param array set options
      */
-  public static function YAMLLoadString($input, $options = []) {
+  public static function YAMLLoadString($input, $options = array()) {
     $Spyc = new Spyc;
     foreach ($options as $key => $value) {
         if (property_exists($Spyc, $key)) {
kAlvaro commented 4 years ago

I found a workaround when this library is a dependency of a third-party package. Set previous version as direct dependency and Composer will use that, e.g.:

{
 "config": {
    "platform": {
      "php": "5.3.3"
    }
  },
  "require": {
    "piwik/device-detector": "^3.11",
    "mustangostang/spyc": "0.6.2"
  }
}