summaryrefslogtreecommitdiffstats
path: root/upstream.patch
blob: c633df453ed7ba3452d7de5947b3848995605b85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
From 4df543b41f574666dea020aeaf5e865488968053 Mon Sep 17 00:00:00 2001
From: viest <wjx@php.net>
Date: Mon, 18 May 2026 20:45:11 +0800
Subject: [PATCH] fix(7.0): make phpt suite + examples parse on PHP 7.0, extend
 CI matrix
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reported in #565 by Remi: package.xml + composer.json declare >= 7.0 but
three tests use 7.1-only syntax and one float assertion is sensitive to
PHP 7.0's serialize_precision default.

Tests / examples:
- tests/conditional_format.phpt: replace `foreach (… as [\$range, \$cf])`
  with `foreach (… as \$rule) { list(\$range, \$cf) = \$rule; }` (short-list
  destructuring is PHP 7.1).
- tests/examples_smoke.phpt: drop `: void` return type from the closure
  (void return type is PHP 7.1).
- tests/open_xlsx_next_row_with_formula.phpt: switch the float-bearing
  line to --EXPECTF-- + %f so it accepts both '3.14' (7.1+) and
  '3.1400000000000001' (7.0, default serialize_precision=17).
- examples/11_read_styles.php: drop `?array` nullable parameter syntax
  (PHP 7.1).

CI:
- main.yml matrix gets PHP 7.0/7.1/7.2/7.3 jobs on ubuntu-22.04 so the
  declared minimum is actually exercised on every push. macOS-14 stays
  on 7.4+ because setup-php's older bottles for ARM64 are unreliable.
---
 .github/workflows/main.yml                 | 13 +++++++++++++
 examples/11_read_styles.php                |  3 ++-
 tests/conditional_format.phpt              |  5 ++++-
 tests/examples_smoke.phpt                  |  5 +++--
 tests/open_xlsx_next_row_with_formula.phpt |  4 ++--
 5 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 8919ff1..ef205a8 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -11,6 +11,19 @@ jobs:
       matrix:
         operating-system: [ubuntu-22.04, macos-14]
         php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
+        include:
+          # Older PHP only on Linux — setup-php's macOS bottles for 7.0-7.3
+          # are flaky on macos-14 (ARM64) and we don't ship binaries for
+          # those combos anyway. Linux coverage is the one that matters for
+          # downstream distros still on 7.x (EPEL etc.).
+          - operating-system: ubuntu-22.04
+            php-versions: '7.0'
+          - operating-system: ubuntu-22.04
+            php-versions: '7.1'
+          - operating-system: ubuntu-22.04
+            php-versions: '7.2'
+          - operating-system: ubuntu-22.04
+            php-versions: '7.3'
 
     steps:
       - name: Checkout
diff --git a/examples/11_read_styles.php b/examples/11_read_styles.php
index 0fee464..8da9fe5 100644
--- a/examples/11_read_styles.php
+++ b/examples/11_read_styles.php
@@ -26,7 +26,8 @@
     ->openFile($name)
     ->openSheet();
 
-$fmt_font = static function (?array $font): string {
+/* No `?array` nullable-type — that would require PHP 7.1. */
+$fmt_font = static function ($font) {
     if (!$font) return 'default';
     return sprintf('%s %dpt color=%s%s%s',
         $font['name'], $font['size'], $font['color'],
diff --git a/tests/conditional_format.phpt b/tests/conditional_format.phpt
index f6d0723..c3a28f4 100644
--- a/tests/conditional_format.phpt
+++ b/tests/conditional_format.phpt
@@ -53,7 +53,10 @@ $rules = [
 ];
 
 $excel->insertText(0, 0, 'cf');
-foreach ($rules as [$range, $cf]) {
+/* Plain list() destructuring instead of `as [$range, $cf]` so the test
+ * parses on PHP 7.0 (short-list destructuring is a 7.1 feature). */
+foreach ($rules as $rule) {
+    list($range, $cf) = $rule;
     $excel->conditionalFormatRange($range, $cf);
 }
 $path = $excel->output();
diff --git a/tests/examples_smoke.phpt b/tests/examples_smoke.phpt
index 16d4c52..c4017ef 100644
--- a/tests/examples_smoke.phpt
+++ b/tests/examples_smoke.phpt
@@ -17,8 +17,9 @@ if (empty($files)) {
 }
 
 /* Run each example in an isolated scope (closure) so they don't bleed
- * variables into each other, while still keeping the loaded extension. */
-$run = static function (string $file): void {
+ * variables into each other, while still keeping the loaded extension.
+ * No `: void` return type — that would require PHP 7.1. */
+$run = static function ($file) {
     /* The example writes to stdout — capture it so the smoke test only
      * cares about whether the script ran without a fatal. */
     ob_start();
diff --git a/tests/open_xlsx_next_row_with_formula.phpt b/tests/open_xlsx_next_row_with_formula.phpt
index b754363..b0b23b1 100644
--- a/tests/open_xlsx_next_row_with_formula.phpt
+++ b/tests/open_xlsx_next_row_with_formula.phpt
@@ -47,11 +47,11 @@ var_dump($excel->nextRowWithFormula());
 <?php
 @unlink(__DIR__ . '/open_xlsx_next_row_with_formula.xlsx');
 ?>
---EXPECT--
+--EXPECTF--
 [0] type=string value='n' style_id=0
 [1] type=string value='s' style_id=0
 [0] type=number value=42
 [1] type=string value='hello'
-[0] type=number value=3.14
+[0] type=number value=%f
 [1] type=string value='world'
 NULL