Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.4 compat #145

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ on:

jobs:
build-test:
runs-on: ubuntu-latest

runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache Composer dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- uses: php-actions/composer@v6
- name: PHPUnit tests
run: ./vendor/bin/phpunit

2 changes: 1 addition & 1 deletion src/EDI/Analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function loadMultiSegmentsXml(array $segmentXmlFiles)
* @param array|null $rawSegments (optional) List of raw segments from EDI\Parser::getRawSegments
* @return string file
*/
public function process(array $data, array $rawSegments = null): string
public function process(array $data, ?array $rawSegments = null): string
{
$r = [];
foreach ($data as $nrow => $segment) {
Expand Down
14 changes: 7 additions & 7 deletions src/EDI/Interpreter.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ class Interpreter
* @param string $xmlMsg Path to XML Message representation
* @param array $xmlSeg Segments processed by EDI\Analyser::loadSegmentsXml or EDI\Mapping\MappingProvider
* @param array $xmlSvc Service segments processed by EDI\Analyser::loadSegmentsXml or EDI\Mapping\MappingProvider
* @param array|null $messageTextConf Personalisation of error messages
* @param array|null $messageTextConf Personalization of error messages
*/
public function __construct(string $xmlMsg, array $xmlSeg, array $xmlSvc, array $messageTextConf = null)
public function __construct(string $xmlMsg, array $xmlSeg, array $xmlSvc, ?array $messageTextConf = null)
{
// simplexml_load_file: This can be affected by a PHP bug #62577 (https://bugs.php.net/bug.php?id=62577)
$xmlData = \file_get_contents($xmlMsg);
Expand Down Expand Up @@ -735,7 +735,7 @@ private function doAddArray(array &$array, array &$jsonMessage, $maxRepeat = 1)
*
* @param int|null $segmentIdx
*/
private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, array &$errors = null): array
private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, ?array &$errors = null): array
{
$id = $segment[0];

Expand Down Expand Up @@ -797,7 +797,7 @@ private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, ar
//print_r($d_sub_desc_attr);
//print_r($d_detail);
//die();
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
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
if (isset($this->codes[$d_sub_desc_attr['id']][$d_detail])) {
$d_detail = $this->codes[$d_sub_desc_attr['id']][$d_detail];
}
Expand All @@ -817,15 +817,15 @@ private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, ar
} else {
$d_sub_desc_attr = $sub_details_desc[0]['attributes'];

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
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
if (isset($this->codes[$d_sub_desc_attr['id']][$detail]) && $this->codes[$d_sub_desc_attr['id']][$detail]) {
$detail = $this->codes[$d_sub_desc_attr['id']][$detail];
}
}
$jsoncomposite[$d_sub_desc_attr[$this->outputKey]] = $detail;
}
} else {
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
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
if (isset($this->codes[$d_desc_attr['id']][$detail]) && $this->codes[$d_desc_attr['id']][$detail]) {
$detail = $this->codes[$d_desc_attr['id']][$detail];
}
Expand Down Expand Up @@ -869,7 +869,7 @@ private function processService(array &$segments): array

public function rebuildArray()
{
if ($this->codes !== null) {
if (isset($this->codes)) {
throw new \LogicException('Run the Interpreter without calling setCodes()');
}
$unh = $this->serviceSeg['interchangeHeader'];
Expand Down
3 changes: 2 additions & 1 deletion src/EDI/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ public function readEdiDataValueReq($filter, int $l1, $l2 = false)
* @param int $l1 first level item number (start by 1)
* @param false|int $l2 second level item number (start by 0)
* @param bool $required if required, but no exist, register error
* @param int|null $offset if multiple segments found, get segment by offset
* @return string|null
*/
public function readEdiDataValue($filter, int $l1, $l2 = false, bool $required = false, int $offset = null)
public function readEdiDataValue($filter, int $l1, $l2 = false, bool $required = false, ?int $offset = null)
{
$found_segments = [];
$segment_name = $filter;
Expand Down