Fix PHP 8.1/8.4 deprecations: strftime() and implicit nullable types#4
Open
AlexanderSinani wants to merge 2 commits into
Open
Fix PHP 8.1/8.4 deprecations: strftime() and implicit nullable types#4AlexanderSinani wants to merge 2 commits into
AlexanderSinani wants to merge 2 commits into
Conversation
strftime() was deprecated in PHP 8.1 and removed in PHP 9.0.
Two categories of fixes:
1. Generator timestamp comments (18 files): replace
$now = strftime('%c')
with
$now = date('D M j G:i:s Y')
This affects every OM builder that writes an "autogenerated on" comment
into the generated file header.
2. Generated date getter code (PHP5ObjectBuilder only): the template
that is written into every Base*.php temporal accessor previously
emitted a call to strftime() for %-prefixed format strings. This is
replaced with a strtr()-based mapping to date() equivalents, covering
the most common strftime specifiers (%Y %m %d %H %M %S %s %A %a
%B %b %W %u %e %I %p %P %Z %z). Plain date() format strings (no %)
continue to work unchanged.
PHP 8.4 deprecates implicitly nullable typed parameters — where a parameter has a type hint and a default of null but is not declared ?Type. This generates a deprecation notice on every call site and will become a hard error in a future version. Two areas affected: 1. Generator templates (generator/lib/builder/om/): the strings emitted into generated OM files used \$con = null without ?. Fixed in PHP5ObjectBuilder, PHP5ObjectNoCollectionBuilder, PHP5NestedSetBuilder, PHP5NestedSetPeerBuilder, PHP5NodeBuilder, PHP5NodePeerBuilder, QueryBuilder. 2. Runtime library (runtime/lib/): actual PHP code in PropelException, NodeObject, NodePeer, ModelCriteria, PropelDateTime used implicit nullable for PropelPDO, NodeObject, Exception, and DateTimeZone parameters. All affected signatures now use the explicit ?Type notation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two categories of PHP 8.x deprecation notices fixed:
1.
strftime()deprecated since PHP 8.1 (18 files)strftime()was deprecated in PHP 8.1 and will be removed in PHP 9. Every builder that writes an "autogenerated on" comment calledstrftime('%c'). Fixed withdate('D M j G:i:s Y')(locale-independent, equivalent output).The more impactful fix is in
PHP5ObjectBuilder: the template emitted into every generatedBase*.phptemporal accessor calledstrftime($format, ...)for%-prefixed format strings. This has been replaced with astrtr()-based mapping todate()equivalents, covering the common specifiers (%Y %y %m %d %H %M %S %s %A %a %B %b %W %u %e %I %p %P %Z %z). Plaindate()format strings (no%) continue to work unchanged.2. Implicit nullable types deprecated in PHP 8.4 (12 files)
PHP 8.4 deprecates parameters that have a type hint and a default value of
nullbut are not declared?Type. This generates a deprecation notice on every call.PHP5ObjectBuilder,PHP5ObjectNoCollectionBuilder,PHP5NestedSetBuilder,PHP5NestedSetPeerBuilder,PHP5NodeBuilder,PHP5NodePeerBuilder,QueryBuilder): template strings emittingPropelPDO $con = nullandCriteria $criteria = nullnow emit?PropelPDO $con = nulletc.PropelException,NodeObject,NodePeer,ModelCriteria,PropelDateTime): actual PHP signatures forPropelPDO,NodeObject,Exception, andDateTimeZoneparameters updated to use explicit?Type.