Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Code style adjust 5 internal usages of Object::none() to ::createEmpty() #5497

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function fromArray(array $commandHooks): self
return new self(...$commandHooks);
}

public static function none(): self
public static function createEmpty(): self
{
return new self();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function fromArray(array $subscriberFactories): self
return new self(...$subscriberFactories);
}

public static function none(): self
public static function createEmpty(): self
{
return new self();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private function __construct(ProjectionInterface ...$projections)
$this->projections = $projections;
}

public static function empty(): self
public static function createEmpty(): self
{
return new self();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function fromArray(array $subscribers): self
return new self($subscribersById);
}

public static function none(): self
public static function createEmpty(): self
{
return self::fromArray([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function fromArray(array $ids): self
return new self($subscriptionIdsById);
}

public static function none(): self
public static function createEmpty(): self
{
return self::fromArray([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function fromArray(array $subscriptions): self
return new self($subscriptionsById);
}

public static function none(): self
public static function createEmpty(): self
{
return self::fromArray([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function findByCriteriaForUpdate(SubscriptionCriteria $criteria): Subscri
assert($result instanceof Result);
$rows = $result->fetchAllAssociative();
if ($rows === []) {
return Subscriptions::none();
return Subscriptions::createEmpty();
}
return Subscriptions::fromArray(array_map(self::fromDatabase(...), $rows));
}
Expand Down
2 changes: 1 addition & 1 deletion Neos.Fusion/Classes/Core/FusionGlobals.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private function __construct(
) {
}

public static function empty(): self
public static function createEmpty(): self
{
return new self([]);
}
Expand Down
12 changes: 10 additions & 2 deletions Neos.Fusion/Classes/Core/FusionSourceCodeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public function __construct(FusionSourceCode ...$fusionSourceCode)
$this->fusionCodeCollection = self::deduplicateItemsAndKeepLast($fusionSourceCode);
}

public static function createEmpty(): self
{
return new self();
}

public static function fromFilePath(string $filePath): self
{
return new self(FusionSourceCode::fromFilePath($filePath));
Expand All @@ -47,7 +52,7 @@ public static function fromString(string $string): self
public static function tryFromFilePath(string $filePath): self
{
if (!is_readable($filePath)) {
return self::empty();
return self::createEmpty();
}
return self::fromFilePath($filePath);
}
Expand All @@ -61,9 +66,12 @@ public static function tryFromPackageRootFusion(string $packageKey): self
return self::tryFromFilePath($fusionPathAndFilename);
}

/**
* @deprecated with Neos 9, remove me :)
*/
public static function empty(): self
{
return new self();
return self::createEmpty();
}

public function union(FusionSourceCodeCollection $other): self
Expand Down
2 changes: 1 addition & 1 deletion Neos.Fusion/Tests/Benchmark/RuntimeBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function init()
]
]
];
$this->runtime = (new RuntimeFactory())->createFromConfiguration(FusionConfiguration::fromArray($fusionConfiguration), FusionGlobals::empty());
$this->runtime = (new RuntimeFactory())->createFromConfiguration(FusionConfiguration::fromArray($fusionConfiguration), FusionGlobals::createEmpty());

// Build an EEL evaluator suitable for benchmarking
$evaluator = $this->buildEelEvaluator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function usingEelWorksWithoutSetCurrentContextInRuntime()
{
$fusionAst = (new Parser())->parseFromSource(FusionSourceCodeCollection::fromString('root = ${"foo"}'));

$runtime = (new RuntimeFactory())->createFromConfiguration($fusionAst, FusionGlobals::empty());
$runtime = (new RuntimeFactory())->createFromConfiguration($fusionAst, FusionGlobals::createEmpty());

$renderedFusion = $runtime->render('root');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function usingReservedKeysThrowsException()
$this->expectException(Exception::class);
$this->objectManager->get(RuntimeFactory::class)->createFromSourceCode(
FusionSourceCodeCollection::fromFilePath(__DIR__ . '/Fixtures/ReservedKeysFusion/ReservedKeys.fusion'),
FusionGlobals::empty()
FusionGlobals::createEmpty()
);
}

Expand Down
2 changes: 1 addition & 1 deletion Neos.Fusion/Tests/Unit/Core/FusionSourceCodeDtosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function pureFactories()
self::assertEquals("a", $code->getSourceCode());
self::assertEquals("memory://a", $code->getFilePath());

$code = FusionSourceCodeCollection::empty();
$code = FusionSourceCodeCollection::createEmpty();
self::assertCount(0, $code);
}

Expand Down
16 changes: 8 additions & 8 deletions Neos.Fusion/Tests/Unit/Core/RuntimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function handleRenderingExceptionThrowsException()
$this->expectException(Exception::class);
$objectManager = $this->getMockBuilder(ObjectManager::class)->disableOriginalConstructor()->setMethods(['isRegistered', 'get'])->getMock();
$runtimeException = new RuntimeException('I am a parent exception', 123, new Exception('I am a previous exception'), 'root');
$runtime = new Runtime(FusionConfiguration::fromArray([]), FusionGlobals::empty());
$runtime = new Runtime(FusionConfiguration::fromArray([]), FusionGlobals::createEmpty());
$this->inject($runtime, 'objectManager', $objectManager);
$exceptionHandlerSetting = 'settings';
$runtime->injectSettings(['rendering' => ['exceptionHandler' => $exceptionHandlerSetting]]);
Expand All @@ -81,7 +81,7 @@ public function evaluateProcessorForEelExpressionUsesProtectedContext()
self::callback(fn (ProtectedContext $actualContext) => $actualContext->get('foo') === '19')
);

