From 99ada0cd457b20fcadefef7a9c8f465a638dcb53 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 20 Apr 2023 15:57:48 +0200 Subject: [PATCH 1/3] sec(deps): Update guzzlehttp/psr7 Signed-off-by: Joas Schilling --- composer.lock | 15 ++++++--------- composer/installed.json | 19 ++++++++----------- composer/installed.php | 12 ++++++------ guzzlehttp/psr7/src/LazyOpenStream.php | 10 +++++++++- guzzlehttp/psr7/src/Message.php | 2 +- guzzlehttp/psr7/src/MessageTrait.php | 13 ++++++------- guzzlehttp/psr7/src/ServerRequest.php | 8 ++++---- 7 files changed, 40 insertions(+), 39 deletions(-) diff --git a/composer.lock b/composer.lock index e964d12f9..5d536f1aa 100644 --- a/composer.lock +++ b/composer.lock @@ -1504,16 +1504,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.4.3", + "version": "2.4.5", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "67c26b443f348a51926030c83481b85718457d3d" + "reference": "0454e12ef0cd597ccd2adb036f7bda4e7fface66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d", - "reference": "67c26b443f348a51926030c83481b85718457d3d", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/0454e12ef0cd597ccd2adb036f7bda4e7fface66", + "reference": "0454e12ef0cd597ccd2adb036f7bda4e7fface66", "shasum": "" }, "require": { @@ -1539,9 +1539,6 @@ "bamarni-bin": { "bin-links": true, "forward-command": false - }, - "branch-alias": { - "dev-master": "2.4-dev" } }, "autoload": { @@ -1603,7 +1600,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.4.3" + "source": "https://github.com/guzzle/psr7/tree/2.4.5" }, "funding": [ { @@ -1619,7 +1616,7 @@ "type": "tidelift" } ], - "time": "2022-10-26T14:07:24+00:00" + "time": "2023-04-17T16:00:45+00:00" }, { "name": "guzzlehttp/uri-template", diff --git a/composer/installed.json b/composer/installed.json index ab513f315..ddd5569f4 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1564,17 +1564,17 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.4.3", - "version_normalized": "2.4.3.0", + "version": "2.4.5", + "version_normalized": "2.4.5.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "67c26b443f348a51926030c83481b85718457d3d" + "reference": "0454e12ef0cd597ccd2adb036f7bda4e7fface66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d", - "reference": "67c26b443f348a51926030c83481b85718457d3d", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/0454e12ef0cd597ccd2adb036f7bda4e7fface66", + "reference": "0454e12ef0cd597ccd2adb036f7bda4e7fface66", "shasum": "" }, "require": { @@ -1595,15 +1595,12 @@ "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, - "time": "2022-10-26T14:07:24+00:00", + "time": "2023-04-17T16:00:45+00:00", "type": "library", "extra": { "bamarni-bin": { "bin-links": true, "forward-command": false - }, - "branch-alias": { - "dev-master": "2.4-dev" } }, "installation-source": "dist", @@ -1666,7 +1663,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.4.3" + "source": "https://github.com/guzzle/psr7/tree/2.4.5" }, "funding": [ { @@ -7045,6 +7042,6 @@ "install-path": "../web-auth/webauthn-lib" } ], - "dev": false, + "dev": true, "dev-package-names": [] } diff --git a/composer/installed.php b/composer/installed.php index dd00d7e91..91adedec2 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -3,11 +3,11 @@ 'name' => 'nextcloud/3rdparty', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '7290f9d6d76016c7a6c06f0e58a780101df3fc41', + 'reference' => '0ec73636ee36558960a1df60828b645ef3d4a53c', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), - 'dev' => false, + 'dev' => true, ), 'versions' => array( 'aws/aws-crt-php' => array( @@ -209,9 +209,9 @@ 'dev_requirement' => false, ), 'guzzlehttp/psr7' => array( - 'pretty_version' => '2.4.3', - 'version' => '2.4.3.0', - 'reference' => '67c26b443f348a51926030c83481b85718457d3d', + 'pretty_version' => '2.4.5', + 'version' => '2.4.5.0', + 'reference' => '0454e12ef0cd597ccd2adb036f7bda4e7fface66', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), @@ -328,7 +328,7 @@ 'nextcloud/3rdparty' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '7290f9d6d76016c7a6c06f0e58a780101df3fc41', + 'reference' => '0ec73636ee36558960a1df60828b645ef3d4a53c', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), diff --git a/guzzlehttp/psr7/src/LazyOpenStream.php b/guzzlehttp/psr7/src/LazyOpenStream.php index 5618331f1..f6c84904e 100644 --- a/guzzlehttp/psr7/src/LazyOpenStream.php +++ b/guzzlehttp/psr7/src/LazyOpenStream.php @@ -10,7 +10,6 @@ * Lazily reads or writes to a file that is opened only after an IO operation * take place on the stream. */ -#[\AllowDynamicProperties] final class LazyOpenStream implements StreamInterface { use StreamDecoratorTrait; @@ -21,6 +20,11 @@ final class LazyOpenStream implements StreamInterface /** @var string */ private $mode; + /** + * @var StreamInterface + */ + private $stream; + /** * @param string $filename File to lazily open * @param string $mode fopen mode to use when opening the stream @@ -29,6 +33,10 @@ public function __construct(string $filename, string $mode) { $this->filename = $filename; $this->mode = $mode; + + // unsetting the property forces the first access to go through + // __get(). + unset($this->stream); } /** diff --git a/guzzlehttp/psr7/src/Message.php b/guzzlehttp/psr7/src/Message.php index 61c1a5dcc..c1e15f826 100644 --- a/guzzlehttp/psr7/src/Message.php +++ b/guzzlehttp/psr7/src/Message.php @@ -77,7 +77,7 @@ public static function bodySummary(MessageInterface $message, int $truncateAt = // Matches any printable character, including unicode characters: // letters, marks, numbers, punctuation, spacing, and separators. - if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary)) { + if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary) !== 0) { return null; } diff --git a/guzzlehttp/psr7/src/MessageTrait.php b/guzzlehttp/psr7/src/MessageTrait.php index d2dc28b60..464bdfaa4 100644 --- a/guzzlehttp/psr7/src/MessageTrait.php +++ b/guzzlehttp/psr7/src/MessageTrait.php @@ -224,12 +224,9 @@ private function assertHeader($header): void )); } - if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/', $header)) { + if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) { throw new \InvalidArgumentException( - sprintf( - '"%s" is not valid header name', - $header - ) + sprintf('"%s" is not valid header name.', $header) ); } } @@ -257,8 +254,10 @@ private function assertValue(string $value): void // Clients must not send a request with line folding and a server sending folded headers is // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting // folding is not likely to break any legitimate use case. - if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/', $value)) { - throw new \InvalidArgumentException(sprintf('"%s" is not valid header value', $value)); + if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) { + throw new \InvalidArgumentException( + sprintf('"%s" is not valid header value.', $value) + ); } } } diff --git a/guzzlehttp/psr7/src/ServerRequest.php b/guzzlehttp/psr7/src/ServerRequest.php index 43cbb502e..b2aa382da 100644 --- a/guzzlehttp/psr7/src/ServerRequest.php +++ b/guzzlehttp/psr7/src/ServerRequest.php @@ -144,10 +144,10 @@ private static function normalizeNestedFileSpec(array $files = []): array foreach (array_keys($files['tmp_name']) as $key) { $spec = [ 'tmp_name' => $files['tmp_name'][$key], - 'size' => $files['size'][$key], - 'error' => $files['error'][$key], - 'name' => $files['name'][$key], - 'type' => $files['type'][$key], + 'size' => $files['size'][$key] ?? null, + 'error' => $files['error'][$key] ?? null, + 'name' => $files['name'][$key] ?? null, + 'type' => $files['type'][$key] ?? null, ]; $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec); } From 9d7ff42f0d4cf50608d7f9ad7770c76f06a7d87b Mon Sep 17 00:00:00 2001 From: nextcloud-command Date: Fri, 21 Apr 2023 07:25:08 +0000 Subject: [PATCH 2/3] chore(autoloader): Dump autoloader Signed-off-by: nextcloud-command --- composer/ClassLoader.php | 12 ++++++++---- composer/InstalledVersions.php | 17 ++++++++++++----- composer/autoload_real.php | 6 +++--- composer/installed.json | 2 +- composer/installed.php | 6 +++--- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/composer/ClassLoader.php b/composer/ClassLoader.php index fd56bd7d8..a72151c77 100644 --- a/composer/ClassLoader.php +++ b/composer/ClassLoader.php @@ -429,7 +429,8 @@ public function unregister() public function loadClass($class) { if ($file = $this->findFile($class)) { - (self::$includeFile)($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } @@ -560,7 +561,10 @@ private function findFileWithExtension($class, $ext) return false; } - private static function initializeIncludeClosure(): void + /** + * @return void + */ + private static function initializeIncludeClosure() { if (self::$includeFile !== null) { return; @@ -574,8 +578,8 @@ private static function initializeIncludeClosure(): void * @param string $file * @return void */ - self::$includeFile = static function($file) { + self::$includeFile = \Closure::bind(static function($file) { include $file; - }; + }, null, null); } } diff --git a/composer/InstalledVersions.php b/composer/InstalledVersions.php index c6b54af7b..51e734a77 100644 --- a/composer/InstalledVersions.php +++ b/composer/InstalledVersions.php @@ -98,7 +98,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; } } @@ -119,7 +119,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) */ public static function satisfies(VersionParser $parser, $packageName, $constraint) { - $constraint = $parser->parseConstraints($constraint); + $constraint = $parser->parseConstraints((string) $constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); @@ -328,7 +328,9 @@ private static function getInstalled() if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { self::$installed = $installed[count($installed) - 1]; } @@ -340,12 +342,17 @@ private static function getInstalled() // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; } else { self::$installed = array(); } } - $installed[] = self::$installed; + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } return $installed; } diff --git a/composer/autoload_real.php b/composer/autoload_real.php index ca7d2ad3c..149de3c38 100644 --- a/composer/autoload_real.php +++ b/composer/autoload_real.php @@ -39,15 +39,15 @@ public static function getLoader() $loader->register(true); $filesToLoad = \Composer\Autoload\ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652::$files; - $requireFile = static function ($fileIdentifier, $file) { + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; require $file; } - }; + }, null, null); foreach ($filesToLoad as $fileIdentifier => $file) { - ($requireFile)($fileIdentifier, $file); + $requireFile($fileIdentifier, $file); } return $loader; diff --git a/composer/installed.json b/composer/installed.json index ddd5569f4..c7354f99e 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -7042,6 +7042,6 @@ "install-path": "../web-auth/webauthn-lib" } ], - "dev": true, + "dev": false, "dev-package-names": [] } diff --git a/composer/installed.php b/composer/installed.php index 91adedec2..b79147575 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -3,11 +3,11 @@ 'name' => 'nextcloud/3rdparty', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '0ec73636ee36558960a1df60828b645ef3d4a53c', + 'reference' => '99ada0cd457b20fcadefef7a9c8f465a638dcb53', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), - 'dev' => true, + 'dev' => false, ), 'versions' => array( 'aws/aws-crt-php' => array( @@ -328,7 +328,7 @@ 'nextcloud/3rdparty' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '0ec73636ee36558960a1df60828b645ef3d4a53c', + 'reference' => '99ada0cd457b20fcadefef7a9c8f465a638dcb53', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), From 6573b6827be9d9a3eb4a3f753b694ded3c928ac3 Mon Sep 17 00:00:00 2001 From: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Date: Fri, 21 Apr 2023 09:34:26 +0200 Subject: [PATCH 3/3] feat(CI): Add lint PHP action Signed-off-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com> --- .github/workflows/lint-php.yml | 60 ++++++++++++++++++++++++++++++++++ composer.json | 3 ++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/lint-php.yml diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml new file mode 100644 index 000000000..3bcfaaa8a --- /dev/null +++ b/.github/workflows/lint-php.yml @@ -0,0 +1,60 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint php + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +concurrency: + group: lint-php-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + php-lint: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: [ "8.0", "8.1", "8.2" ] + + name: php-lint + + steps: + - name: Checkout + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Lint + run: composer run lint + + summary: + permissions: + contents: none + runs-on: ubuntu-latest + needs: php-lint + + if: always() + + name: php-lint-summary + + steps: + - name: Summary status + run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi diff --git a/composer.json b/composer.json index 8a14d570b..407e42b78 100644 --- a/composer.json +++ b/composer.json @@ -62,6 +62,9 @@ "symfony/translation": "^4.4.41", "web-auth/webauthn-lib": "^3.1" }, + "scripts": { + "lint": "find . -name \\*.php -print0 | xargs -0 -n1 php -l" + }, "extra": { "patches-file": "composer.patches.json" }