Skip to content

Commit 296be93

Browse files
authored
Add Symfony 7.2 and PHP 8.4 to test matrix, add typing, fix deprecations and remove superfluous docblock (#351)
1 parent 62bf18a commit 296be93

40 files changed

+46
-163
lines changed

.github/workflows/tests.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ jobs:
2424
symfony-version: 5.4.*
2525
- php-version: 8.1
2626
symfony-version: 6.4.*
27-
- php-version: 8.3
27+
- php-version: 8.4
2828
symfony-version: 6.4.*
2929
- php-version: 8.2
30-
symfony-version: 7.1.*
31-
- php-version: 8.3
32-
symfony-version: 7.1.*
30+
symfony-version: 7.2.*
31+
- php-version: 8.4
32+
symfony-version: 7.2.*
3333

3434
steps:
3535
- name: "Checkout"
@@ -61,8 +61,8 @@ jobs:
6161
strategy:
6262
matrix:
6363
include:
64-
- php-version: 8.3
65-
symfony-version: 7.1.*
64+
- php-version: 8.4
65+
symfony-version: 7.2.*
6666

6767
steps:
6868
- name: "Checkout"
@@ -100,8 +100,8 @@ jobs:
100100
strategy:
101101
matrix:
102102
include:
103-
- php-version: 8.3
104-
symfony-version: 7.1.*
103+
- php-version: 8.4
104+
symfony-version: 7.2.*
105105

106106
steps:
107107
- name: "Checkout"
@@ -133,8 +133,8 @@ jobs:
133133
strategy:
134134
matrix:
135135
include:
136-
- php-version: 8.3
137-
symfony-version: 7.1.*
136+
- php-version: 8.4
137+
symfony-version: 7.2.*
138138

139139
steps:
140140
- name: "Checkout"

phpstan-baseline.neon

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
parameters:
22
ignoreErrors:
3+
-
4+
message: "#^Offset 1 does not exist on array\\{0\\?\\: string, 1\\?\\: non\\-empty\\-string, 2\\?\\: '\\.gz'\\}\\.$#"
5+
count: 1
6+
path: src/Service/Dumper.php
7+
38
-
49
message: "#^Offset 'uri' on array\\{timed_out\\: bool, blocked\\: bool, eof\\: bool, unread_bytes\\: int, stream_type\\: string, wrapper_type\\: string, wrapper_data\\: mixed, mode\\: string, \\.\\.\\.\\} in isset\\(\\) always exists and is not nullable\\.$#"
510
count: 1

src/Event/SitemapPopulateEvent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class SitemapPopulateEvent extends Event
4747
public function __construct(
4848
UrlContainerInterface $urlContainer,
4949
UrlGeneratorInterface $urlGenerator,
50-
string $section = null
50+
?string $section = null
5151
) {
5252
$this->urlContainer = $urlContainer;
5353
$this->section = $section;

src/Messenger/DumpSitemapMessage.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class DumpSitemapMessage
4343
* @param array<string, mixed> $options
4444
*/
4545
public function __construct(
46-
string $section = null,
47-
string $baseUrl = null,
48-
string $targetDir = null,
46+
?string $section = null,
47+
?string $baseUrl = null,
48+
?string $targetDir = null,
4949
array $options = []
5050
) {
5151
$this->section = $section;

src/Service/AbstractGenerator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ abstract class AbstractGenerator implements UrlContainerInterface
6565
public function __construct(
6666
EventDispatcherInterface $dispatcher,
6767
UrlGeneratorInterface $urlGenerator,
68-
int $itemsBySet = null
68+
?int $itemsBySet = null
6969
) {
7070
$this->dispatcher = $dispatcher;
7171
// We add one to LIMIT_ITEMS because it was used as an index, not a quantity
@@ -146,14 +146,14 @@ public function getUrlset(string $name): Urlset
146146
*
147147
* @return Urlset
148148
*/
149-
abstract protected function newUrlset(string $name, \DateTimeInterface $lastmod = null): Urlset;
149+
abstract protected function newUrlset(string $name, ?\DateTimeInterface $lastmod = null): Urlset;
150150

151151
/**
152152
* Dispatches SitemapPopulate Event - the listeners should use it to add their URLs to the sitemap
153153
*
154154
* @param string|null $section
155155
*/
156-
protected function populate(string $section = null): void
156+
protected function populate(?string $section = null): void
157157
{
158158
$event = new SitemapPopulateEvent($this, $this->urlGenerator, $section);
159159

src/Service/Dumper.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(
5858
Filesystem $filesystem,
5959
UrlGeneratorInterface $urlGenerator,
6060
string $sitemapFilePrefix = Configuration::DEFAULT_FILENAME,
61-
int $itemsBySet = null
61+
?int $itemsBySet = null
6262
) {
6363
parent::__construct($dispatcher, $urlGenerator, $itemsBySet);
6464

@@ -69,7 +69,7 @@ public function __construct(
6969
/**
7070
* @inheritdoc
7171
*/
72-
public function dump(string $targetDir, string $host, string $section = null, array $options = [])
72+
public function dump(string $targetDir, string $host, ?string $section = null, array $options = [])
7373
{
7474
/** @var array{gzip: bool} $options */
7575
$options = array_merge(['gzip' => false], $options);
@@ -262,7 +262,7 @@ protected function deleteExistingSitemaps(string $targetDir): void
262262
*
263263
* @return DumpingUrlset|Urlset
264264
*/
265-
protected function newUrlset(string $name, \DateTimeInterface $lastmod = null, bool $gzExtension = false): Urlset
265+
protected function newUrlset(string $name, ?\DateTimeInterface $lastmod = null, bool $gzExtension = false): Urlset
266266
{
267267
$url = $this->baseUrl . $this->sitemapFilePrefix . '.' . $name . '.xml';
268268
if ($gzExtension) {

src/Service/DumperInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ interface DumperInterface extends UrlContainerInterface
2626
*
2727
* @return array<int, string>|bool
2828
*/
29-
public function dump(string $targetDir, string $host, string $section = null, array $options = []);
29+
public function dump(string $targetDir, string $host, ?string $section = null, array $options = []);
3030
}

src/Service/Generator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Generator extends AbstractGenerator implements GeneratorInterface
3434
public function __construct(
3535
EventDispatcherInterface $dispatcher,
3636
UrlGeneratorInterface $router,
37-
int $itemsBySet = null
37+
?int $itemsBySet = null
3838
) {
3939
parent::__construct($dispatcher, $router, $itemsBySet);
4040

@@ -65,7 +65,7 @@ public function fetch(string $name): ?XmlConstraint
6565
/**
6666
* @inheritdoc
6767
*/
68-
protected function newUrlset(string $name, \DateTimeInterface $lastmod = null): Urlset
68+
protected function newUrlset(string $name, ?\DateTimeInterface $lastmod = null): Urlset
6969
{
7070
return new Urlset(
7171
$this->router->generate(

src/Sitemap/Url/GoogleImage.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ class GoogleImage
5656
*/
5757
public function __construct(
5858
string $location,
59-
string $caption = null,
60-
string $geoLocation = null,
61-
string $title = null,
62-
string $license = null
59+
?string $caption = null,
60+
?string $geoLocation = null,
61+
?string $title = null,
62+
?string $license = null
6363
) {
6464
$this->setLocation($location);
6565
$this->setCaption($caption);

src/Sitemap/Url/GoogleMultilangUrlDecorator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class GoogleMultilangUrlDecorator extends UrlDecorator
4343
*
4444
* @return GoogleMultilangUrlDecorator
4545
*/
46-
public function addLink(string $href, string $hreflang, string $rel = null): self
46+
public function addLink(string $href, string $hreflang, ?string $rel = null): self
4747
{
4848
$this->linkXml .= $this->generateLinkXml($href, $hreflang, $rel);
4949

@@ -57,7 +57,7 @@ public function addLink(string $href, string $hreflang, string $rel = null): sel
5757
*
5858
* @return string
5959
*/
60-
protected function generateLinkXml(string $href, string $hreflang, string $rel = null): string
60+
protected function generateLinkXml(string $href, string $hreflang, ?string $rel = null): string
6161
{
6262
if (null == $rel) {
6363
$rel = self::REL_ALTERNATE;

src/Sitemap/Url/GoogleVideo.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public function setPublicationDate(DateTimeInterface $publicationDate): self
528528
*
529529
* @return GoogleVideo
530530
*/
531-
public function setFamilyFriendly(string $familyFriendly = null): self
531+
public function setFamilyFriendly(?string $familyFriendly = null): self
532532
{
533533
if (null == $familyFriendly) {
534534
$familyFriendly = self::FAMILY_FRIENDLY_YES;
@@ -881,7 +881,7 @@ public function getLive(): ?string
881881
*
882882
* @return GoogleVideo
883883
*/
884-
public function addPrice($amount, string $currency, string $type = null, string $resolution = null): self
884+
public function addPrice($amount, string $currency, ?string $type = null, ?string $resolution = null): self
885885
{
886886
$this->prices[] = [
887887
'amount' => $amount,

src/Sitemap/Url/UrlConcrete.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class UrlConcrete implements Url
5959
*/
6060
public function __construct(
6161
string $loc,
62-
DateTimeInterface $lastmod = null,
63-
string $changefreq = null,
62+
?DateTimeInterface $lastmod = null,
63+
?string $changefreq = null,
6464
$priority = null
6565
) {
6666
$this->setLoc($loc);
@@ -116,7 +116,7 @@ public function getLastmod(): ?DateTimeInterface
116116
*
117117
* @return UrlConcrete
118118
*/
119-
public function setChangefreq(string $changefreq = null): self
119+
public function setChangefreq(?string $changefreq = null): self
120120
{
121121
$frequencies = [
122122
self::CHANGEFREQ_ALWAYS,

src/Sitemap/Urlset.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Urlset extends XmlConstraint
4848
* @param string $loc
4949
* @param DateTimeInterface|null $lastmod
5050
*/
51-
public function __construct(string $loc, DateTimeInterface $lastmod = null)
51+
public function __construct(string $loc, ?DateTimeInterface $lastmod = null)
5252
{
5353
$this->loc = $loc;
5454
$this->lastmod = $lastmod ?? new \DateTimeImmutable();

tests/Integration/config/6.1/framework.yaml

-14
This file was deleted.

tests/Integration/config/6.1/routes/controllers.yaml

-3
This file was deleted.

tests/Integration/config/6.3/framework.yaml

-14
This file was deleted.

tests/Integration/config/6.3/messenger.yaml

-6
This file was deleted.

tests/Integration/config/6.3/presta_sitemap.yaml

-9
This file was deleted.

tests/Integration/config/6.3/routes/controllers.yaml

-3
This file was deleted.

tests/Integration/config/6.3/routes/presta_sitemap.yaml

-2
This file was deleted.

tests/Integration/config/6.3/routes/translated.yaml

-7
This file was deleted.

tests/Integration/config/6.3/routes/xml.xml

-14
This file was deleted.

tests/Integration/config/6.3/routes/yaml.yaml

-6
This file was deleted.

tests/Integration/config/7.1/messenger.yaml

-6
This file was deleted.

tests/Integration/config/7.1/presta_sitemap.yaml

-9
This file was deleted.

tests/Integration/config/7.1/routes/presta_sitemap.yaml

-2
This file was deleted.

tests/Integration/config/7.1/routes/translated.yaml

-7
This file was deleted.

tests/Integration/config/7.1/routes/xml.xml

-14
This file was deleted.

tests/Integration/config/7.1/routes/yaml.yaml

-6
This file was deleted.

tests/Unit/Command/DumpSitemapsCommandTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function baseUrls(): \Generator
149149
yield 'Custom https port' => ['https://host.org:8080', 'https://host.org:8080/'];
150150
}
151151

152-
private function executeCommand(?string $section, bool $gzip, string $baseUrl = null): array
152+
private function executeCommand(?string $section, bool $gzip, ?string $baseUrl = null): array
153153
{
154154
$options = ['target' => self::TARGET_DIR, '--gzip' => $gzip];
155155
if ($section !== null) {

0 commit comments

Comments
 (0)