Skip to content

Commit

Permalink
Fixed nullable types for PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Mar 23, 2024
1 parent 99dffbc commit 9dc8b1a
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 25 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"require-dev": {
"code-lts/doctum": "*",
"matthiasmullie/minify": "*",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5",
"friendsofphp/php-cs-fixer": "^3.52"
},
"suggest": {
"ext-curl": "Improves the performance of the MediaEmbed plugin and some JavaScript minifiers",
Expand Down Expand Up @@ -45,4 +46,4 @@
"extra": {
"version": "2.16.1-dev"
}
}
}
2 changes: 1 addition & 1 deletion scripts/benchmarkRegexps.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
];
benchmark($regexps, $input, '');

function benchmark(array $regexps, string $input, string $replace = null)
function benchmark(array $regexps, string $input, ?string $replace = null)
{
foreach ($regexps as $regexp)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Configurator/Helpers/FilterSyntaxMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function parseArrayElement(string $key, string $value): array
* @param string $otherElements
* @return array
*/
public function parseArrayElements(string $firstElement, string $otherElements = null)
public function parseArrayElements(string $firstElement, ?string $otherElements = null)
{
$elements = [$this->recurse($firstElement, 'ArrayElement')];
if (isset($otherElements))
Expand Down Expand Up @@ -171,7 +171,7 @@ public function parseFalse(): bool
* @param string $args
* @return array
*/
public function parseFilterCallback(string $callback, string $args = null): array
public function parseFilterCallback(string $callback, ?string $args = null): array
{
$config = ['filter' => $callback];
if (isset($args))
Expand All @@ -187,7 +187,7 @@ public function parseFilterCallback(string $callback, string $args = null): arra
* @param string $otherArgs
* @return array
*/
public function parseFilterArgs(string $firstArg, string $otherArgs = null)
public function parseFilterArgs(string $firstArg, ?string $otherArgs = null)
{
$parsedArg = $this->parser->parse($firstArg, 'FilterArg');

Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/Helpers/TemplateInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function closesParent(TemplateInspector $parent)
* @param DOMElement $node Context node
* @return mixed
*/
public function evaluate($expr, DOMElement $node = null)
public function evaluate($expr, ?DOMElement $node = null)
{
return $this->xpath->evaluate($expr, $node);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Configurator/Helpers/TemplateParser/IRProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function createXPath(DOMDocument $dom)
* @param DOMNode $node Context node
* @return mixed
*/
protected function evaluate($expr, DOMNode $node = null)
protected function evaluate($expr, ?DOMNode $node = null)
{
return (isset($node)) ? $this->xpath->evaluate($expr, $node) : $this->xpath->evaluate($expr);
}
Expand All @@ -67,7 +67,7 @@ protected function evaluate($expr, DOMNode $node = null)
* @param DOMNode $node Context node
* @return \DOMNodeList
*/
protected function query($query, DOMNode $node = null)
protected function query($query, ?DOMNode $node = null)
{
return (isset($node)) ? $this->xpath->query($query, $node) : $this->xpath->query($query);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/Helpers/TemplateParser/Optimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected function removeEmptyDefaultCases()
* @param DOMNode $contextNode
* @return void
*/
protected function removeNodes($query, DOMNode $contextNode = null)
protected function removeNodes($query, ?DOMNode $contextNode = null)
{
foreach ($this->query($query, $contextNode) as $node)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/Items/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Attribute implements ConfigProvider
*
* @param array $options This attribute's options
*/
public function __construct(array $options = null)
public function __construct(?array $options = null)
{
$this->filterChain = new AttributeFilterChain;

Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/Items/AttributeFilters/ChoiceFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ChoiceFilter extends RegexpFilter
* @param array $values List of allowed values
* @param bool $caseSensitive Whether the choice is case-sensitive
*/
public function __construct(array $values = null, $caseSensitive = false)
public function __construct(?array $values = null, $caseSensitive = false)
{
parent::__construct();

Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/Items/AttributeFilters/HashmapFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HashmapFilter extends AbstractMapFilter
* @param array $map Associative array in the form [key => value]
* @param bool $strict Whether this map is strict (values with no match are invalid)
*/
public function __construct(array $map = null, $strict = false)
public function __construct(?array $map = null, $strict = false)
{
parent::__construct('s9e\\TextFormatter\\Parser\\AttributeFilters\\HashmapFilter::filter');

Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/Items/AttributeFilters/MapFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MapFilter extends AbstractMapFilter
* @param bool $caseSensitive Whether this map is case-sensitive
* @param bool $strict Whether this map is strict (values with no match are invalid)
*/
public function __construct(array $map = null, $caseSensitive = false, $strict = false)
public function __construct(?array $map = null, $caseSensitive = false, $strict = false)
{
parent::__construct('s9e\\TextFormatter\\Parser\\AttributeFilters\\MapFilter::filter');

Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/Items/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Tag implements ConfigProvider
*
* @param array $options This tag's options
*/
public function __construct(array $options = null)
public function __construct(?array $options = null)
{
$this->attributes = new AttributeCollection;
$this->attributePreprocessors = new AttributePreprocessorCollection;
Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/JavaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function getMinifier()
* @param array $config Config array returned by the configurator
* @return string JavaScript parser
*/
public function getParser(array $config = null)
public function getParser(?array $config = null)
{
$this->configOptimizer->reset();

Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/RendererGenerators/PHP/XPathConvertor.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class XPathConvertor
/**
* Constructor
*/
public function __construct(RecursiveParser $parser = null)
public function __construct(?RecursiveParser $parser = null)
{
$this->features = [
'mbstring' => extension_loaded('mbstring'),
Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/TemplateChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function checkTag(Tag $tag)
* @param Tag $tag Tag this template belongs to
* @return void
*/
public function checkTemplate($template, Tag $tag = null)
public function checkTemplate($template, ?Tag $tag = null)
{
if ($this->disabled)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Configurator/TemplateNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class TemplateNormalizer implements ArrayAccess, Iterator
*
* @param array $normalizations List of normalizations
*/
public function __construct(array $normalizations = null)
public function __construct(?array $normalizations = null)
{
if (!isset($normalizations))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/AttributeFilters/NumericFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function filterInt($attrValue)
* @param Logger $logger Parser's Logger instance
* @return mixed Filtered value, or FALSE if invalid
*/
public static function filterRange($attrValue, $min, $max, Logger $logger = null)
public static function filterRange($attrValue, $min, $max, ?Logger $logger = null)
{
$attrValue = filter_var($attrValue, FILTER_VALIDATE_INT);

Expand Down
2 changes: 1 addition & 1 deletion src/Parser/AttributeFilters/UrlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UrlFilter
* @param Logger $logger Parser's logger
* @return mixed Cleaned up URL if valid, FALSE otherwise
*/
public static function filter($attrValue, array $urlConfig, Logger $logger = null)
public static function filter($attrValue, array $urlConfig, ?Logger $logger = null)
{
/**
* Trim the URL to conform with HTML5 then parse it
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/BBCodes/Configurator/BBCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BBCode implements ConfigProvider
/**
* @param array $options This BBCode's options
*/
public function __construct(array $options = null)
public function __construct(?array $options = null)
{
$this->contentAttributes = new AttributeList;
if (isset($options))
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/MediaEmbed/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function asConfig()
* @param array $siteConfig Site's config
* @return Tag Tag created for this site
*/
public function add($siteId, array $siteConfig = null)
public function add($siteId, ?array $siteConfig = null)
{
// Normalize or retrieve the site definition
$siteId = $this->normalizeId($siteId);
Expand Down
2 changes: 1 addition & 1 deletion tests/Parser/TagProcessingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TagProcessingTest extends Test
* @testdox Works
* @dataProvider getData
*/
public function test($original, $expected, $setup = null, $callback = null, array $expectedLogs = null)
public function test($original, $expected, $setup = null, $callback = null, ?array $expectedLogs = null)
{
$this->configurator->rulesGenerator->clear();
$this->configurator->rulesGenerator->add('AllowAll');
Expand Down
2 changes: 1 addition & 1 deletion tests/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function reduceAndSortArrays(array &$expected, array &$actual, $remove
}
}

protected function assertParsing($original, $expected, $setup = null, $callback = null, array $expectedLogs = null)
protected function assertParsing($original, $expected, $setup = null, $callback = null, ?array $expectedLogs = null)
{
if (isset($setup))
{
Expand Down

0 comments on commit 9dc8b1a

Please sign in to comment.