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 17, 2024
1 parent 77630cf commit 71b1c0b
Show file tree
Hide file tree
Showing 84 changed files with 136 additions and 136 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/ArchiveProcessor/PluginsArchiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PluginsArchiver
*/
private $archiveWriter;

public function __construct(Parameters $params, ArchiveWriter $archiveWriter = null)
public function __construct(Parameters $params, ?ArchiveWriter $archiveWriter = null)
{
$this->params = $params;
$this->archiveWriter = $archiveWriter ?: new ArchiveWriter($this->params);
Expand Down
4 changes: 2 additions & 2 deletions core/ArchiveProcessor/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public static function isArchivingDisabledFor(array $idSites, Segment $segment,
return !self::isArchivingEnabledFor($idSites, $segment, $periodLabel);
}

public static function isRequestAuthorizedToArchive(Parameters $params = null)
public static function isRequestAuthorizedToArchive(?Parameters $params = null)
{
$isRequestAuthorizedToArchive = Rules::isBrowserTriggerEnabled() || SettingsServer::isArchivePhpTriggered();

Expand Down Expand Up @@ -334,7 +334,7 @@ public static function isSegmentPreProcessed(array $idSites, Segment $segment)
*/
public static function getSelectableDoneFlagValues(
$includeInvalidated = true,
Parameters $params = null,
?Parameters $params = null,
$checkAuthorizedToArchive = true
) {
$possibleValues = array(ArchiveWriter::DONE_OK, ArchiveWriter::DONE_OK_TEMPORARY);
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/Concurrency/DistributedList.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DistributedList
*
* @param string $optionName
*/
public function __construct($optionName, LoggerInterface $logger = null)
public function __construct($optionName, ?LoggerInterface $logger = null)
{
$this->optionName = $optionName;
$this->logger = $logger ?: StaticContainer::get(LoggerInterface::class);
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
6 changes: 3 additions & 3 deletions core/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
class Container extends DIContainer implements ContainerInterface
{
public function __construct(
MutableDefinitionSource $definitionSource = null,
ProxyFactory $proxyFactory = null,
ContainerInterface $wrapperContainer = null
?MutableDefinitionSource $definitionSource = null,
?ProxyFactory $proxyFactory = null,
?ContainerInterface $wrapperContainer = null
) {
parent::__construct($definitionSource, $proxyFactory, $wrapperContainer);
// ensure this container class can be resolved
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
2 changes: 1 addition & 1 deletion core/CronArchive/Performance/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Logger
*/
private $archivingRunId;

public function __construct(Config $config, LoggerInterface $logger = null)
public function __construct(Config $config, ?LoggerInterface $logger = null)
{
$this->isEnabled = $config->Debug['archiving_profile'] == 1;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion core/CronArchive/QueueConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function __construct(
SegmentArchiving $segmentArchiving,
CronArchive $cronArchive,
RequestParser $cliMultiRequestParser,
ArchiveFilter $archiveFilter = null
?ArchiveFilter $archiveFilter = null
) {
$this->logger = $logger;
$this->websiteIdArchiveList = $websiteIdArchiveList;
Expand Down
2 changes: 1 addition & 1 deletion core/CronArchive/ReArchiveList.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ReArchiveList extends DistributedList
{
public const OPTION_NAME = 'ReArchiveList';

public function __construct(LoggerInterface $logger = null)
public function __construct(?LoggerInterface $logger = null)
{
parent::__construct(self::OPTION_NAME, $logger);
}
Expand Down
8 changes: 4 additions & 4 deletions core/CronArchive/SegmentArchiving.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ class SegmentArchiving

public function __construct(
$beginningOfTimeLastNInYears = self::DEFAULT_BEGINNING_OF_TIME_LAST_N_YEARS,
Model $segmentEditorModel = null,
Cache $segmentListCache = null,
Date $now = null,
LoggerInterface $logger = null
?Model $segmentEditorModel = null,
?Cache $segmentListCache = null,
?Date $now = null,
?LoggerInterface $logger = null
) {
$this->processNewSegmentsFrom = StaticContainer::get('ini.General.process_new_segments_from');
$this->beginningOfTimeLastNInYears = $beginningOfTimeLastNInYears;
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/DataAccess/ArchivingDbAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ArchivingDbAdapter
*/
private $maxExecutionTime;

public function __construct($wrapped, LoggerInterface $logger = null)
public function __construct($wrapped, ?LoggerInterface $logger = null)
{
$this->wrapped = $wrapped;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion core/DataAccess/LogAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class LogAggregator
*
* @param \Piwik\ArchiveProcessor\Parameters $params
*/
public function __construct(Parameters $params, LoggerInterface $logger = null)
public function __construct(Parameters $params, ?LoggerInterface $logger = null)
{
$this->dateStart = $params->getDateTimeStart();
$this->dateEnd = $params->getDateTimeEnd();
Expand Down
6 changes: 3 additions & 3 deletions core/DataAccess/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Model
*/
private $logger;

public function __construct(LoggerInterface $logger = null)
public function __construct(?LoggerInterface $logger = null)
{
$this->logger = $logger ?: StaticContainer::get(LoggerInterface::class);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ public function updateArchiveAsInvalidated(
$archiveTable,
$idSites,
$allPeriodsToInvalidate,
Segment $segment = null,
?Segment $segment = null,
bool $forceInvalidateNonexistentRanges = false,
?string $name = null,
bool $doNotCreateInvalidations = false
Expand Down Expand Up @@ -324,7 +324,7 @@ private function makeExistingInvalidationArrayKey($idSite, $date1, $date2, $peri
* @return \Zend_Db_Statement
* @throws Exception
*/
public function updateRangeArchiveAsInvalidated($archiveTable, $idSites, $allPeriodsToInvalidate, Segment $segment = null)
public function updateRangeArchiveAsInvalidated($archiveTable, $idSites, $allPeriodsToInvalidate, ?Segment $segment = null)
{
if (empty($idSites)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion core/DataAccess/RawLogDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RawLogDao
*/
private $logTablesProvider;

public function __construct(DimensionMetadataProvider $provider = null, LogTablesProvider $logTablesProvider = null)
public function __construct(?DimensionMetadataProvider $provider = null, ?LogTablesProvider $logTablesProvider = null)
{
$this->dimensionMetadataProvider = $provider ?: StaticContainer::get('Piwik\Plugin\Dimension\DimensionMetadataProvider');
$this->logTablesProvider = $logTablesProvider ?: StaticContainer::get('Piwik\Plugin\LogTablesProvider');
Expand Down
2 changes: 1 addition & 1 deletion core/Db/TransactionalDatabaseDynamicTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getSupportsTransactionLevelForNonLockingReads(): ?bool
return $this->supportsTransactionLevelForNonLockingReads;
}

public function setSupportsTransactionLevelForNonLockingReads(bool $supports = null): void
public function setSupportsTransactionLevelForNonLockingReads(?bool $supports = null): void
{
$this->supportsTransactionLevelForNonLockingReads = $supports;
}
Expand Down
2 changes: 1 addition & 1 deletion core/Db/TransactionalDatabaseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ interface TransactionalDatabaseInterface
public function getCurrentTransactionIsolationLevelForSession(): string;
public function setTransactionIsolationLevel(string $level): void;
public function getSupportsTransactionLevelForNonLockingReads(): ?bool;
public function setSupportsTransactionLevelForNonLockingReads(bool $supports = null): void;
public function setSupportsTransactionLevelForNonLockingReads(?bool $supports = null): void;
}
2 changes: 1 addition & 1 deletion core/Db/TransactionalDatabaseStaticTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getCurrentTransactionIsolationLevelForSession(): string
}
}

public function setSupportsTransactionLevelForNonLockingReads(bool $supports = null): void
public function setSupportsTransactionLevelForNonLockingReads(?bool $supports = null): void
{
$this->supportsTransactionLevelForNonLockingReads = $supports;
}
Expand Down
2 changes: 1 addition & 1 deletion core/Exception/NotYetInstalledException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class NotYetInstalledException extends InvalidRequestParameterException
{
public function __construct($message = "", $code = 0, Throwable $previous = null)
public function __construct($message = "", $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
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
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
Loading

0 comments on commit 71b1c0b

Please sign in to comment.