Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Aug 27, 2024
1 parent 1bab293 commit e5c474a
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 452 deletions.
122 changes: 1 addition & 121 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ parameters:
count: 1
path: src/bundle/DependencyInjection/Compiler/OutputVisitorPass.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Compiler\\\\ValueObjectVisitorPass\\:\\:process\\(\\) has no return type specified\\.$#"
count: 1
path: src/bundle/DependencyInjection/Compiler/ValueObjectVisitorPass.php

-
message: "#^Method Ibexa\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Configuration\\:\\:addRestRootResourcesSection\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -415,21 +410,6 @@ parameters:
count: 1
path: src/contracts/Output/ValueObjectVisitor.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcher\\:\\:addVisitor\\(\\) has no return type specified\\.$#"
count: 1
path: src/contracts/Output/ValueObjectVisitorDispatcher.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcher\\:\\:setOutputGenerator\\(\\) has no return type specified\\.$#"
count: 1
path: src/contracts/Output/ValueObjectVisitorDispatcher.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcher\\:\\:setOutputVisitor\\(\\) has no return type specified\\.$#"
count: 1
path: src/contracts/Output/ValueObjectVisitorDispatcher.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\Visitor\\:\\:setHeader\\(\\) has no return type specified\\.$#"
count: 1
Expand All @@ -450,16 +430,6 @@ parameters:
count: 1
path: src/contracts/Output/Visitor.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\Visitor\\:\\:\\$statusCode \\(int\\) does not accept null\\.$#"
count: 1
path: src/contracts/Output/Visitor.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\Visitor\\:\\:\\$valueObjectVisitorDispatcher \\(Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcher\\) does not accept default value of type array\\.$#"
count: 1
path: src/contracts/Output/Visitor.php

-
message: "#^Method Ibexa\\\\Rest\\\\FieldTypeProcessor\\\\BaseRelationProcessor\\:\\:setLocationService\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -3570,11 +3540,6 @@ parameters:
count: 1
path: tests/bundle/DependencyInjection/Compiler/OutputVisitorPassTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Bundle\\\\Rest\\\\DependencyInjection\\\\Compiler\\\\ValueObjectVisitorPassTest\\:\\:testProcess\\(\\) has no return type specified\\.$#"
count: 1
path: tests/bundle/DependencyInjection/Compiler/ValueObjectVisitorPassTest.php

-
message: "#^Parameter \\#2 \\$method of function method_exists expects string, array\\<int\\|string, int\\|string\\>\\|int\\|string given\\.$#"
count: 1
Expand Down Expand Up @@ -6695,98 +6660,13 @@ parameters:
count: 1
path: tests/lib/Output/ValueObjectVisitorBaseTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcherTest\\:\\:testVisitValueObject\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/ValueObjectVisitorDispatcherTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcherTest\\:\\:testVisitValueObjectInvalidType\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/ValueObjectVisitorDispatcherTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcherTest\\:\\:testVisitValueObjectNoMatch\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/ValueObjectVisitorDispatcherTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcherTest\\:\\:testVisitValueObjectParentMatch\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/ValueObjectVisitorDispatcherTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcherTest\\:\\:testVisitValueObjectSecondRuleParentMatch\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/ValueObjectVisitorDispatcherTest.php

-
message: "#^Parameter \\#1 \\$data of method Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcher\\:\\:visit\\(\\) expects object, int given\\.$#"
count: 1
path: tests/lib/Output/ValueObjectVisitorDispatcherTest.php

-
message: "#^Property Ibexa\\\\Tests\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcherTest\\:\\:\\$outputGeneratorMock \\(Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\Generator&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: tests/lib/Output/ValueObjectVisitorDispatcherTest.php

-
message: "#^Property Ibexa\\\\Tests\\\\Rest\\\\Output\\\\ValueObjectVisitorDispatcherTest\\:\\:\\$outputVisitorMock \\(Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\Visitor&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: tests/lib/Output/ValueObjectVisitorDispatcherTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:getGeneratorMock\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:getVisitorMock\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:testSetFilteredHeaders\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:testSetHeaderResetAfterVisit\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:testSetHeaders\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:testSetHeadersNoOverwrite\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:testSetStatusCode\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:testSetStatusCodeNoOverride\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:testVisitDocument\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:testVisitEmptyDocument\\(\\) has no return type specified\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Rest\\\\Output\\\\VisitorTest\\:\\:testVisitValueObject\\(\\) has no return type specified\\.$#"
message: "#^Parameter \\#2 \\$value of method Ibexa\\\\Contracts\\\\Rest\\\\Output\\\\Visitor\\:\\:setHeader\\(\\) expects string, false given\\.$#"
count: 1
path: tests/lib/Output/VisitorTest.php

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Compiler pass for the ibexa.rest.output.value_object.visitor tag.
* Maps a fully qualified class to a value object visitor.
*/
class ValueObjectVisitorResolverPass implements CompilerPassInterface
final class ValueObjectVisitorResolverPass implements CompilerPassInterface
{
public const string OUTPUT_VALUE_OBJECT_VISITOR_SERVICE_TAG = 'ibexa.rest.output.value_object.visitor';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

namespace Ibexa\Contracts\Rest\Input\Parser\Query\Criterion;

use Ibexa\Contracts\Rest\Exceptions;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Output/Generator/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,6 @@ public function serializeBool($boolValue)

public function toArray(): array
{
return json_decode(json_encode($this->json), true);
return json_decode(json_encode($this->json, JSON_THROW_ON_ERROR), true, JSON_THROW_ON_ERROR);
}
}
38 changes: 0 additions & 38 deletions src/lib/Output/Normalizer/TestData.php

This file was deleted.

38 changes: 0 additions & 38 deletions src/lib/Output/Normalizer/TestNormalizer.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@

namespace Ibexa\Tests\Bundle\Rest\DependencyInjection\Compiler;

use Ibexa\Bundle\Rest\DependencyInjection\Compiler\ValueObjectVisitorPass;
use Ibexa\Contracts\Rest\Output\ValueObjectVisitorDispatcher;
use Ibexa\Bundle\Rest\DependencyInjection\Compiler\ValueObjectVisitorResolverPass;
use Ibexa\Contracts\Rest\Output\ValueObjectVisitorResolver;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class ValueObjectVisitorPassTest extends TestCase
final class ValueObjectVisitorResolverPassTest extends TestCase
{
public function testProcess()
public function testProcess(): void
{
$visitorDefinition = new Definition();
$visitorDefinition->addTag('ibexa.rest.output.value_object.visitor', ['type' => 'test']);

$containerBuilder = new ContainerBuilder();
$containerBuilder->addDefinitions(
[
ValueObjectVisitorDispatcher::class => new Definition(),
ValueObjectVisitorResolver::class => new Definition(),
'ezpublish_rest.output.value_object_visitor.test' => $visitorDefinition,
]
);

$compilerPass = new ValueObjectVisitorPass();
$compilerPass = new ValueObjectVisitorResolverPass();
$compilerPass->process($containerBuilder);

$dispatcherMethodCalls = $containerBuilder
->getDefinition(ValueObjectVisitorDispatcher::class)
->getDefinition(ValueObjectVisitorResolver::class)
->getMethodCalls();
self::assertTrue(isset($dispatcherMethodCalls[0][0]), 'Failed asserting that dispatcher has a method call');
self::assertEquals('addVisitor', $dispatcherMethodCalls[0][0], "Failed asserting that called method is 'addVisitor'");
Expand Down
Loading

0 comments on commit e5c474a

Please sign in to comment.