Skip to content

Commit 7276b93

Browse files
authored
[TASK] Ensure PHP 8.4 compatibility for nullable parameters (MyIntervals#643)
Ensure that parameters that have a `null` default value also have `null` as part of their type declarations. Also ensure a uniform notation for nullable types. https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated Fixes MyIntervals#634
1 parent a28ad75 commit 7276b93

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

config/php-cs-fixer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141

4242
// function notation
4343
'native_function_invocation' => ['include' => ['@all']],
44+
'nullable_type_declaration' => [
45+
'syntax' => 'question_mark',
46+
],
47+
'nullable_type_declaration_for_default_null_value' => true,
4448

4549
// import
4650
'no_unused_imports' => true,

src/CSSList/Document.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function createShorthands(): void
138138
*
139139
* @param OutputFormat|null $oOutputFormat
140140
*/
141-
public function render(OutputFormat $oOutputFormat = null): string
141+
public function render(?OutputFormat $oOutputFormat = null): string
142142
{
143143
if ($oOutputFormat === null) {
144144
$oOutputFormat = new OutputFormat();

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Parser
2121
* @param Settings|null $oParserSettings
2222
* @param int $iLineNo the line number (starting from 1, not from 0)
2323
*/
24-
public function __construct($sText, Settings $oParserSettings = null, $iLineNo = 1)
24+
public function __construct($sText, ?Settings $oParserSettings = null, $iLineNo = 1)
2525
{
2626
if ($oParserSettings === null) {
2727
$oParserSettings = Settings::create();

src/RuleSet/RuleSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function getLineNo()
9898
/**
9999
* @param Rule|null $oSibling
100100
*/
101-
public function addRule(Rule $oRule, Rule $oSibling = null): void
101+
public function addRule(Rule $oRule, ?Rule $oSibling = null): void
102102
{
103103
$sRule = $oRule->getRule();
104104
if (!isset($this->aRules[$sRule])) {

0 commit comments

Comments
 (0)