Skip to content

Fix deprecation when passing null as first parameter to array_key_exists#103

Merged
Crell merged 2 commits intoCrell:masterfrom
agustingomes:issues/102
Mar 9, 2026
Merged

Fix deprecation when passing null as first parameter to array_key_exists#103
Crell merged 2 commits intoCrell:masterfrom
agustingomes:issues/102

Conversation

@agustingomes
Copy link
Copy Markdown
Contributor

@agustingomes agustingomes commented Mar 5, 2026

Description

This PR fixes a deprecation emitted when $key is null when passed to array_key_exists function.

Motivation and context

In the context of adopting the library in a proof of concept, I encountered a deprecation notice and created #102 to follow up on it. This PR fixes #102

How has this been tested?

Existing test suite already covers this scenario, but is now made visible by running the tests with error_reporting=E_ALL. can be confirmed by running vendor/bin/phpunit on the first commit.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING document.
  • My pull request addresses exactly one patch/feature.
  • I have created a branch for this patch/feature.
  • Each individual commit in the pull request is meaningful.

phpunit.xml.dist Outdated
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" failOnDeprecation="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also off topic from the bug fix, I think. I'm fine with a separate issue/PR to discuss E_ALL and deprecations, but that should be separate from the bug fix itself. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is a reasonable thing. Initially the intent was to make the issue reproducible by running the tests against the first commit, because PHPUnit would still return code 0 with the deprecations.

Once I push the next changes, I'll take a moment to create a new issue, and then it can be tackled in its own scope.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #104 and removed most changes I originally pushed on the 1st commit, leaving only the essential to make the deprecation surface on the CI checks if ran against the first commit.

The current test suite already contains test cases that would trigger the deprecation.

Therefore, this commit sets the .ini directive `error_reporting` to `E_ALL`, so these issues surface earlier.
This change fixes the situation whenever a call to `array_key_exists` with `$key` set to `null` would trigger a deprecation notice.
@Crell Crell merged commit 997fce4 into Crell:master Mar 9, 2026
6 checks passed
@agustingomes agustingomes deleted the issues/102 branch March 9, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecation thrown on Array Based Deformatter

2 participants