Skip to main content

Posts

Showing posts with the label PHP 8.4

Fixing Implicit Nullable Parameter Deprecations in PHP 8.4

  If you recently upgraded your CI/CD pipeline or local environment to PHP 8.4, you likely encountered a flood of deprecation notices resembling this: Deprecated: Implicitly marking parameter $param as nullable is deprecated, the explicit nullable type must be used instead For years, PHP allowed developers to declare a typed parameter with a default  null  value without explicitly marking the type as nullable. This behavior was convenient but inconsistent with the strict type system PHP has been adopting since version 7.0. In PHP 8.4, this "magic" behavior is officially deprecated. This guide details exactly why this change was made, how to fix it manually, and how to automate the remediation for large codebases. The Root Cause: Why PHP 8.4 Removes Implicit Nullability To understand the fix, we must understand the inconsistency in the type system. Historically, the PHP engine inferred type definitions based on default values. If you wrote  function setDate(DateTime $...