$runtime = new Runtime(FusionConfiguration::fromArray([]), FusionGlobals::empty());
$runtime = new Runtime(FusionConfiguration::fromArray([]), FusionGlobals::createEmpty());
$this->inject($runtime, 'eelEvaluator', $eelEvaluator);

$runtime->pushContextArray(['foo' => '19']);
Expand All @@ -108,7 +108,7 @@ public function evaluateWithCacheModeUncachedAndUnspecifiedContextThrowsExceptio
]
]
]
]), FusionGlobals::empty());
]), FusionGlobals::createEmpty());

$runtime->evaluate('foo/bar');
}
Expand All @@ -131,7 +131,7 @@ public function renderRethrowsSecurityExceptions()
*/
public function runtimeCurrentContextStackWorksSimplePushPop()
{
$runtime = new Runtime(FusionConfiguration::fromArray([]), FusionGlobals::empty());
$runtime = new Runtime(FusionConfiguration::fromArray([]), FusionGlobals::createEmpty());

self::assertSame([], $runtime->getCurrentContext(), 'context should be empty at start.');

Expand All @@ -149,7 +149,7 @@ public function runtimeCurrentContextStackWorksSimplePushPop()
*/
public function runtimeCurrentContextStack3PushesAndPops()
{
$runtime = new Runtime(FusionConfiguration::fromArray([]), FusionGlobals::empty());
$runtime = new Runtime(FusionConfiguration::fromArray([]), FusionGlobals::createEmpty());

self::assertSame([], $runtime->getCurrentContext(), 'empty at start');

Expand Down Expand Up @@ -298,7 +298,7 @@ public function renderResponseExamples(): iterable
public function renderEntryPathStream(mixed $rawValue, string $expectedStreamContents)
{
$runtime = $this->getMockBuilder(Runtime::class)
->setConstructorArgs([FusionConfiguration::fromArray([]), FusionGlobals::empty()])
->setConstructorArgs([FusionConfiguration::fromArray([]), FusionGlobals::createEmpty()])
->onlyMethods(['render'])
->getMock();

Expand All @@ -319,7 +319,7 @@ public function renderEntryPathStream(mixed $rawValue, string $expectedStreamCon
public function renderEntryPathResponse(mixed $rawValue, string $expectedHttpResponseString)
{
$runtime = $this->getMockBuilder(Runtime::class)
->setConstructorArgs([FusionConfiguration::fromArray([]), FusionGlobals::empty()])
->setConstructorArgs([FusionConfiguration::fromArray([]), FusionGlobals::createEmpty()])
->onlyMethods(['render'])
->getMock();

Expand Down Expand Up @@ -372,7 +372,7 @@ public function renderResponseThrowsIfNotStringable(mixed $illegalValue)
$this->expectExceptionMessage(sprintf('Fusion entry path "path" is expected to render a compatible http response body: string|\Stringable|null. Got %s instead.', get_debug_type($illegalValue)));

$runtime = $this->getMockBuilder(Runtime::class)
->setConstructorArgs([FusionConfiguration::fromArray([]), FusionGlobals::empty()])
->setConstructorArgs([FusionConfiguration::fromArray([]), FusionGlobals::createEmpty()])
->onlyMethods(['render'])
->getMock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function run(ProcessingContext $context): void
$this->contentRepository->id,
WorkspaceName::forLive(),
WorkspaceTitle::fromString('Public live workspace'),
WorkspaceDescription::empty(),
WorkspaceDescription::createEmpty(),
WorkspaceRoleAssignments::createForLiveWorkspace()
);
}
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/Domain/Model/WorkspaceDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function fromString(string $value): self
return new self($value);
}

public static function empty(): self
public static function createEmpty(): self
{
return new self('');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FusionSourceCodeFactory

public function createFromAutoIncludes(): FusionSourceCodeCollection
{
$sourcecode = FusionSourceCodeCollection::empty();
$sourcecode = FusionSourceCodeCollection::createEmpty();
foreach (array_keys($this->packageManager->getAvailablePackages()) as $packageKey) {
if (isset($this->autoIncludeConfiguration[$packageKey]) && $this->autoIncludeConfiguration[$packageKey] === true) {
$sourcecode = $this->fusionAutoIncludeHandler->loadFusionFromPackage($packageKey, $sourcecode);
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function createSiteNodeIfNotExists(Site $site, string $nodeTypeName): voi
$this->contentRepository->id,
WorkspaceName::forLive(),
WorkspaceTitle::fromString('Public live workspace'),
WorkspaceDescription::empty(),
WorkspaceDescription::createEmpty(),
WorkspaceRoleAssignments::createForLiveWorkspace()
)
);
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/Domain/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function createPersonalWorkspaceForUserIfMissing(ContentRepositoryId $con
$contentRepositoryId,
$workspaceName,
WorkspaceTitle::fromString($user->getLabel()),
WorkspaceDescription::empty(),
WorkspaceDescription::createEmpty(),
WorkspaceName::forLive(),
$user->getId(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function theLiveWorkspaceExists(): void
$this->currentContentRepository->id,
WorkspaceName::forLive(),
WorkspaceTitle::fromString('Public live workspace'),
WorkspaceDescription::empty(),
WorkspaceDescription::createEmpty(),
WorkspaceRoleAssignments::createForLiveWorkspace()
);
}
Expand Down