Skip to content

[codex] Fix getEnv nullable default deprecation#55

Merged
ChiragAgg5k merged 1 commit intomainfrom
codex/fix-getenv-nullable-deprecation
Mar 28, 2026
Merged

[codex] Fix getEnv nullable default deprecation#55
ChiragAgg5k merged 1 commit intomainfrom
codex/fix-getenv-nullable-deprecation

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

Summary

  • make Platform::getEnv() use an explicit nullable type for the optional default value
  • update the unit test to validate current env lookup, fallback values, and null defaults without relying on a fixed argc
  • include the current composer.json and composer.lock metadata changes in the PR

Why

PHP now deprecates implicitly nullable parameters such as string $default = null. This change removes the deprecation at Platform::getEnv() and keeps the test stable across different runtime environments.

Impact

Consumers no longer hit the deprecation notice from Platform::getEnv() on newer PHP versions, and the test now checks behavior rather than shell-specific argument counts.

Validation

  • php -l src/Platform/Platform.php
  • php -l tests/unit/GetEnvTest.php
  • vendor/bin/phpunit --configuration phpunit.xml --filter GetEnvTest

Root Cause

Platform::getEnv() declared string $default = null, which relies on implicit nullability that is deprecated in newer PHP versions.

@ChiragAgg5k ChiragAgg5k marked this pull request as ready for review March 28, 2026 15:19
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 28, 2026

Greptile Summary

This PR makes a clean, targeted fix to remove the PHP implicitly-nullable-parameter deprecation in Platform::getEnv() by changing string $default = null to ?string $default = null, and updates the unit test to be environment-independent.

  • src/Platform/Platform.php: ?string $default = null is the correct explicit-nullability syntax; the fix is backwards-compatible — all existing call-sites continue to work unchanged.
  • tests/unit/GetEnvTest.php: The test now validates three distinct behaviours (key present, missing key with fallback, missing key with no default) and no longer relies on a hard-coded argc value, making it portable across CLI and non-CLI environments.
  • composer.json / composer.lock: Only cosmetic alphabetical reordering of require entries; no dependency or version changes.

Confidence Score: 5/5

Safe to merge — the change is minimal, backwards-compatible, and correctly addresses the PHP deprecation.

All four changed files contain only correct, low-risk modifications: a one-character type-hint fix in the source, an improved test, and cosmetic composer reordering. No logic changes, no version bumps, no breaking changes.

No files require special attention.

Important Files Changed

Filename Overview
src/Platform/Platform.php Added ? to make $default explicitly nullable, removing the PHP deprecation warning on newer PHP versions
tests/unit/GetEnvTest.php Test rewritten to validate env lookup, fallback, and null-default behaviour without relying on a hard-coded argc value
composer.json Cosmetic alphabetical reordering of require entries; no version or dependency changes
composer.lock Content-hash updated to reflect the reordering in composer.json; no package versions changed

Reviews (1): Last reviewed commit: "Fix getEnv nullable default deprecation" | Re-trigger Greptile

@ChiragAgg5k ChiragAgg5k merged commit 16d385e into main Mar 28, 2026
7 checks passed
@ChiragAgg5k ChiragAgg5k deleted the codex/fix-getenv-nullable-deprecation branch March 28, 2026 16:23
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.

2 participants