Skip to content

Commit

Permalink
Merge pull request #5433 from dlubitz/task/explicit-nullable-paramete…
Browse files Browse the repository at this point in the history
…r-84

TASK: Make nullable parameter explicit to become PHP 8.4 compatible
  • Loading branch information
dlubitz authored Jan 17, 2025
2 parents 3028ea8 + a8b5094 commit 6c3ad10
Show file tree
Hide file tree
Showing 110 changed files with 204 additions and 204 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.0', '8.1', '8.2', '8.3']
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']
dependencies: ['highest']
composer-arguments: [''] # to run --ignore-platform-reqs in experimental builds
static-analysis: ['no']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static function getSubCommandDescription($controllerCommandName)
* @param string $only Only execute the given check or checks (comma separated)
* @return void
*/
public function invokeSubCommand($controllerCommandName, ConsoleOutput $output, NodeType $nodeType = null, $workspaceName = 'live', $dryRun = false, $cleanup = true, $skip = null, $only = null)
public function invokeSubCommand($controllerCommandName, ConsoleOutput $output, ?NodeType $nodeType = null, $workspaceName = 'live', $dryRun = false, $cleanup = true, $skip = null, $only = null)
{
/** @noinspection PhpDeprecationInspection This is only set for backwards compatibility */
$this->output = $output;
Expand Down Expand Up @@ -288,7 +288,7 @@ public function invokeSubCommand($controllerCommandName, ConsoleOutput $output,
* @throws NodeConfigurationException
* @throws NodeTypeNotFoundException
*/
protected function createMissingChildNodes($workspaceName, $dryRun, NodeType $nodeType = null)
protected function createMissingChildNodes($workspaceName, $dryRun, ?NodeType $nodeType = null)
{
if ($nodeType !== null) {
$this->dispatch(self::EVENT_NOTICE, sprintf('Checking nodes of type "<i>%s</i>" for missing child nodes ...', $nodeType->getName()));
Expand Down Expand Up @@ -437,7 +437,7 @@ protected function createChildNodesByNodeType(NodeType $nodeType, $workspaceName
* @throws NodeConfigurationException
* @throws NodeTypeNotFoundException
*/
public function addMissingDefaultValues($workspaceName, $dryRun, NodeType $nodeType = null)
public function addMissingDefaultValues($workspaceName, $dryRun, ?NodeType $nodeType = null)
{
if ($nodeType !== null) {
$this->dispatch(self::EVENT_NOTICE, sprintf('Checking nodes of type <i>%s</i> for missing default values ...', $nodeType));
Expand Down Expand Up @@ -645,7 +645,7 @@ protected function removeDisallowedChildNodes($workspaceName)
* @param NodeType $nodeType Only for this node type, if specified
* @return void
*/
protected function removeOrphanNodes($workspaceName, /** @noinspection PhpUnusedParameterInspection */$dryRun, NodeType $nodeType = null)
protected function removeOrphanNodes($workspaceName, /** @noinspection PhpUnusedParameterInspection */$dryRun, ?NodeType $nodeType = null)
{
$this->dispatch(self::EVENT_NOTICE, 'Checking for orphan nodes ...');

Expand Down Expand Up @@ -712,7 +712,7 @@ protected function removeOrphanNodes($workspaceName, /** @noinspection PhpUnused
* @return void
* @throws NodeConfigurationException
*/
public function removeUndefinedProperties($workspaceName, /** @noinspection PhpUnusedParameterInspection */$dryRun, NodeType $nodeType = null)
public function removeUndefinedProperties($workspaceName, /** @noinspection PhpUnusedParameterInspection */$dryRun, ?NodeType $nodeType = null)
{
$this->dispatch(self::EVENT_NOTICE, 'Checking for undefined properties ...');

Expand Down Expand Up @@ -1173,7 +1173,7 @@ public function fixNodesWithInconsistentIdentifier()
* @throws NodeConfigurationException
* @throws NodeTypeNotFoundException
*/
protected function reorderChildNodes($workspaceName, $dryRun, NodeType $nodeType = null)
protected function reorderChildNodes($workspaceName, $dryRun, ?NodeType $nodeType = null)
{
if ($nodeType !== null) {
$this->dispatch(self::EVENT_NOTICE, sprintf('Checking nodes of type "<i>%s</i>" for child nodes that need reordering ...', $nodeType));
Expand Down Expand Up @@ -1261,7 +1261,7 @@ protected function reorderChildNodesByNodeType($workspaceName, /** @noinspection
* @param NodeType $nodeType This argument will be ignored
* @return void
*/
protected function repairShadowNodes($workspaceName, /** @noinspection PhpUnusedParameterInspection */$dryRun, NodeType $nodeType = null)
protected function repairShadowNodes($workspaceName, /** @noinspection PhpUnusedParameterInspection */$dryRun, ?NodeType $nodeType = null)
{
/** @var Workspace $workspace */
$workspace = $this->workspaceRepository->findByIdentifier($workspaceName);
Expand Down Expand Up @@ -1295,7 +1295,7 @@ protected function repairShadowNodes($workspaceName, /** @noinspection PhpUnused
* @param NodeType $nodeType
* @return array in the form [['nodeData' => <nodeDataInstance>, 'shadowPath' => '<shadowPath>'], ...]
*/
protected function findMissingShadowNodesInWorkspace(Workspace $workspace, NodeType $nodeType = null)
protected function findMissingShadowNodesInWorkspace(Workspace $workspace, ?NodeType $nodeType = null)
{
$workspaces = array_merge([$workspace], $workspace->getBaseWorkspaces());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ public static function getSubCommandDescription($controllerCommandName);
* @param boolean $cleanup If false, cleanup tasks are skipped
* @return void
*/
public function invokeSubCommand($controllerCommandName, ConsoleOutput $output, NodeType $nodeType = null, $workspaceName = 'live', $dryRun = false, $cleanup = true);
public function invokeSubCommand($controllerCommandName, ConsoleOutput $output, ?NodeType $nodeType = null, $workspaceName = 'live', $dryRun = false, $cleanup = true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public function getLastPublicationDateTime()
* @param \DateTimeInterface $lastPublicationDateTime
* @return void
*/
public function setLastPublicationDateTime(\DateTimeInterface $lastPublicationDateTime = null)
public function setLastPublicationDateTime(?\DateTimeInterface $lastPublicationDateTime = null)
{
$this->lastPublicationDateTime = $lastPublicationDateTime;
}
Expand Down Expand Up @@ -451,7 +451,7 @@ public function isHidden()
* @param \DateTimeInterface $dateTime Date before this node should be hidden
* @return void
*/
public function setHiddenBeforeDateTime(\DateTimeInterface $dateTime = null)
public function setHiddenBeforeDateTime(?\DateTimeInterface $dateTime = null)
{
if ($this->hiddenBeforeDateTime != $dateTime) {
$this->hiddenBeforeDateTime = $dateTime;
Expand All @@ -475,7 +475,7 @@ public function getHiddenBeforeDateTime()
* @param \DateTimeInterface $dateTime Date after which this node should be hidden or NULL if no such time was set
* @return void
*/
public function setHiddenAfterDateTime(\DateTimeInterface $dateTime = null)
public function setHiddenAfterDateTime(?\DateTimeInterface $dateTime = null)
{
if ($this->hiddenAfterDateTime != $dateTime) {
$this->hiddenAfterDateTime = $dateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getLabel(): string
* @param ContentDimensionValue|null $fallback
* @return ContentDimensionValue
*/
public function createValue(string $value, ContentDimensionValue $fallback = null): ContentDimensionValue
public function createValue(string $value, ?ContentDimensionValue $fallback = null): ContentDimensionValue
{
$contentDimensionValue = new ContentDimensionValue($value, $fallback);
if ($fallback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ContentDimensionValue
* @param string $value
* @param ContentDimensionValue|null $fallback
*/
public function __construct(string $value, ContentDimensionValue $fallback = null)
public function __construct(string $value, ?ContentDimensionValue $fallback = null)
{
$this->value = $value;
if ($fallback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class IntraDimensionalFallbackGraph
* @param string|null $label
* @return ContentDimension
*/
public function createDimension(string $dimensionName, string $label = null): ContentDimension
public function createDimension(string $dimensionName, ?string $label = null): ContentDimension
{
$dimension = new ContentDimension($dimensionName, $label);
$this->dimensions[$dimension->getName()] = $dimension;
Expand Down
22 changes: 11 additions & 11 deletions Neos.ContentRepository/Classes/Domain/Model/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ protected function createNodeForVariant(NodeData $nodeData): ?NodeInterface
* @param NodeInterface $nodeToMove
* @return array NodeVariant and old and new path
*/
protected function moveVariantOrChild(string $aggregateOriginalPath, string $aggregateDestinationPath, NodeInterface $nodeToMove = null): ?array
protected function moveVariantOrChild(string $aggregateOriginalPath, string $aggregateDestinationPath, ?NodeInterface $nodeToMove = null): ?array
{
if ($nodeToMove === null) {
return null;
Expand Down Expand Up @@ -605,7 +605,7 @@ public function isRoot(): bool
* @throws NodeTypeNotFoundException
* @api
*/
public function moveBefore(NodeInterface $referenceNode, string $newName = null): void
public function moveBefore(NodeInterface $referenceNode, ?string $newName = null): void
{
if ($referenceNode === $this) {
return;
Expand Down Expand Up @@ -652,7 +652,7 @@ public function moveBefore(NodeInterface $referenceNode, string $newName = null)
* @throws NodeTypeNotFoundException
* @api
*/
public function moveAfter(NodeInterface $referenceNode, string $newName = null): void
public function moveAfter(NodeInterface $referenceNode, ?string $newName = null): void
{
if ($referenceNode === $this) {
return;
Expand Down Expand Up @@ -699,7 +699,7 @@ public function moveAfter(NodeInterface $referenceNode, string $newName = null):
* @throws NodeTypeNotFoundException
* @api
*/
public function moveInto(NodeInterface $referenceNode, string $newName = null): void
public function moveInto(NodeInterface $referenceNode, ?string $newName = null): void
{
if ($referenceNode === $this || $referenceNode === $this->getParent()) {
return;
Expand Down Expand Up @@ -1136,7 +1136,7 @@ public function getNodeType(): NodeType
* @throws NodeTypeNotFoundException
* @api
*/
public function createNode($name, NodeType $nodeType = null, $identifier = null): NodeInterface
public function createNode($name, ?NodeType $nodeType = null, $identifier = null): NodeInterface
{
$this->emitBeforeNodeCreate($this, $name, $nodeType, $identifier);
$newNode = $this->createSingleNode($name, $nodeType, $identifier);
Expand Down Expand Up @@ -1182,7 +1182,7 @@ public function createNode($name, NodeType $nodeType = null, $identifier = null)
* @throws NodeExistsException
* @throws NodeTypeNotFoundException
*/
public function createSingleNode($name, NodeType $nodeType = null, $identifier = null): NodeInterface
public function createSingleNode($name, ?NodeType $nodeType = null, $identifier = null): NodeInterface
{
if ($nodeType !== null && !$this->willChildNodeBeAutoCreated($name) && !$this->isNodeTypeAllowedAsChildNode($nodeType)) {
throw new NodeConstraintException('Cannot create new node "' . $name . '" of Type "' . $nodeType->getName() . '" in ' . $this->__toString(), 1400782413);
Expand Down Expand Up @@ -1416,7 +1416,7 @@ public function isHidden(): bool
* @throws NodeTypeNotFoundException
* @throws NodeException
*/
public function setHiddenBeforeDateTime(\DateTimeInterface $dateTime = null): void
public function setHiddenBeforeDateTime(?\DateTimeInterface $dateTime = null): void
{
if ($this->getHiddenBeforeDateTime() instanceof \DateTime && $dateTime instanceof \DateTime && $this->getHiddenBeforeDateTime()->format(\DateTime::W3C) === $dateTime->format(\DateTime::W3C)) {
return;
Expand Down Expand Up @@ -1447,7 +1447,7 @@ public function getHiddenBeforeDateTime(): ?\DateTimeInterface
* @throws NodeTypeNotFoundException
* @throws NodeException
*/
public function setHiddenAfterDateTime(\DateTimeInterface $dateTime = null): void
public function setHiddenAfterDateTime(?\DateTimeInterface $dateTime = null): void
{
if ($this->getHiddenAfterDateTime() instanceof \DateTimeInterface && $dateTime instanceof \DateTimeInterface && $this->getHiddenAfterDateTime()->format(\DateTime::W3C) === $dateTime->format(\DateTime::W3C)) {
return;
Expand Down Expand Up @@ -1976,7 +1976,7 @@ public function isTethered(): bool
* @param boolean $status
* @return void
*/
public function setNodeDataIsMatchingContext(bool $status = null): void
public function setNodeDataIsMatchingContext(?bool $status = null): void
{
$this->nodeDataIsMatchingContext = $status;
}
Expand Down Expand Up @@ -2078,7 +2078,7 @@ public function findNamedChildNode(NodeName $nodeName): TraversableNodeInterface
* @return TraversableNodes
* @api
*/
public function findChildNodes(NodeTypeConstraints $nodeTypeConstraints = null, int $limit = null, int $offset = null): TraversableNodes
public function findChildNodes(?NodeTypeConstraints $nodeTypeConstraints = null, ?int $limit = null, ?int $offset = null): TraversableNodes
{
/** @noinspection PhpDeprecationInspection */
$filter = $nodeTypeConstraints !== null ? $nodeTypeConstraints->asLegacyNodeTypeFilterString() : null;
Expand All @@ -2092,7 +2092,7 @@ public function findChildNodes(NodeTypeConstraints $nodeTypeConstraints = null,
* @param NodeTypeConstraints|null $nodeTypeConstraints
* @return int
*/
public function countChildNodes(NodeTypeConstraints $nodeTypeConstraints = null): int
public function countChildNodes(?NodeTypeConstraints $nodeTypeConstraints = null): int
{
return count($this->findChildNodes($nodeTypeConstraints));
}
Expand Down
18 changes: 9 additions & 9 deletions Neos.ContentRepository/Classes/Domain/Model/NodeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class NodeData extends AbstractNodeData
* @param string $identifier The node identifier (not the persistence object identifier!). Specifying this only makes sense while creating corresponding nodes
* @param array $dimensions An array of dimension name to dimension values
*/
public function __construct($path, Workspace $workspace, $identifier = null, array $dimensions = null)
public function __construct($path, Workspace $workspace, $identifier = null, ?array $dimensions = null)
{
parent::__construct();
$this->creationDateTime = new \DateTime();
Expand Down Expand Up @@ -350,7 +350,7 @@ public function getDepth()
* @param Workspace $workspace
* @return void
*/
public function setWorkspace(Workspace $workspace = null)
public function setWorkspace(?Workspace $workspace = null)
{
if ($this->workspace !== $workspace) {
$this->workspace = $workspace;
Expand Down Expand Up @@ -446,7 +446,7 @@ public function getParentPath()
* @param array $dimensions
* @return NodeData
*/
public function createNodeData($name, NodeType $nodeType = null, $identifier = null, Workspace $workspace = null, array $dimensions = null)
public function createNodeData($name, ?NodeType $nodeType = null, $identifier = null, ?Workspace $workspace = null, ?array $dimensions = null)
{
$newNodeData = $this->createSingleNodeData($name, $nodeType, $identifier, $workspace, $dimensions);
if ($nodeType !== null) {
Expand Down Expand Up @@ -479,7 +479,7 @@ public function createNodeData($name, NodeType $nodeType = null, $identifier = n
* @throws \InvalidArgumentException if the node name is not accepted.
* @return NodeData
*/
public function createSingleNodeData($name, NodeType $nodeType = null, $identifier = null, Workspace $workspace = null, array $dimensions = null)
public function createSingleNodeData($name, ?NodeType $nodeType = null, $identifier = null, ?Workspace $workspace = null, ?array $dimensions = null)
{
if (!is_string($name) || preg_match(NodeInterface::MATCH_PATTERN_NAME, $name) !== 1) {
throw new \InvalidArgumentException('Invalid node name "' . $name . '" (a node name must only contain lowercase characters, numbers and the "-" sign).', 1292428697);
Expand Down Expand Up @@ -509,7 +509,7 @@ public function createSingleNodeData($name, NodeType $nodeType = null, $identifi
* @param array $dimensions
* @return NodeData the freshly generated node
*/
public function createNodeDataFromTemplate(NodeTemplate $nodeTemplate, $nodeName = null, Workspace $workspace = null, array $dimensions = null)
public function createNodeDataFromTemplate(NodeTemplate $nodeTemplate, $nodeName = null, ?Workspace $workspace = null, ?array $dimensions = null)
{
$newNodeName = $nodeName !== null ? $nodeName : $nodeTemplate->getName();
$possibleNodeName = $this->nodeService->generateUniqueNodeName($this->getPath(), $newNodeName);
Expand Down Expand Up @@ -733,7 +733,7 @@ public function getMovedTo()
* @param NodeData $nodeData
* @return void
*/
public function setMovedTo(NodeData $nodeData = null)
public function setMovedTo(?NodeData $nodeData = null)
{
$this->movedTo = $nodeData;
}
Expand Down Expand Up @@ -828,7 +828,7 @@ public function getDimensionsHash()
* @param array $dimensions
* @return boolean
*/
public function matchesWorkspaceAndDimensions($workspace, array $dimensions = null)
public function matchesWorkspaceAndDimensions($workspace, ?array $dimensions = null)
{
if ($this->workspace->getName() !== $workspace->getName()) {
return false;
Expand Down Expand Up @@ -1031,7 +1031,7 @@ public function createShadow($path)
* @param NodeData $nodeData
* @return void
*/
protected function setAsShadowOf(NodeData $nodeData = null)
protected function setAsShadowOf(?NodeData $nodeData = null)
{
$this->setMovedTo($nodeData);
$this->setRemoved(($nodeData !== null));
Expand Down Expand Up @@ -1063,7 +1063,7 @@ protected function materializeToWorkspace($workspace)
* @param NodeData $nodeData Other NodeData object to addOrUpdate
* @throws IllegalObjectTypeException
*/
protected function addOrUpdate(NodeData $nodeData = null)
protected function addOrUpdate(?NodeData $nodeData = null)
{
$nodeData = ($nodeData === null ? $this : $nodeData);

Expand Down
8 changes: 4 additions & 4 deletions Neos.ContentRepository/Classes/Domain/Model/NodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function isHidden();
* @return void
* @api
*/
public function setHiddenBeforeDateTime(\DateTimeInterface $dateTime = null);
public function setHiddenBeforeDateTime(?\DateTimeInterface $dateTime = null);

/**
* Returns the date and time before which this node will be automatically hidden.
Expand All @@ -245,7 +245,7 @@ public function getHiddenBeforeDateTime();
* @return void
* @api
*/
public function setHiddenAfterDateTime(\DateTimeInterface $dateTime = null);
public function setHiddenAfterDateTime(?\DateTimeInterface $dateTime = null);

/**
* Returns the date and time after which this node will be automatically hidden.
Expand Down Expand Up @@ -403,7 +403,7 @@ public function getParentPath();
* @throws NodeExistsException if a node with this path already exists.
* @api
*/
public function createNode($name, NodeType $nodeType = null, $identifier = null);
public function createNode($name, ?NodeType $nodeType = null, $identifier = null);

/**
* Creates, adds and returns a child node of this node, without setting default
Expand All @@ -418,7 +418,7 @@ public function createNode($name, NodeType $nodeType = null, $identifier = null)
* @throws \InvalidArgumentException if the node name is not accepted.
* @throws NodeExistsException if a node with this path already exists.
*/
public function createSingleNode($name, NodeType $nodeType = null, $identifier = null);
public function createSingleNode($name, ?NodeType $nodeType = null, $identifier = null);

/**
* Creates and persists a node from the given $nodeTemplate as child node
Expand Down
Loading

0 comments on commit 6c3ad10

Please sign in to comment.