Skip to content

Commit 2df0e85

Browse files
committed
adjusted spec test cases, regenerated baseline
1 parent 8a08766 commit 2df0e85

6 files changed

Lines changed: 29 additions & 75 deletions

File tree

phpstan-baseline.neon

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,6 @@ parameters:
666666
count: 1
667667
path: spec/ResponseTagger/Value/ContentInfoTaggerSpec.php
668668

669-
-
670-
message: '#^Call to an undefined method FOS\\HttpCache\\ResponseTagger\:\:willReturn\(\)\.$#'
671-
identifier: method.notFound
672-
count: 1
673-
path: spec/ResponseTagger/Value/ContentInfoTaggerSpec.php
674-
675669
-
676670
message: '#^Call to an undefined method spec\\Ibexa\\HttpCache\\ResponseTagger\\Value\\ContentInfoTaggerSpec\:\:tag\(\)\.$#'
677671
identifier: method.notFound
@@ -684,18 +678,6 @@ parameters:
684678
count: 1
685679
path: spec/ResponseTagger/Value/ContentInfoTaggerSpec.php
686680

687-
-
688-
message: '#^Method FOS\\HttpCache\\ResponseTagger\:\:addTags\(\) invoked with 0 parameters, 1 required\.$#'
689-
identifier: arguments.count
690-
count: 1
691-
path: spec/ResponseTagger/Value/ContentInfoTaggerSpec.php
692-
693-
-
694-
message: '#^Parameter \#1 \$tags of method FOS\\HttpCache\\ResponseTagger\:\:addTags\(\) expects array\<string\>, Prophecy\\Argument\\Token\\AnyValueToken given\.$#'
695-
identifier: argument.type
696-
count: 1
697-
path: spec/ResponseTagger/Value/ContentInfoTaggerSpec.php
698-
699681
-
700682
message: '#^Call to an undefined method FOS\\HttpCache\\ResponseTagger\:\:shouldHaveBeenCalled\(\)\.$#'
701683
identifier: method.notFound
@@ -1152,6 +1134,12 @@ parameters:
11521134
count: 1
11531135
path: src/lib/ResponseTagger/Value/ContentInfoTagger.php
11541136

1137+
-
1138+
message: '#^Variable \$logger on left side of \?\? always exists and is not nullable\.$#'
1139+
identifier: nullCoalesce.variable
1140+
count: 1
1141+
path: src/lib/ResponseTagger/Value/ContentInfoTagger.php
1142+
11551143
-
11561144
message: '#^Method Ibexa\\HttpCache\\ResponseTagger\\Value\\LocationTagger\:\:tag\(\) has no return type specified\.$#'
11571145
identifier: missingType.return

phpstan.neon.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ parameters:
99
- src
1010
- spec
1111
treatPhpDocTypesAsCertain: false
12-
ignoreErrors:
13-
-
14-
message: "#^Cannot call method (log|debug|info|notice|warning|error|critical|alert|emergency)\\(\\) on Psr\\\\Log\\\\LoggerInterface\\|null\\.$#"

spec/ResponseTagger/Value/ContentInfoTaggerSpec.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
<?php
22

3-
/**
4-
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5-
* @license For full copyright and license information view LICENSE file distributed with this source code.
6-
*/
7-
83
namespace spec\Ibexa\HttpCache\ResponseTagger\Value;
94

10-
use FOS\HttpCache\ResponseTagger;
115
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
6+
use Ibexa\Core\Repository\Values\Content\Location;
127
use Ibexa\HttpCache\ResponseTagger\Value\ContentInfoTagger;
8+
use FOS\HttpCache\ResponseTagger;
139
use PhpSpec\ObjectBehavior;
14-
use Prophecy\Argument;
10+
use RuntimeException;
1511

