Skip to content

Commit

Permalink
explicitly mark nullable parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Oct 14, 2024
1 parent 385f635 commit 9e58af6
Show file tree
Hide file tree
Showing 39 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions core/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function getInstance()
/**
* Constructor
*/
public function __construct(RolesProvider $roleProvider = null, CapabilitiesProvider $capabilityProvider = null)
public function __construct(?RolesProvider $roleProvider = null, ?CapabilitiesProvider $capabilityProvider = null)
{
if (!isset($roleProvider)) {
$roleProvider = StaticContainer::get('Piwik\Access\RolesProvider');
Expand Down Expand Up @@ -135,7 +135,7 @@ private function resetSites()
* @param null|Auth $auth Auth adapter
* @return bool true on success, false if reloading access failed (when auth object wasn't specified and user is not enforced to be Super User)
*/
public function reloadAccess(Auth $auth = null)
public function reloadAccess(?Auth $auth = null)
{
$this->resetSites();

Expand Down
18 changes: 9 additions & 9 deletions core/Archive/ArchiveInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function getDaysWithRememberedInvalidationsForSite(int $idSite): array
return array_keys($this->getRememberedArchivedReportsThatShouldBeInvalidated($idSite));
}

public function getRememberedArchivedReportsThatShouldBeInvalidated(int $idSite = null)
public function getRememberedArchivedReportsThatShouldBeInvalidated(?int $idSite = null)
{
if (null === $idSite) {
$optionName = $this->rememberArchivedReportIdStart . '%';
Expand Down Expand Up @@ -276,7 +276,7 @@ public function markArchivesAsInvalidated(
array $idSites,
array $dates,
$period,
Segment $segment = null,
?Segment $segment = null,
bool $cascadeDown = false,
bool $forceInvalidateNonexistentRanges = false,
?string $name = null,
Expand Down Expand Up @@ -416,7 +416,7 @@ private function addChildPeriodsByYearMonth(&$result, Period $period)
}
}

private function addParentPeriodsByYearMonth(&$result, Period $period, Date $originalDate = null)
private function addParentPeriodsByYearMonth(&$result, Period $period, ?Date $originalDate = null)
{
if (
$period->getLabel() == 'year'
Expand All @@ -442,7 +442,7 @@ private function addParentPeriodsByYearMonth(&$result, Period $period, Date $ori
* @return InvalidationResult
* @throws \Exception
*/
public function markArchivesOverlappingRangeAsInvalidated(array $idSites, array $dates, Segment $segment = null)
public function markArchivesOverlappingRangeAsInvalidated(array $idSites, array $dates, ?Segment $segment = null)
{
$invalidationInfo = new InvalidationResult();

Expand Down Expand Up @@ -485,7 +485,7 @@ public function markArchivesOverlappingRangeAsInvalidated(array $idSites, array
* @throws \Exception
* @api
*/
public function reArchiveReport($idSites, string $plugin = null, string $report = null, Date $startDate = null, Segment $segment = null)
public function reArchiveReport($idSites, ?string $plugin = null, ?string $report = null, ?Date $startDate = null, ?Segment $segment = null)
{
$date2 = Date::today();

Expand Down Expand Up @@ -571,10 +571,10 @@ public function removeInvalidations($idSite, $plugin, $report = null)
*/
public function scheduleReArchiving(
$idSites,
string $pluginName = null,
?string $pluginName = null,
$report = null,
Date $startDate = null,
Segment $segment = null
?Date $startDate = null,
?Segment $segment = null
) {
if (!empty($report)) {
$this->removeInvalidationsSafely($idSites, $pluginName, $report);
Expand Down Expand Up @@ -709,7 +709,7 @@ public function removeInvalidationsFromDistributedList($idSites, $pluginName = n
private function markArchivesInvalidated(
$idSites,
$dates,
Segment $segment = null,
?Segment $segment = null,
bool $removeRanges = false,
bool $forceInvalidateNonexistentRanges = false,
?string $name = null,
Expand Down
2 changes: 1 addition & 1 deletion core/Archive/ArchivePurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ArchivePurger
*/
private $logger;

public function __construct(Model $model = null, Date $purgeCustomRangesOlderThan = null, LoggerInterface $logger = null)
public function __construct(?Model $model = null, ?Date $purgeCustomRangesOlderThan = null, ?LoggerInterface $logger = null)
{
$this->model = $model ?: new Model();

Expand Down
2 changes: 1 addition & 1 deletion core/Archive/DataCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function &get($idSite, $period)
* @param string $value eg 5
* @param array|null $meta Optional metadata to add to the row
*/
public function set($idSite, $period, $name, $value, array $meta = null)
public function set($idSite, $period, $name, $value, ?array $meta = null)
{
$row = & $this->get($idSite, $period);
$row[$name] = $value;
Expand Down
2 changes: 1 addition & 1 deletion core/CacheId.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function pluginAware($cacheId)
return $cacheId;
}

public static function siteAware($cacheId, array $idSites = null)
public static function siteAware($cacheId, ?array $idSites = null)
{
if ($idSites === null) {
$idSites = self::getIdSiteList('idSite');
Expand Down
2 changes: 1 addition & 1 deletion core/CliMulti.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CliMulti
*/
private $logger;

public function __construct(LoggerInterface $logger = null)
public function __construct(?LoggerInterface $logger = null)
{
$this->supportsAsync = $this->supportsAsync();
$this->supportsAsyncSymfony = $this->supportsAsyncSymfony();
Expand Down
2 changes: 1 addition & 1 deletion core/Columns/DimensionMetricFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(Dimension $dimension)
/**
* @return ArchivedMetric
*/
public function createCustomMetric($metricName, $readableName, $aggregation, $documentation = '', string $semanticType = null)
public function createCustomMetric($metricName, $readableName, $aggregation, $documentation = '', ?string $semanticType = null)
{
if (!$this->dimension->getDbTableName() || !$this->dimension->getColumnName()) {
throw new \Exception(sprintf('Cannot make metric from dimension %s because DB table or column missing', $this->dimension->getId()));
Expand Down
2 changes: 1 addition & 1 deletion core/Columns/DimensionSegmentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(Dimension $dimension)
* @return Segment
* @throws \Exception
*/
public function createSegment(Segment $segment = null)
public function createSegment(?Segment $segment = null)
{
$dimension = $this->dimension;

Expand Down
2 changes: 1 addition & 1 deletion core/Columns/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Updater extends \Piwik\Updates
* @param ActionDimension[]|null $actionDimensions
* @param ConversionDimension[]|null $conversionDimensions
*/
public function __construct(array $visitDimensions = null, array $actionDimensions = null, array $conversionDimensions = null)
public function __construct(?array $visitDimensions = null, ?array $actionDimensions = null, ?array $conversionDimensions = null)
{
$this->visitDimensions = $visitDimensions;
$this->actionDimensions = $actionDimensions;
Expand Down
2 changes: 1 addition & 1 deletion core/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Console extends Application
*/
private $environment;

public function __construct(Environment $environment = null)
public function __construct(?Environment $environment = null)
{
$this->setServerArgsIfPhpCgi();

Expand Down
4 changes: 2 additions & 2 deletions core/CronArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class CronArchive
*
* @param LoggerInterface|null $logger
*/
public function __construct(LoggerInterface $logger = null)
public function __construct(?LoggerInterface $logger = null)
{
$this->logger = $logger ?: StaticContainer::get(LoggerInterface::class);
$this->formatter = new Formatter();
Expand Down Expand Up @@ -1063,7 +1063,7 @@ protected function isSegmentAvailable($segmentDefinition, $idSites): bool
return true;
}

private function canWeSkipInvalidatingBecauseInvalidationAlreadyInProgress(int $idSite, Period $period, Segment $segment = null): bool
private function canWeSkipInvalidatingBecauseInvalidationAlreadyInProgress(int $idSite, Period $period, ?Segment $segment = null): bool
{
$invalidationsInProgress = $this->model->getInvalidationsInProgress($idSite);
$timezone = Site::getTimezoneFor($idSite);
Expand Down
4 changes: 2 additions & 2 deletions core/DI.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function value($value)
* @return \DI\Definition\Helper\CreateDefinitionHelper
* @see PHPDI\create()
*/
public static function create(string $className = null)
public static function create(?string $className = null)
{
return PHPDI\create($className);
}
Expand All @@ -42,7 +42,7 @@ public static function create(string $className = null)
* @return \DI\Definition\Helper\AutowireDefinitionHelper
* @see PHPDI\autowire()
*/
public static function autowire(string $className = null)
public static function autowire(?string $className = null)
{
return PHPDI\autowire($className);
}
Expand Down
2 changes: 1 addition & 1 deletion core/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public static function globr($sDir, $sPattern, $nFlags = 0)
* @param \Closure|false $beforeUnlink An optional closure to execute on a file path before unlinking.
* @api
*/
public static function unlinkRecursive($dir, $deleteRootToo, \Closure $beforeUnlink = null)
public static function unlinkRecursive($dir, $deleteRootToo, ?\Closure $beforeUnlink = null)
{
if (!$dh = @opendir($dir)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion core/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ private function makeSessionAuthenticator()
return null;
}

private function makeAuthenticator(SessionAuth $auth = null)
private function makeAuthenticator(?SessionAuth $auth = null)
{
/**
* Triggered before the user is authenticated, when the global authentication object
Expand Down
4 changes: 2 additions & 2 deletions core/Metrics/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getPrettyPercentFromQuotient($value)
* This parameter is not currently supported and subject to change.
* @api
*/
public function formatMetrics(DataTable $dataTable, Report $report = null, $metricsToFormat = null, $formatAll = false)
public function formatMetrics(DataTable $dataTable, ?Report $report = null, $metricsToFormat = null, $formatAll = false)
{
$metrics = $this->getMetricsToFormat($dataTable, $report);
if (
Expand Down Expand Up @@ -285,7 +285,7 @@ private function makeRegexToMatchMetrics($metricsToFormat)
* @param Report $report
* @return Metric[]
*/
private function getMetricsToFormat(DataTable $dataTable, Report $report = null)
private function getMetricsToFormat(DataTable $dataTable, ?Report $report = null)
{
return Report::getMetricsForTable($dataTable, $report, $baseType = 'Piwik\\Plugin\\Metric');
}
Expand Down
8 changes: 4 additions & 4 deletions core/Plugin/ConsoleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function addRequiredValueOption(
public function addOption(
string $name,
$shortcut = null,
int $mode = null,
?int $mode = null,
string $description = '',
$default = null
) {
Expand Down Expand Up @@ -256,7 +256,7 @@ public function addRequiredArgument(
*
* @see addOptionalArgument, addRequiredArgument
*/
public function addArgument(string $name, int $mode = null, string $description = '', $default = null)
public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null)
{
throw new \LogicException('addArgument can not be used.');
}
Expand Down Expand Up @@ -384,9 +384,9 @@ protected function askForConfirmation(string $question, bool $default = true, st
*/
protected function askAndValidate(
string $question,
callable $validator = null,
?callable $validator = null,
$default = null,
iterable $autocompleterValues = null
?iterable $autocompleterValues = null
) {
/** @var QuestionHelper $helper */
$helper = parent::getHelper('question');
Expand Down
2 changes: 1 addition & 1 deletion core/Plugin/Dimension/VisitDimension.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function onAnyGoalConversion(Request $request, Visitor $visitor, $action)
* @return bool Return true to force a visit, false if otherwise.
* @api
*/
public function shouldForceNewVisit(Request $request, Visitor $visitor, Action $action = null)
public function shouldForceNewVisit(Request $request, Visitor $visitor, ?Action $action = null)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion core/Plugin/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ public function getProcessedMetricsById()
* @return Metric[]
* @api
*/
public static function getMetricsForTable(DataTable $dataTable, Report $report = null, $baseType = 'Piwik\\Plugin\\Metric')
public static function getMetricsForTable(DataTable $dataTable, ?Report $report = null, $baseType = 'Piwik\\Plugin\\Metric')
{
$metrics = $dataTable->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME) ?: array();

Expand Down
10 changes: 5 additions & 5 deletions core/Plugin/Tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getScheduledTasks()
* @return Schedule
* @api
*/
protected function hourly($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY, int $ttlInSeconds = null)
protected function hourly($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY, ?int $ttlInSeconds = null)
{
return $this->custom($this, $methodName, $methodParameter, 'hourly', $priority, $ttlInSeconds);
}
Expand All @@ -75,7 +75,7 @@ protected function hourly($methodName, $methodParameter = null, $priority = self
* See {@link hourly()}
* @api
*/
protected function daily($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY, int $ttlInSeconds = null)
protected function daily($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY, ?int $ttlInSeconds = null)
{
return $this->custom($this, $methodName, $methodParameter, 'daily', $priority, $ttlInSeconds);
}
Expand All @@ -86,7 +86,7 @@ protected function daily($methodName, $methodParameter = null, $priority = self:
* See {@link hourly()}
* @api
*/
protected function weekly($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY, int $ttlInSeconds = null)
protected function weekly($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY, ?int $ttlInSeconds = null)
{
return $this->custom($this, $methodName, $methodParameter, 'weekly', $priority, $ttlInSeconds);
}
Expand All @@ -97,7 +97,7 @@ protected function weekly($methodName, $methodParameter = null, $priority = self
* See {@link hourly()}
* @api
*/
protected function monthly($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY, int $ttlInSeconds = null)
protected function monthly($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY, ?int $ttlInSeconds = null)
{
return $this->custom($this, $methodName, $methodParameter, 'monthly', $priority, $ttlInSeconds);
}
Expand All @@ -120,7 +120,7 @@ protected function monthly($methodName, $methodParameter = null, $priority = sel
*
* @api
*/
protected function custom($objectOrClassName, $methodName, $methodParameter, $time, $priority = self::NORMAL_PRIORITY, int $ttlInSeconds = null)
protected function custom($objectOrClassName, $methodName, $methodParameter, $time, $priority = self::NORMAL_PRIORITY, ?int $ttlInSeconds = null)
{
$this->checkIsValidTask($objectOrClassName, $methodName);

Expand Down
2 changes: 1 addition & 1 deletion core/Scheduler/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct(
$methodParameter,
$scheduledTime,
$priority = self::NORMAL_PRIORITY,
int $ttlInSeconds = null
?int $ttlInSeconds = null
) {
$this->className = $this->getClassNameFromInstance($objectInstance);

Expand Down
2 changes: 1 addition & 1 deletion core/Segment.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Segment
* @param Date|null $endDate end date used to limit subqueries
* @throws
*/
public function __construct($segmentCondition, $idSites, Date $startDate = null, Date $endDate = null)
public function __construct($segmentCondition, $idSites, ?Date $startDate = null, ?Date $endDate = null)
{

$this->segmentQueryBuilder = StaticContainer::get('Piwik\DataAccess\LogQueryBuilder');
Expand Down
2 changes: 1 addition & 1 deletion core/Session/SessionAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SessionAuth implements Auth

private $tokenAuth;

public function __construct(UsersModel $userModel = null, $shouldDestroySession = true)
public function __construct(?UsersModel $userModel = null, $shouldDestroySession = true)
{
$this->userModel = $userModel ?: new UsersModel();
$this->shouldDestroySession = $shouldDestroySession;
Expand Down
4 changes: 2 additions & 2 deletions core/Tracker/Visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class Visitor
*/
public $previousVisitProperties;

public function __construct(VisitProperties $visitProperties, $isVisitorKnown = false, VisitProperties $previousVisitProperties = null)
public function __construct(VisitProperties $visitProperties, $isVisitorKnown = false, ?VisitProperties $previousVisitProperties = null)
{
$this->visitProperties = $visitProperties;
$this->previousVisitProperties = $previousVisitProperties;
$this->setIsVisitorKnown($isVisitorKnown);
}

public static function makeFromVisitProperties(VisitProperties $visitProperties, Request $request, VisitProperties $previousVisitProperties = null)
public static function makeFromVisitProperties(VisitProperties $visitProperties, Request $request, ?VisitProperties $previousVisitProperties = null)
{
$isKnown = $request->getMetadata('CoreHome', 'isVisitorKnown');
return new Visitor($visitProperties, $isKnown, $previousVisitProperties);
Expand Down
2 changes: 1 addition & 1 deletion core/Tracker/VisitorRecognizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function findKnownVisitor($configId, VisitProperties $visitProperties, Re
}
}

public function removeUnchangedValues($visit, VisitProperties $originalVisit = null)
public function removeUnchangedValues($visit, ?VisitProperties $originalVisit = null)
{
if (empty($originalVisit)) {
return $visit;
Expand Down
Loading

0 comments on commit 9e58af6

Please sign in to comment.