Skip to content

Commit

Permalink
Add Symfony 7.2 and PHP 8.4 to test matrix, add typing, fix deprecati…
Browse files Browse the repository at this point in the history
…ons and remove superfluous docblock (#351)
  • Loading branch information
ker0x authored Jan 10, 2025
1 parent 62bf18a commit 296be93
Show file tree
Hide file tree
Showing 40 changed files with 46 additions and 163 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
symfony-version: 5.4.*
- php-version: 8.1
symfony-version: 6.4.*
- php-version: 8.3
- php-version: 8.4
symfony-version: 6.4.*
- php-version: 8.2
symfony-version: 7.1.*
- php-version: 8.3
symfony-version: 7.1.*
symfony-version: 7.2.*
- php-version: 8.4
symfony-version: 7.2.*

steps:
- name: "Checkout"
Expand Down Expand Up @@ -61,8 +61,8 @@ jobs:
strategy:
matrix:
include:
- php-version: 8.3
symfony-version: 7.1.*
- php-version: 8.4
symfony-version: 7.2.*

steps:
- name: "Checkout"
Expand Down Expand Up @@ -100,8 +100,8 @@ jobs:
strategy:
matrix:
include:
- php-version: 8.3
symfony-version: 7.1.*
- php-version: 8.4
symfony-version: 7.2.*

steps:
- name: "Checkout"
Expand Down Expand Up @@ -133,8 +133,8 @@ jobs:
strategy:
matrix:
include:
- php-version: 8.3
symfony-version: 7.1.*
- php-version: 8.4
symfony-version: 7.2.*

steps:
- name: "Checkout"
Expand Down
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
parameters:
ignoreErrors:
-
message: "#^Offset 1 does not exist on array\\{0\\?\\: string, 1\\?\\: non\\-empty\\-string, 2\\?\\: '\\.gz'\\}\\.$#"
count: 1
path: src/Service/Dumper.php

-
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\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion src/Event/SitemapPopulateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SitemapPopulateEvent extends Event
public function __construct(
UrlContainerInterface $urlContainer,
UrlGeneratorInterface $urlGenerator,
string $section = null
?string $section = null
) {
$this->urlContainer = $urlContainer;
$this->section = $section;
Expand Down
6 changes: 3 additions & 3 deletions src/Messenger/DumpSitemapMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class DumpSitemapMessage
* @param array<string, mixed> $options
*/
public function __construct(
string $section = null,
string $baseUrl = null,
string $targetDir = null,
?string $section = null,
?string $baseUrl = null,
?string $targetDir = null,
array $options = []
) {
$this->section = $section;
Expand Down
6 changes: 3 additions & 3 deletions src/Service/AbstractGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class AbstractGenerator implements UrlContainerInterface
public function __construct(
EventDispatcherInterface $dispatcher,
UrlGeneratorInterface $urlGenerator,
int $itemsBySet = null
?int $itemsBySet = null
) {
$this->dispatcher = $dispatcher;
// We add one to LIMIT_ITEMS because it was used as an index, not a quantity
Expand Down Expand Up @@ -146,14 +146,14 @@ public function getUrlset(string $name): Urlset
*
* @return Urlset
*/
abstract protected function newUrlset(string $name, \DateTimeInterface $lastmod = null): Urlset;
abstract protected function newUrlset(string $name, ?\DateTimeInterface $lastmod = null): Urlset;

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

Expand Down
6 changes: 3 additions & 3 deletions src/Service/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(
Filesystem $filesystem,
UrlGeneratorInterface $urlGenerator,
string $sitemapFilePrefix = Configuration::DEFAULT_FILENAME,
int $itemsBySet = null
?int $itemsBySet = null
) {
parent::__construct($dispatcher, $urlGenerator, $itemsBySet);

Expand All @@ -69,7 +69,7 @@ public function __construct(
/**
* @inheritdoc
*/
public function dump(string $targetDir, string $host, string $section = null, array $options = [])
public function dump(string $targetDir, string $host, ?string $section = null, array $options = [])
{
/** @var array{gzip: bool} $options */
$options = array_merge(['gzip' => false], $options);
Expand Down Expand Up @@ -262,7 +262,7 @@ protected function deleteExistingSitemaps(string $targetDir): void
*
* @return DumpingUrlset|Urlset
*/
protected function newUrlset(string $name, \DateTimeInterface $lastmod = null, bool $gzExtension = false): Urlset
protected function newUrlset(string $name, ?\DateTimeInterface $lastmod = null, bool $gzExtension = false): Urlset
{
$url = $this->baseUrl . $this->sitemapFilePrefix . '.' . $name . '.xml';
if ($gzExtension) {
Expand Down
2 changes: 1 addition & 1 deletion src/Service/DumperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ interface DumperInterface extends UrlContainerInterface
*
* @return array<int, string>|bool
*/
public function dump(string $targetDir, string $host, string $section = null, array $options = []);
public function dump(string $targetDir, string $host, ?string $section = null, array $options = []);
}
4 changes: 2 additions & 2 deletions src/Service/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Generator extends AbstractGenerator implements GeneratorInterface
public function __construct(
EventDispatcherInterface $dispatcher,
UrlGeneratorInterface $router,
int $itemsBySet = null
?int $itemsBySet = null
) {
parent::__construct($dispatcher, $router, $itemsBySet);

Expand Down Expand Up @@ -65,7 +65,7 @@ public function fetch(string $name): ?XmlConstraint
/**
* @inheritdoc
*/
protected function newUrlset(string $name, \DateTimeInterface $lastmod = null): Urlset
protected function newUrlset(string $name, ?\DateTimeInterface $lastmod = null): Urlset
{
return new Urlset(
$this->router->generate(
Expand Down
8 changes: 4 additions & 4 deletions src/Sitemap/Url/GoogleImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class GoogleImage
*/
public function __construct(
string $location,
string $caption = null,
string $geoLocation = null,
string $title = null,
string $license = null
?string $caption = null,
?string $geoLocation = null,
?string $title = null,
?string $license = null
) {
$this->setLocation($location);
$this->setCaption($caption);
Expand Down
4 changes: 2 additions & 2 deletions src/Sitemap/Url/GoogleMultilangUrlDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class GoogleMultilangUrlDecorator extends UrlDecorator
*
* @return GoogleMultilangUrlDecorator
*/
public function addLink(string $href, string $hreflang, string $rel = null): self
public function addLink(string $href, string $hreflang, ?string $rel = null): self
{
$this->linkXml .= $this->generateLinkXml($href, $hreflang, $rel);

Expand All @@ -57,7 +57,7 @@ public function addLink(string $href, string $hreflang, string $rel = null): sel
*
* @return string
*/
protected function generateLinkXml(string $href, string $hreflang, string $rel = null): string
protected function generateLinkXml(string $href, string $hreflang, ?string $rel = null): string
{
if (null == $rel) {
$rel = self::REL_ALTERNATE;
Expand Down
4 changes: 2 additions & 2 deletions src/Sitemap/Url/GoogleVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ public function setPublicationDate(DateTimeInterface $publicationDate): self
*
* @return GoogleVideo
*/
public function setFamilyFriendly(string $familyFriendly = null): self
public function setFamilyFriendly(?string $familyFriendly = null): self
{
if (null == $familyFriendly) {
$familyFriendly = self::FAMILY_FRIENDLY_YES;
Expand Down Expand Up @@ -881,7 +881,7 @@ public function getLive(): ?string
*
* @return GoogleVideo
*/
public function addPrice($amount, string $currency, string $type = null, string $resolution = null): self
public function addPrice($amount, string $currency, ?string $type = null, ?string $resolution = null): self
{
$this->prices[] = [
'amount' => $amount,
Expand Down
6 changes: 3 additions & 3 deletions src/Sitemap/Url/UrlConcrete.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class UrlConcrete implements Url
*/
public function __construct(
string $loc,
DateTimeInterface $lastmod = null,
string $changefreq = null,
?DateTimeInterface $lastmod = null,
?string $changefreq = null,
$priority = null
) {
$this->setLoc($loc);
Expand Down Expand Up @@ -116,7 +116,7 @@ public function getLastmod(): ?DateTimeInterface
*
* @return UrlConcrete
*/
public function setChangefreq(string $changefreq = null): self
public function setChangefreq(?string $changefreq = null): self
{
$frequencies = [
self::CHANGEFREQ_ALWAYS,
Expand Down
2 changes: 1 addition & 1 deletion src/Sitemap/Urlset.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Urlset extends XmlConstraint
* @param string $loc
* @param DateTimeInterface|null $lastmod
*/
public function __construct(string $loc, DateTimeInterface $lastmod = null)
public function __construct(string $loc, ?DateTimeInterface $lastmod = null)
{
$this->loc = $loc;
$this->lastmod = $lastmod ?? new \DateTimeImmutable();
Expand Down
14 changes: 0 additions & 14 deletions tests/Integration/config/6.1/framework.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions tests/Integration/config/6.1/routes/controllers.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions tests/Integration/config/6.3/framework.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions tests/Integration/config/6.3/messenger.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions tests/Integration/config/6.3/presta_sitemap.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions tests/Integration/config/6.3/routes/controllers.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/Integration/config/6.3/routes/presta_sitemap.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions tests/Integration/config/6.3/routes/translated.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions tests/Integration/config/6.3/routes/xml.xml

This file was deleted.

6 changes: 0 additions & 6 deletions tests/Integration/config/6.3/routes/yaml.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions tests/Integration/config/7.1/messenger.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions tests/Integration/config/7.1/presta_sitemap.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/Integration/config/7.1/routes/presta_sitemap.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions tests/Integration/config/7.1/routes/translated.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions tests/Integration/config/7.1/routes/xml.xml

This file was deleted.

6 changes: 0 additions & 6 deletions tests/Integration/config/7.1/routes/yaml.yaml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/Unit/Command/DumpSitemapsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function baseUrls(): \Generator
yield 'Custom https port' => ['https://host.org:8080', 'https://host.org:8080/'];
}

private function executeCommand(?string $section, bool $gzip, string $baseUrl = null): array
private function executeCommand(?string $section, bool $gzip, ?string $baseUrl = null): array
{
$options = ['target' => self::TARGET_DIR, '--gzip' => $gzip];
if ($section !== null) {
Expand Down
Loading

0 comments on commit 296be93

Please sign in to comment.