1612
class ContentInfoTaggerSpec extends ObjectBehavior
1713
{
1814
public function let(ResponseTagger $tagHandler): void
1915
{
2016
$this->beConstructedWith($tagHandler);
21-
22-
$tagHandler->addTags(Argument::any())->willReturn($tagHandler);
2317
}
2418

2519
public function it_is_initializable(): void
@@ -29,18 +23,14 @@ public function it_is_initializable(): void
2923

3024
public function it_ignores_non_content_info(ResponseTagger $tagHandler): void
3125
{
32-
$this->tag(null);
26+
$this->tag(new Location());
3327

34-
$tagHandler->addTags()->shouldNotHaveBeenCalled();
28+
$tagHandler->addTags([])->shouldNotHaveBeenCalled();
3529
}
3630

3731
public function it_tags_with_content_and_content_type_id(ResponseTagger $tagHandler): void
3832
{
39-
$value = new ContentInfo([
40-
'id' => 123,
41-
'mainLocationId' => 456,
42-
'contentTypeId' => 987,
43-
]);
33+
$value = new ContentInfo(['id' => 123, 'contentTypeId' => 987]);
4434

4535
$this->tag($value);
4636

@@ -49,11 +39,7 @@ public function it_tags_with_content_and_content_type_id(ResponseTagger $tagHand
4939

5040
public function it_tags_with_location_id_if_one_is_set(ResponseTagger $tagHandler): void
5141
{
52-
$value = new ContentInfo([
53-
'id' => 123,
54-
'mainLocationId' => 456,
55-
'contentTypeId' => 987,
56-
]);
42+
$value = new ContentInfo(['mainLocationId' => 456]);
5743

5844
$this->tag($value);
5945

spec/ResponseTagger/Value/LocationTaggerSpec.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Ibexa\HttpCache\ResponseTagger\Value\LocationTagger;
1414
use PhpSpec\ObjectBehavior;
1515
use Prophecy\Argument;
16+
use RuntimeException;
1617

1718
class LocationTaggerSpec extends ObjectBehavior
1819
{
@@ -30,7 +31,7 @@ public function it_is_initializable(): void
3031

3132
public function it_ignores_non_location(ResponseTagger $tagHandler): void
3233
{
33-
$this->tag(null);
34+
$this->tag(new ContentInfo());
3435

3536
$tagHandler->addTags(Argument::any())->shouldNotHaveBeenCalled();
3637
}

src/lib/ResponseTagger/Value/ContentInfoTagger.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,20 @@
1111
use FOS\HttpCache\ResponseTagger as FosResponseTagger;
1212
use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo;
1313
use Ibexa\Contracts\HttpCache\Handler\ContentTagInterface;
14-
use Psr\Log\LoggerAwareInterface;
15-
use Psr\Log\LoggerAwareTrait;
1614
use Psr\Log\LoggerInterface;
1715
use Psr\Log\NullLogger;
1816
use RuntimeException;
1917

20-
class ContentInfoTagger extends AbstractValueTagger implements LoggerAwareInterface
18+
class ContentInfoTagger extends AbstractValueTagger
2119
{
22-
use LoggerAwareTrait;
23-
24-
private bool $debug;
25-
2620
public function __construct(
2721
FosResponseTagger $responseTagger,
28-
?LoggerInterface $logger = null,
29-
bool $debug = false
22+
private LoggerInterface $logger = new NullLogger(),
23+
private readonly bool $debug = false
3024
) {
3125
parent::__construct($responseTagger);
3226

3327
$this->logger = $logger ?? new NullLogger();
34-
$this->debug = $debug;
3528
}
3629

3730
public function tag($value)
@@ -54,14 +47,14 @@ public function tag($value)
5447
}
5548

5649
$this->responseTagger->addTags([
57-
ContentTagInterface::CONTENT_PREFIX . $value->id,
50+
ContentTagInterface::CONTENT_PREFIX . $value->getId(),
5851
ContentTagInterface::CONTENT_TYPE_PREFIX . $value->contentTypeId,
5952
]);
6053

6154
if ($value->mainLocationId) {
62-
$this->responseTagger->addTags([ContentTagInterface::LOCATION_PREFIX . $value->mainLocationId]);
55+
$this->responseTagger->addTags([
56+
ContentTagInterface::LOCATION_PREFIX . $value->getMainLocationId(),
57+
]);
6358
}
6459
}
6560
}
66-
67-
class_alias(ContentInfoTagger::class, 'EzSystems\PlatformHttpCacheBundle\ResponseTagger\Value\ContentInfoTagger');

src/lib/ResponseTagger/Value/LocationTagger.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,18 @@
1111
use FOS\HttpCache\ResponseTagger as FosResponseTagger;
1212
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
1313
use Ibexa\Contracts\HttpCache\Handler\ContentTagInterface;
14-
use Psr\Log\LoggerAwareInterface;
15-
use Psr\Log\LoggerAwareTrait;
1614
use Psr\Log\LoggerInterface;
1715
use Psr\Log\NullLogger;
1816
use RuntimeException;
1917

20-
class LocationTagger extends AbstractValueTagger implements LoggerAwareInterface
18+
class LocationTagger extends AbstractValueTagger
2119
{
22-
use LoggerAwareTrait;
23-
24-
private bool $debug;
25-
2620
public function __construct(
2721
FosResponseTagger $responseTagger,
28-
?LoggerInterface $logger = null,
29-
bool $debug = false
22+
private LoggerInterface $logger = new NullLogger(),
23+
private readonly bool $debug = false
3024
) {
3125
parent::__construct($responseTagger);
32-
33-
$this->logger = $logger ?? new NullLogger();
34-
$this->debug = $debug;
3526
}
3627

3728
public function tag($value)
@@ -53,20 +44,18 @@ public function tag($value)
5344
return $this;
5445
}
5546

56-
if ($value->id !== $value->contentInfo->mainLocationId) {
57-
$this->responseTagger->addTags([ContentTagInterface::LOCATION_PREFIX . $value->id]);
47+
if ($value->id !== $value->getContentInfo()->getMainLocationId()) {
48+
$this->responseTagger->addTags([ContentTagInterface::LOCATION_PREFIX . $value->getId()]);
5849
}
5950

6051
$this->responseTagger->addTags([ContentTagInterface::PARENT_LOCATION_PREFIX . $value->parentLocationId]);
6152
$this->responseTagger->addTags(
6253
array_map(
63-
static function ($pathItem) {
54+
static function ($pathItem): string {
6455
return ContentTagInterface::PATH_PREFIX . $pathItem;
6556
},
66-
$value->path
57+
$value->getPath()
6758
)
6859
);
6960
}
7061
}
71-
72-
class_alias(LocationTagger::class, 'EzSystems\PlatformHttpCacheBundle\ResponseTagger\Value\LocationTagger');

0 commit comments

Comments
 (0)