From 29cde98dd8213c40337e5209b8ee1bb9432a0b8a Mon Sep 17 00:00:00 2001 From: Phillip Hartin Date: Fri, 31 Aug 2018 10:14:21 +1000 Subject: [PATCH 1/4] Replaces use of deprecated each function to improve PHP7 compatibility --- site/addons/Imgix/ImgixTags.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/site/addons/Imgix/ImgixTags.php b/site/addons/Imgix/ImgixTags.php index 3560afa..52928c9 100644 --- a/site/addons/Imgix/ImgixTags.php +++ b/site/addons/Imgix/ImgixTags.php @@ -21,17 +21,18 @@ protected function categorizedAttributes() { unset($attrs['path']); - while (list($key, $val) = each($attrs)) { - $is_html_attr = in_array($key, self::$html_attributes); - $is_data_attr = strpos($key, 'data-') === 0; - $is_aria_attr = strpos($key, 'aria-') === 0; - - if ($is_html_attr || $is_data_attr || $is_aria_attr) { - $categorized_attrs['img_attributes'][$key] = $val; - } else { - $categorized_attrs['imgix_attributes'][$key] = $val; - } - } + if (is_array($attrs)) { + foreach ($attrs as $key => $val) { + $is_html_attr = in_array($key, self::$html_attributes); + $is_data_attr = strpos($key, 'data-') === 0; + $is_aria_attr = strpos($key, 'aria-') === 0; + if ($is_html_attr || $is_data_attr || $is_aria_attr) { + $categorized_attrs['img_attributes'][$key] = $val; + } else { + $categorized_attrs['imgix_attributes'][$key] = $val; + } + } + } return $categorized_attrs; } @@ -48,9 +49,12 @@ protected function buildHtmlAttributes($categorized_attrs) { $html = ''; - while (list($key, $val) = each($img_attributes)) { - $html .= " $key=\"$val\""; - } + if (is_array($img_attributes)) { + foreach ($img_attributes as $key => $val) { + $html .= " $key=\"$val\""; + break; + } + } return $html; } From 6386a76b548cdfe7feecf973a9a3cf91de33961d Mon Sep 17 00:00:00 2001 From: Phillip Hartin Date: Tue, 4 Sep 2018 17:17:33 +1000 Subject: [PATCH 2/4] Removes unnecessary break during HTML attribute building --- site/addons/Imgix/ImgixTags.php | 1 - 1 file changed, 1 deletion(-) diff --git a/site/addons/Imgix/ImgixTags.php b/site/addons/Imgix/ImgixTags.php index 52928c9..1765892 100644 --- a/site/addons/Imgix/ImgixTags.php +++ b/site/addons/Imgix/ImgixTags.php @@ -52,7 +52,6 @@ protected function buildHtmlAttributes($categorized_attrs) { if (is_array($img_attributes)) { foreach ($img_attributes as $key => $val) { $html .= " $key=\"$val\""; - break; } } From fb85daedb50f5752a5a16689b23bf1ef45096174 Mon Sep 17 00:00:00 2001 From: Sherwin H Date: Fri, 20 Sep 2019 16:18:31 -0400 Subject: [PATCH 3/4] style: make indentations consistent --- site/addons/Imgix/ImgixTags.php | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/site/addons/Imgix/ImgixTags.php b/site/addons/Imgix/ImgixTags.php index 1765892..407d410 100644 --- a/site/addons/Imgix/ImgixTags.php +++ b/site/addons/Imgix/ImgixTags.php @@ -21,18 +21,18 @@ protected function categorizedAttributes() { unset($attrs['path']); - if (is_array($attrs)) { - foreach ($attrs as $key => $val) { - $is_html_attr = in_array($key, self::$html_attributes); - $is_data_attr = strpos($key, 'data-') === 0; - $is_aria_attr = strpos($key, 'aria-') === 0; - if ($is_html_attr || $is_data_attr || $is_aria_attr) { - $categorized_attrs['img_attributes'][$key] = $val; - } else { - $categorized_attrs['imgix_attributes'][$key] = $val; - } - } - } + if (is_array($attrs)) { + foreach ($attrs as $key => $val) { + $is_html_attr = in_array($key, self::$html_attributes); + $is_data_attr = strpos($key, 'data-') === 0; + $is_aria_attr = strpos($key, 'aria-') === 0; + if ($is_html_attr || $is_data_attr || $is_aria_attr) { + $categorized_attrs['img_attributes'][$key] = $val; + } else { + $categorized_attrs['imgix_attributes'][$key] = $val; + } + } + } return $categorized_attrs; } @@ -49,11 +49,11 @@ protected function buildHtmlAttributes($categorized_attrs) { $html = ''; - if (is_array($img_attributes)) { - foreach ($img_attributes as $key => $val) { - $html .= " $key=\"$val\""; - } - } + if (is_array($img_attributes)) { + foreach ($img_attributes as $key => $val) { + $html .= " $key=\"$val\""; + } + } return $html; } From f69de7ab58354229ca35a7e8ae83f0e41897c1fa Mon Sep 17 00:00:00 2001 From: Sherwin H Date: Fri, 20 Sep 2019 16:52:54 -0400 Subject: [PATCH 4/4] ci(travis): set default dist to trusty, php 5 does not build on xenial --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bb95054..d3fe39e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +dist: trusty language: php php: - '7.0' @@ -5,4 +6,4 @@ php: - '5.5' install: - 'cd site/addons/Imgix && composer install' -script: 'echo "Tests pending a harness from Statamic. imgix-php is well-tested though, and that''s there most of imgix-statamic''s logic lives."' +script: 'echo "Tests pending a harness from Statamic. imgix-php is well-tested though, and that''s where most of imgix-statamic''s logic lives."'