From 6524217b64cf4d519f2c7c01c2ac988c756c427c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2025 02:39:26 +0000 Subject: [PATCH 1/2] deps(composer): bump mediawiki/mediawiki-codesniffer Bumps the mediawiki group with 1 update: [mediawiki/mediawiki-codesniffer](https://github.com/wikimedia/mediawiki-tools-codesniffer). Updates `mediawiki/mediawiki-codesniffer` from 45.0.0 to 46.0.0 - [Changelog](https://github.com/wikimedia/mediawiki-tools-codesniffer/blob/master/HISTORY.md) - [Commits](https://github.com/wikimedia/mediawiki-tools-codesniffer/compare/v45.0.0...v46.0.0) --- updated-dependencies: - dependency-name: mediawiki/mediawiki-codesniffer dependency-type: direct:development update-type: version-update:semver-major dependency-group: mediawiki ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- composer.lock | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 1a839d2..313d92b 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "ext-intl": "*" }, "require-dev": { - "mediawiki/mediawiki-codesniffer": "45.0.0", + "mediawiki/mediawiki-codesniffer": "46.0.0", "mediawiki/minus-x": "1.1.3", "php-parallel-lint/php-console-highlighter": "1.0.0", "php-parallel-lint/php-parallel-lint": "1.4.0", diff --git a/composer.lock b/composer.lock index 5af5386..e0d52c0 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": "9c9d4074444ef39ac81a8ada633a38bd", + "content-hash": "a97deb9f1cd94f87a40de3b925f75e03", "packages": [ { "name": "wikimedia/assert", @@ -307,16 +307,16 @@ }, { "name": "mediawiki/mediawiki-codesniffer", - "version": "v45.0.0", + "version": "v46.0.0", "source": { "type": "git", "url": "https://github.com/wikimedia/mediawiki-tools-codesniffer.git", - "reference": "3ebb209514384d68ba52f16c26ba192a9027442d" + "reference": "6bd8a9ac4c10bf393dcd9ef32e3402399128a9e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/mediawiki-tools-codesniffer/zipball/3ebb209514384d68ba52f16c26ba192a9027442d", - "reference": "3ebb209514384d68ba52f16c26ba192a9027442d", + "url": "https://api.github.com/repos/wikimedia/mediawiki-tools-codesniffer/zipball/6bd8a9ac4c10bf393dcd9ef32e3402399128a9e5", + "reference": "6bd8a9ac4c10bf393dcd9ef32e3402399128a9e5", "shasum": "" }, "require": { @@ -326,16 +326,16 @@ "ext-mbstring": "*", "php": ">=7.4.0", "phpcsstandards/phpcsextra": "1.2.1", - "squizlabs/php_codesniffer": "3.10.3", + "squizlabs/php_codesniffer": "3.11.3", "symfony/polyfill-php80": "^1.26.0" }, "require-dev": { "ext-dom": "*", - "mediawiki/mediawiki-phan-config": "0.14.0", + "mediawiki/mediawiki-phan-config": "0.15.1", "mediawiki/minus-x": "1.1.3", "php-parallel-lint/php-console-highlighter": "1.0.0", "php-parallel-lint/php-parallel-lint": "1.4.0", - "phpunit/phpunit": "9.6.16" + "phpunit/phpunit": "9.6.21" }, "type": "phpcodesniffer-standard", "autoload": { @@ -355,9 +355,9 @@ "mediawiki" ], "support": { - "source": "https://github.com/wikimedia/mediawiki-tools-codesniffer/tree/v45.0.0" + "source": "https://github.com/wikimedia/mediawiki-tools-codesniffer/tree/v46.0.0" }, - "time": "2024-10-29T17:38:15+00:00" + "time": "2025-01-27T21:05:44+00:00" }, { "name": "mediawiki/minus-x", @@ -2377,16 +2377,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.10.3", + "version": "3.11.3", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", "shasum": "" }, "require": { @@ -2451,9 +2451,13 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-09-18T10:38:58+00:00" + "time": "2025-01-23T17:04:15+00:00" }, { "name": "staabm/side-effects-detector", From 1262a996ffeb35b68a23107aac1cfb990ecda762 Mon Sep 17 00:00:00 2001 From: Samantha Nguyen Date: Wed, 5 Feb 2025 12:30:49 -0600 Subject: [PATCH 2/2] fix phpcs lint errors --- src/MediaType.php | 2 +- src/MediaTypeParser.php | 21 +++++++++++---------- src/Utf8Utils.php | 8 ++++---- tests/Utf8UtilsTest.php | 22 +++++++++++----------- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/MediaType.php b/src/MediaType.php index 88321d4..0d75423 100644 --- a/src/MediaType.php +++ b/src/MediaType.php @@ -235,7 +235,7 @@ public function __toString(): string { $onlyContainsHttpCodepoints = Utf8Utils::onlyContains( $value, - fn ( string $s ) => Utf8Utils::isHttpTokenCodepoint( $s ) ); + static fn ( string $s ) => Utf8Utils::isHttpTokenCodepoint( $s ) ); if ( $value === '' || !$onlyContainsHttpCodepoints ) { $serializedValue = $this->serializeParameterValue( $value ); diff --git a/src/MediaTypeParser.php b/src/MediaTypeParser.php index fd386a9..b96c9f0 100644 --- a/src/MediaTypeParser.php +++ b/src/MediaTypeParser.php @@ -54,7 +54,7 @@ public function parseOrThrow( string|null $s ): MediaType { private function collectType( string $s, int $length, int &$position ): string { $type = Utf8Utils::collectCodepoints( $s, $position, - fn ( string $c ) => $c !== Token::Slash->value + static fn ( string $c ) => $c !== Token::Slash->value ); if ( $type === '' ) { @@ -62,7 +62,7 @@ private function collectType( string $s, int $length, int &$position ): string { } $onlyContainsHttpCodepoints = Utf8Utils::onlyContains( - $type, fn ( string $c ) => Utf8Utils::isHttpTokenCodepoint( $c ) ); + $type, static fn ( string $c ) => Utf8Utils::isHttpTokenCodepoint( $c ) ); if ( !$onlyContainsHttpCodepoints ) { throw new MediaTypeParserException( "type: should only contain HTTP codepoints" ); } @@ -82,7 +82,7 @@ private function collectType( string $s, int $length, int &$position ): string { private function collectSubType( string $s, int &$position ): string { $subType = Utf8Utils::collectCodepoints( $s, $position, - fn ( string $c ) => $c !== Token::Semicolon->value + static fn ( string $c ) => $c !== Token::Semicolon->value ); $subType = Utf8Utils::trimHttpWhitespace( $subType ); @@ -91,7 +91,7 @@ private function collectSubType( string $s, int &$position ): string { } $onlyContainsHttpCodepoints = Utf8Utils::onlyContains( - $subType, fn ( string $c ) => Utf8Utils::isHttpTokenCodepoint( $c ) ); + $subType, static fn ( string $c ) => Utf8Utils::isHttpTokenCodepoint( $c ) ); if ( !$onlyContainsHttpCodepoints ) { throw new MediaTypeParserException( "subtype: should only contain HTTP codepoints" ); } @@ -110,13 +110,13 @@ private function collectParameters( string $s, int $length, int &$position ): ar // skip whitespace Utf8Utils::collectCodepoints( $s, $position, - fn ( string $c ) => Utf8Utils::isHttpWhitespace( $c ) + static fn ( string $c ) => Utf8Utils::isHttpWhitespace( $c ) ); // collect parameter name $parameterName = Utf8Utils::collectCodepoints( $s, $position, - fn ( string $c ) => $c !== Token::Semicolon->value && $c !== Token::Equal->value + static fn ( string $c ) => $c !== Token::Semicolon->value && $c !== Token::Equal->value ); $parameterName = \strtolower( $parameterName ); @@ -135,10 +135,11 @@ private function collectParameters( string $s, int $length, int &$position ): ar $parameterValue = null; if ( $s[$position] === '"' ) { $parameterValue = Utf8Utils::collectHttpQuotedString( $s, $position, true ); - Utf8Utils::collectCodepoints( $s, $position, fn ( string $c ) => $c !== Token::Semicolon->value ); + Utf8Utils::collectCodepoints( $s, $position, + static fn ( string $c ) => $c !== Token::Semicolon->value ); } else { $parameterValue = Utf8Utils::collectCodepoints( $s, $position, - fn ( string $c ) => $c !== Token::Semicolon->value ); + static fn ( string $c ) => $c !== Token::Semicolon->value ); $parameterValue = Utf8Utils::trimHttpWhitespace( $parameterValue ); if ( $parameterValue === '' ) { @@ -150,9 +151,9 @@ private function collectParameters( string $s, int $length, int &$position ): ar if ( $parameterName !== '' && Utf8Utils::onlyContains( $parameterName, - fn ( string $c ) => Utf8Utils::isHttpTokenCodepoint( $c ) ) + static fn ( string $c ) => Utf8Utils::isHttpTokenCodepoint( $c ) ) && Utf8Utils::onlyContains( $parameterValue, - fn ( string $c ) => Utf8Utils::isHttpQuotedStringTokenCodepoint( $c ) ) + static fn ( string $c ) => Utf8Utils::isHttpQuotedStringTokenCodepoint( $c ) ) && !\array_key_exists( $parameterName, $parameters ) ) { $parameters[$parameterName] = $parameterValue; diff --git a/src/Utf8Utils.php b/src/Utf8Utils.php index fbcfb9d..202da5c 100644 --- a/src/Utf8Utils.php +++ b/src/Utf8Utils.php @@ -61,10 +61,10 @@ public static function collectHttpQuotedString( $positionStart = $position; $value = ''; - $expectedQuote = fn ( string $input, int $position, string $value ) => + $expectedQuote = static fn ( string $input, int $position, string $value ) => "Codepoint in \"{$input}\" at position {$position} is {$value}, expected U+0022 (\")"; Assert::invariant( - fn () => $input[$position] === '"', + static fn () => $input[$position] === '"', $expectedQuote( $input, $position, $input[$position] ) ); $position++; @@ -72,7 +72,7 @@ public static function collectHttpQuotedString( while ( true ) { $value .= self::collectCodepoints( $input, $position, - fn ( string $c ) => $c !== '"' && $c !== '\\' ); + static fn ( string $c ) => $c !== '"' && $c !== '\\' ); if ( $position >= \strlen( $input ) ) { break; @@ -90,7 +90,7 @@ public static function collectHttpQuotedString( $position++; } else { Assert::invariant( - fn () => $quoteOrBackslash === '"', + static fn () => $quoteOrBackslash === '"', $expectedQuote( $input, $position, $quoteOrBackslash ) ); break; } diff --git a/tests/Utf8UtilsTest.php b/tests/Utf8UtilsTest.php index 8628e2e..b7d18e9 100644 --- a/tests/Utf8UtilsTest.php +++ b/tests/Utf8UtilsTest.php @@ -106,12 +106,12 @@ public function testIsHttpWhitespace( public static function provideOnlyContains(): array { return [ - [ '', fn ( string $c ) => \ctype_alpha( $c ), true ], - [ 'test', fn ( string $c ) => \ctype_alpha( $c ), true ], - [ '1234', fn ( string $c ) => \ctype_digit( $c ), true ], - [ '1234test', fn ( string $c ) => \ctype_digit( $c ), false ], - [ 'test1234', fn ( string $c ) => \ctype_alpha( $c ), false ], - [ 'test1234', fn ( string $c ) => \ctype_alnum( $c ), true ], + [ '', static fn ( string $c ) => \ctype_alpha( $c ), true ], + [ 'test', static fn ( string $c ) => \ctype_alpha( $c ), true ], + [ '1234', static fn ( string $c ) => \ctype_digit( $c ), true ], + [ '1234test', static fn ( string $c ) => \ctype_digit( $c ), false ], + [ 'test1234', static fn ( string $c ) => \ctype_alpha( $c ), false ], + [ 'test1234', static fn ( string $c ) => \ctype_alnum( $c ), true ], ]; } @@ -151,11 +151,11 @@ public static function provideCollectHttpQuotedString(): array { public static function provideCollectCodepoints(): array { return [ - [ '', 0, '', 0, fn () => true ], - [ '1234test', 0, '1234', 4, fn ( string $s ) => \ctype_digit( $s ) ], - [ 'test1234', 0, 'test', 4, fn ( string $s ) => \ctype_alpha( $s ) ], - [ 'foo/bar', 0, 'foo', 3, fn ( string $s ) => $s !== '/' ], - [ 'foo/bar;', 0, 'foo/bar', 7, fn ( string $s ) => $s !== ';' ], + [ '', 0, '', 0, static fn () => true ], + [ '1234test', 0, '1234', 4, static fn ( string $s ) => \ctype_digit( $s ) ], + [ 'test1234', 0, 'test', 4, static fn ( string $s ) => \ctype_alpha( $s ) ], + [ 'foo/bar', 0, 'foo', 3, static fn ( string $s ) => $s !== '/' ], + [ 'foo/bar;', 0, 'foo/bar', 7, static fn ( string $s ) => $s !== ';' ], ]; }