From 131cc6bbd64bbf1134d8f49b61ac9cfef300e3d3 Mon Sep 17 00:00:00 2001 From: Tim Bond Date: Fri, 12 Apr 2024 15:49:48 -0700 Subject: [PATCH] Upgrade PHP Code Sniffer --- composer.json | 2 +- composer.lock | 12 +++++----- src/Builder/MeetupCollection.php | 2 +- src/Builder/Processor/HTMLProcessor.php | 2 +- src/Builder/Processor/HomepageProcessor.php | 1 - .../Processor/MissingLinkProcessor.php | 1 - src/Builder/SiteBuilderService.php | 2 +- src/Generator/MeetupGeneratorService.php | 2 +- .../Processor/RssFeedProcessorTest.php | 8 +++---- .../Generator/MeetupGeneratorCommandTest.php | 24 +++++++++++++++---- .../Generator/MeetupGeneratorServiceTest.php | 2 +- 11 files changed, 35 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index ef82902..ce0220c 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "league/commonmark": "^2.3", "nette/php-generator": "^4.0.0", "psr/log": "^3.0.0", - "squizlabs/php_codesniffer": "3.*", + "squizlabs/php_codesniffer": "^3.9.1", "symfony/console": "^6.1", "twig/markdown-extra": "^3.4", "twig/twig": "^3.0.0" diff --git a/composer.lock b/composer.lock index 596486a..f3ab5f0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1e9e8ade947910345f96765ec101e1b5", + "content-hash": "24abf28c38698abaf9fbe36f5cd0860d", "packages": [ { "name": "dflydev/dot-access-data", @@ -641,16 +641,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.8.1", + "version": "3.9.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", "shasum": "" }, "require": { @@ -717,7 +717,7 @@ "type": "open_collective" } ], - "time": "2024-01-11T20:47:48+00:00" + "time": "2024-03-31T21:03:09+00:00" }, { "name": "symfony/console", diff --git a/src/Builder/MeetupCollection.php b/src/Builder/MeetupCollection.php index 30ab8de..1c3716e 100644 --- a/src/Builder/MeetupCollection.php +++ b/src/Builder/MeetupCollection.php @@ -57,7 +57,7 @@ public function count(): int return count($this->array); } - public function append(MeetupEntry $meetup) + public function append(MeetupEntry $meetup): void { $this->array[] = $meetup; } diff --git a/src/Builder/Processor/HTMLProcessor.php b/src/Builder/Processor/HTMLProcessor.php index fe01876..246d539 100644 --- a/src/Builder/Processor/HTMLProcessor.php +++ b/src/Builder/Processor/HTMLProcessor.php @@ -9,7 +9,7 @@ abstract class HTMLProcessor extends AbstractProcessor { - protected function writeHtml(string $html, string $filename, DateTimeImmutable $modifiedTime = null) + protected function writeHtml(string $html, string $filename, DateTimeImmutable $modifiedTime = null): void { $destination = "$this->outputDirectory/$filename"; $path = substr($destination, 0, strlen(basename($destination)) * -1); diff --git a/src/Builder/Processor/HomepageProcessor.php b/src/Builder/Processor/HomepageProcessor.php index 917648c..b5271fd 100644 --- a/src/Builder/Processor/HomepageProcessor.php +++ b/src/Builder/Processor/HomepageProcessor.php @@ -6,7 +6,6 @@ use DateTimeImmutable; use MergePHP\Website\Builder\MeetupCollection; -use MergePHP\Website\Meetups; use Psr\Log\LoggerInterface; use Twig\Environment; diff --git a/src/Builder/Processor/MissingLinkProcessor.php b/src/Builder/Processor/MissingLinkProcessor.php index a51c604..e23d833 100644 --- a/src/Builder/Processor/MissingLinkProcessor.php +++ b/src/Builder/Processor/MissingLinkProcessor.php @@ -20,7 +20,6 @@ public function __construct( public function run(): void { $this->logger->info('Checking for missing YouTube links'); - $buckets = []; foreach ($this->meetups->withOnlyPast() as $meetup) { if ($meetup->instance->getYouTubeLink() === null) { diff --git a/src/Builder/SiteBuilderService.php b/src/Builder/SiteBuilderService.php index 29fed28..6c864e3 100644 --- a/src/Builder/SiteBuilderService.php +++ b/src/Builder/SiteBuilderService.php @@ -27,7 +27,7 @@ class SiteBuilderService { - protected const APP_ROOT = __DIR__ . '/../..'; + protected const string APP_ROOT = __DIR__ . '/../..'; private Environment $twig; public function __construct(protected string $outputDirectory, protected LoggerInterface $logger) diff --git a/src/Generator/MeetupGeneratorService.php b/src/Generator/MeetupGeneratorService.php index 1f9b413..0c6f9e5 100644 --- a/src/Generator/MeetupGeneratorService.php +++ b/src/Generator/MeetupGeneratorService.php @@ -23,7 +23,7 @@ public function __construct(public string $directory) } } - protected const SUGGESTED_DATE_FORMAT = 'Y-m-d'; + protected const string SUGGESTED_DATE_FORMAT = 'Y-m-d'; public function getSuggestedDate(string $baseDate = 'now'): string { diff --git a/tests/Builder/Processor/RssFeedProcessorTest.php b/tests/Builder/Processor/RssFeedProcessorTest.php index ac4dc83..63fb8b9 100644 --- a/tests/Builder/Processor/RssFeedProcessorTest.php +++ b/tests/Builder/Processor/RssFeedProcessorTest.php @@ -17,10 +17,10 @@ class RssFeedProcessorTest extends TestCase { - private const MEETUP_DATE_STRING = '2000-01-01T00:00:00+00:00'; - private const MODIFIED_DATE_STRING = '2000-01-02T00:00:00+00:00'; - private const EXPECTED_FILENAME = 'vfs://root/atom.xml'; - private const FIXTURES_DIR = __DIR__ . '/../../fixtures/'; + private const string MEETUP_DATE_STRING = '2000-01-01T00:00:00+00:00'; + private const string MODIFIED_DATE_STRING = '2000-01-02T00:00:00+00:00'; + private const string EXPECTED_FILENAME = 'vfs://root/atom.xml'; + private const string FIXTURES_DIR = __DIR__ . '/../../fixtures/'; public function setUp(): void { diff --git a/tests/Generator/MeetupGeneratorCommandTest.php b/tests/Generator/MeetupGeneratorCommandTest.php index e69a72c..abf818a 100644 --- a/tests/Generator/MeetupGeneratorCommandTest.php +++ b/tests/Generator/MeetupGeneratorCommandTest.php @@ -14,12 +14,26 @@ class MeetupGeneratorCommandTest extends TestCase { // generate args simulate what the user types in to the command line - private const GENERATE_1_ARGS = ['Title', 'Description', null , 'Name', 'Bio', null]; - private const GENERATE_2_ARGS = ['Title', 'Description', '2023-01-01', 'Name', 'Bio', null]; - private const GENERATE_3_ARGS = ['Title', 'Description', '2023-01-01', 'Name', 'Bio', 'https://example.com/f.jpg']; + private const array GENERATE_1_ARGS = ['Title', 'Description', null , 'Name', 'Bio', null]; + private const array GENERATE_2_ARGS = ['Title', 'Description', '2023-01-01', 'Name', 'Bio', null]; + private const array GENERATE_3_ARGS = [ + 'Title', + 'Description', + '2023-01-01', + 'Name', + 'Bio', + 'https://example.com/f.jpg' + ]; // command args are what the generator command expects to be called with given a certain set of generate args - private const COMMAND_1_2_ARGS = ['Title', 'Description', '2023-01-01', 'Name', 'Bio', null]; - private const COMMAND_3_ARGS = ['Title', 'Description', '2023-01-01', 'Name', 'Bio', 'https://example.com/f.jpg']; + private const array COMMAND_1_2_ARGS = ['Title', 'Description', '2023-01-01', 'Name', 'Bio', null]; + private const array COMMAND_3_ARGS = [ + 'Title', + 'Description', + '2023-01-01', + 'Name', + 'Bio', + 'https://example.com/f.jpg' + ]; private CommandTester $commandTester; diff --git a/tests/Generator/MeetupGeneratorServiceTest.php b/tests/Generator/MeetupGeneratorServiceTest.php index 8741c08..c3afbd2 100644 --- a/tests/Generator/MeetupGeneratorServiceTest.php +++ b/tests/Generator/MeetupGeneratorServiceTest.php @@ -11,7 +11,7 @@ class MeetupGeneratorServiceTest extends TestCase { private MeetupGeneratorService $generator; - private const FIXTURES_DIR = __DIR__ . '/../fixtures/'; + private const string FIXTURES_DIR = __DIR__ . '/../fixtures/'; public function setUp(): void {