Skip to content

Commit 385dd28

Browse files
authored
Merge pull request #145 from swiffer/php84-compat
PHP 8.4 compat
2 parents 75eb9d6 + 0239aa3 commit 385dd28

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

.github/workflows/ci.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ on:
99

1010
jobs:
1111
build-test:
12-
runs-on: ubuntu-latest
13-
12+
runs-on: ubuntu-24.04
1413
steps:
15-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1615
- name: Cache Composer dependencies
17-
uses: actions/cache@v3
16+
uses: actions/cache@v4
1817
with:
1918
path: /tmp/composer-cache
2019
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
2120
- uses: php-actions/composer@v6
2221
- name: PHPUnit tests
2322
run: ./vendor/bin/phpunit
24-

src/EDI/Analyser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function loadMultiSegmentsXml(array $segmentXmlFiles)
166166
* @param array|null $rawSegments (optional) List of raw segments from EDI\Parser::getRawSegments
167167
* @return string file
168168
*/
169-
public function process(array $data, array $rawSegments = null): string
169+
public function process(array $data, ?array $rawSegments = null): string
170170
{
171171
$r = [];
172172
foreach ($data as $nrow => $segment) {

src/EDI/Interpreter.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ class Interpreter
126126
* @param string $xmlMsg Path to XML Message representation
127127
* @param array $xmlSeg Segments processed by EDI\Analyser::loadSegmentsXml or EDI\Mapping\MappingProvider
128128
* @param array $xmlSvc Service segments processed by EDI\Analyser::loadSegmentsXml or EDI\Mapping\MappingProvider
129-
* @param array|null $messageTextConf Personalisation of error messages
129+
* @param array|null $messageTextConf Personalization of error messages
130130
*/
131-
public function __construct(string $xmlMsg, array $xmlSeg, array $xmlSvc, array $messageTextConf = null)
131+
public function __construct(string $xmlMsg, array $xmlSeg, array $xmlSvc, ?array $messageTextConf = null)
132132
{
133133
// simplexml_load_file: This can be affected by a PHP bug #62577 (https://bugs.php.net/bug.php?id=62577)
134134
$xmlData = \file_get_contents($xmlMsg);
@@ -735,7 +735,7 @@ private function doAddArray(array &$array, array &$jsonMessage, $maxRepeat = 1)
735735
*
736736
* @param int|null $segmentIdx
737737
*/
738-
private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, array &$errors = null): array
738+
private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, ?array &$errors = null): array
739739
{
740740
$id = $segment[0];
741741

@@ -797,7 +797,7 @@ private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, ar
797797
//print_r($d_sub_desc_attr);
798798
//print_r($d_detail);
799799
//die();
800-
if ($this->codes !== null && isset($this->codes[$d_sub_desc_attr['id']]) && is_array($this->codes[$d_sub_desc_attr['id']])) { //if codes is set enable translation of the value
800+
if (isset($this->codes) && isset($this->codes[$d_sub_desc_attr['id']]) && is_array($this->codes[$d_sub_desc_attr['id']])) { //if codes is set enable translation of the value
801801
if (isset($this->codes[$d_sub_desc_attr['id']][$d_detail])) {
802802
$d_detail = $this->codes[$d_sub_desc_attr['id']][$d_detail];
803803
}
@@ -817,15 +817,15 @@ private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, ar
817817
} else {
818818
$d_sub_desc_attr = $sub_details_desc[0]['attributes'];
819819

820-
if ($this->codes !== null && isset($this->codes[$d_sub_desc_attr['id']]) && is_array($this->codes[$d_sub_desc_attr['id']])) { //if codes is set enable translation of the value
820+
if (isset($this->codes) && isset($this->codes[$d_sub_desc_attr['id']]) && is_array($this->codes[$d_sub_desc_attr['id']])) { //if codes is set enable translation of the value
821821
if (isset($this->codes[$d_sub_desc_attr['id']][$detail]) && $this->codes[$d_sub_desc_attr['id']][$detail]) {
822822
$detail = $this->codes[$d_sub_desc_attr['id']][$detail];
823823
}
824824
}
825825
$jsoncomposite[$d_sub_desc_attr[$this->outputKey]] = $detail;
826826
}
827827
} else {
828-
if ($this->codes !== null && isset($this->codes[$d_desc_attr['id']]) && is_array($this->codes[$d_desc_attr['id']])) { //if codes is set enable translation of the value
828+
if (isset($this->codes) && isset($this->codes[$d_desc_attr['id']]) && is_array($this->codes[$d_desc_attr['id']])) { //if codes is set enable translation of the value
829829
if (isset($this->codes[$d_desc_attr['id']][$detail]) && $this->codes[$d_desc_attr['id']][$detail]) {
830830
$detail = $this->codes[$d_desc_attr['id']][$detail];
831831
}
@@ -869,7 +869,7 @@ private function processService(array &$segments): array
869869

870870
public function rebuildArray()
871871
{
872-
if ($this->codes !== null) {
872+
if (isset($this->codes)) {
873873
throw new \LogicException('Run the Interpreter without calling setCodes()');
874874
}
875875
$unh = $this->serviceSeg['interchangeHeader'];

src/EDI/Reader.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,10 @@ public function readEdiDataValueReq($filter, int $l1, $l2 = false)
172172
* @param int $l1 first level item number (start by 1)
173173
* @param false|int $l2 second level item number (start by 0)
174174
* @param bool $required if required, but no exist, register error
175+
* @param int|null $offset if multiple segments found, get segment by offset
175176
* @return string|null
176177
*/
177-
public function readEdiDataValue($filter, int $l1, $l2 = false, bool $required = false, int $offset = null)
178+
public function readEdiDataValue($filter, int $l1, $l2 = false, bool $required = false, ?int $offset = null)
178179
{
179180
$found_segments = [];
180181
$segment_name = $filter;

0 commit comments

Comments
 (0)