From d685168a853c91beef856c6409efef77f7ba099b Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi <nanasess@fsm.ne.jp> Date: Tue, 22 Oct 2024 01:00:11 +0900 Subject: [PATCH 1/2] Use symfony/polyfill-php80 --- composer.json | 3 +- composer.lock | 162 +++++++++++++++++++------------------- data/class/SC_Initial.php | 43 ---------- phpstan.neon.dist | 3 - 4 files changed, 83 insertions(+), 128 deletions(-) diff --git a/composer.json b/composer.json index c0a3dd831b..e8b3e5c985 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,8 @@ "pear/xml_util": "*", "setasign/fpdf": "^1.8", "setasign/fpdi": "^2.6", - "smarty/smarty": "^5.0.2" + "smarty/smarty": "^5.0.2", + "symfony/polyfill-php80": "^1.31" }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index 077480dc11..06ee99de98 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": "83bfd4524f7afe4c75e48dbbcba0e5ca", + "content-hash": "705018bebe0847e07567c8ecc8b681f3", "packages": [ { "name": "mobiledetect/mobiledetectlib", @@ -899,6 +899,86 @@ } ], "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" } ], "packages-dev": [ @@ -4632,86 +4712,6 @@ ], "time": "2024-09-09T11:45:10+00:00" }, - { - "name": "symfony/polyfill-php80", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, { "name": "symfony/polyfill-php81", "version": "v1.31.0", diff --git a/data/class/SC_Initial.php b/data/class/SC_Initial.php index bc50ded1fc..95ca067ace 100644 --- a/data/class/SC_Initial.php +++ b/data/class/SC_Initial.php @@ -57,7 +57,6 @@ public function init() $this->resetSuperglobalsRequest(); // stripslashesDeepGpc メソッドより後で実行 $this->setTimezone(); // 本当はエラーハンドラーより先に読みたい気も $this->normalizeHostname(); // defineConstants メソッドより後で実行 - $this->compatPhp(); } /** @@ -549,46 +548,4 @@ public function normalizeHostname() SC_Response_Ex::sendRedirect($correct_url); } } - - /** - * PHPバージョン互換処理 - * - * @deprecated https://github.com/EC-CUBE/ec-cube2/issues/681 が実現したら、外部ライブラリへ移行して、削除する予定。 - * - * @return void - */ - public function compatPhp() - { - if (!function_exists('str_starts_with')) { - /** - * 文字列が指定された部分文字列で始まるかを調べる。(for PHP < 8) - * - * @param string $haystack - * @param string $needle - * - * @return bool - */ - function str_starts_with($haystack, $needle) - { - return strncmp($haystack, $needle, strlen($needle)) === 0; - } - } - - if (!function_exists('str_ends_with')) { - /** - * 文字列が、指定された文字列で終わるかを調べる。(for PHP < 8) - * - * @param string $haystack - * @param string $needle - * - * @return bool - */ - function str_ends_with($haystack, $needle) - { - $needle_len = strlen($needle); - - return substr($haystack, -$needle_len, $needle_len) === $needle; - } - } - } } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index d23977b88b..17e858b0e6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -38,6 +38,3 @@ parameters: - message: "#^Variable \\$SJIS_widths might not be defined\\.$#" path: data/class/helper/SC_Helper_FPDI.php - - - message: "#^Inner named functions are not supported by PHPStan\\.#" - path: data/class/SC_Initial.php From 3f3081957ff2babfde363d097e8b60e478b87422 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi <nanasess@fsm.ne.jp> Date: Wed, 18 Dec 2024 14:21:48 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AB=E3=81=AA?= =?UTF-8?q?=E3=81=A3=E3=81=9F=20PHPStan=20=E3=81=AE=20ignoreErrors=20?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpstan.neon.dist | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 2e1b6745f2..fedf1b2161 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -38,9 +38,6 @@ parameters: - message: "#^Variable \\$SJIS_widths might not be defined\\.$#" path: data/class/helper/SC_Helper_FPDI.php - - - message: "#^Inner named functions are not supported by PHPStan\\.#" - path: data/class/SC_Initial.php - message: '#^Path in include_once\(\) "Auth/SASL.php" is not a file or it does not exist.#' path: data/module/Net/SMTP.php