Skip to content

Fix: Do not pass null to function that expects DateTime or string#869

Merged
kamil-tekiela merged 1 commit intophp:masterfrom
localheinz:fix/now
Dec 6, 2023
Merged

Fix: Do not pass null to function that expects DateTime or string#869
kamil-tekiela merged 1 commit intophp:masterfrom
localheinz:fix/now

Conversation

@localheinz
Copy link
Copy Markdown
Contributor

@localheinz localheinz commented Dec 6, 2023

This pull request

  • stops passing null to a function that expects DateTime or string

Follows #847.

💁‍♂️ Running

git grep -i format_interval

on current master yields

eol.php:51:				<?php $eolPeriod = format_interval($eolDate, null) ?>
include/branches.inc:46:function format_interval($from, $to) {
supported-versions.php:66:					<td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($initial, null)) ?></em></td>
supported-versions.php:68:					<td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($until, null)) ?></em></td>
supported-versions.php:70:					<td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($eol, null)) ?></em></td>

Before

See http://localhost:8080/supported-versions.php:

CleanShot 2023-12-06 at 17 02 22@2x

After

See http://localhost:8080/supported-versions.php:

CleanShot 2023-12-06 at 17 02 28@2x

Comment thread include/branches.inc
$KEEP_EOL = new DateInterval('P28D');

function format_interval($from, $to) {
function format_interval($from, DateTime $to) {
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.

Alternatively, we could create $to in the function, but that would make it harder to test if we wanted to test it.

@kamil-tekiela kamil-tekiela merged commit 2b70836 into php:master Dec 6, 2023
@localheinz localheinz deleted the fix/now branch December 6, 2023 16:47
@localheinz
Copy link
Copy Markdown
Contributor Author

Thank you, @kamil-tekiela!

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