Skip to content

Commit

Permalink
Fix PHP < 7.4 interface compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Jun 2, 2021
1 parent 841e2ec commit 93d9db9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions phpdoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
$carbon = __DIR__.'/src/Carbon/Carbon.php';
$immutable = __DIR__.'/src/Carbon/CarbonImmutable.php';
$interface = __DIR__.'/src/Carbon/CarbonInterface.php';
$phpLevel = 7.1;
file_put_contents($interface, preg_replace('/(\/\/ <methods[\s\S]*>)([\s\S]+)(<\/methods>)/mU', "$1\n\n // $3", file_get_contents($interface), 1));
require_once __DIR__.'/vendor/autoload.php';
$trait = __DIR__.'/src/Carbon/Traits/Date.php';
Expand Down Expand Up @@ -582,6 +583,10 @@ function compileDoc($autoDocLines, $file)
' */';
}

if (strpos($return, 'self') !== false && $phpLevel < 7.4) {
$return = '';
}

$methods .= "\n$methodDocBlock\n public$static function $method($parameters)$return;";
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Carbon/CarbonInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ public static function createSafe($year = null, $month = null, $day = null, $hou
*
* @return static
*/
public static function createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null): self;
public static function createStrict(?int $year = 0, ?int $month = 1, ?int $day = 1, ?int $hour = 0, ?int $minute = 0, ?int $second = 0, $tz = null);

/**
* Get/set the day of year.
Expand Down

0 comments on commit 93d9db9

Please sign in to comment.