diff --git a/.github/workflows/lint-and-analyse-php.yml b/.github/workflows/lint-and-analyse-php.yml index ce224a2d..69678477 100644 --- a/.github/workflows/lint-and-analyse-php.yml +++ b/.github/workflows/lint-and-analyse-php.yml @@ -36,7 +36,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [ '7.4' ] + php-version: [ '7.2' ] steps: - name: Checkout code uses: actions/checkout@v6 diff --git a/src/Tools/CustomJsonSerializer.php b/src/Tools/CustomJsonSerializer.php index a46d4916..e532b96b 100644 --- a/src/Tools/CustomJsonSerializer.php +++ b/src/Tools/CustomJsonSerializer.php @@ -9,6 +9,7 @@ use Zumba\JsonSerializer\JsonSerializer; use function in_array; +use function method_exists; use const PHP_VERSION_ID; @@ -45,6 +46,7 @@ class CustomJsonSerializer extends JsonSerializer 'EVENT_OPTIONS', 'USER_OPTIONS', 'asciiMap', + 'trace', ]; /** @@ -65,11 +67,15 @@ protected function extractObjectData($value, $ref, $properties) } try { - $propRef = $ref->getProperty($property); + $propRef = $this->getReflectionProperty($ref, $property); if (PHP_VERSION_ID < 80100) { $propRef->setAccessible(true); } + if (method_exists($propRef, 'isInitialized') && ! $propRef->isInitialized($value)) { + continue; + } + $data[$property] = $propRef->getValue($value); } catch (ReflectionException $e) { $data[$property] = $value->$property; diff --git a/tests/data/parser/parseExplain14.out b/tests/data/parser/parseExplain14.out index 63fe473a..998de84d 100644 --- a/tests/data/parser/parseExplain14.out +++ b/tests/data/parser/parseExplain14.out @@ -220,7 +220,9 @@ "message": "Unrecognized statement type.", "code": 0, "file": "/src/Parser.php", - "line": 628 + "line": 628, + "string": "", + "previous": null } ] }, diff --git a/tests/data/parser/parseExplainErr1.out b/tests/data/parser/parseExplainErr1.out index ef5cc35a..04ed97e7 100644 --- a/tests/data/parser/parseExplainErr1.out +++ b/tests/data/parser/parseExplainErr1.out @@ -137,7 +137,9 @@ "message": "An expression was expected.", "code": 0, "file": "/src/Parser.php", - "line": 628 + "line": 628, + "string": "", + "previous": null }, { "@type": "PhpMyAdmin\\SqlParser\\Exceptions\\ParserException", @@ -147,7 +149,9 @@ "message": "An expression was expected.", "code": 0, "file": "/src/Parser.php", - "line": 628 + "line": 628, + "string": "", + "previous": null } ] },