Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

WIP: PHP8.2対応の影響検証 #6

Closed
wants to merge 4 commits into from
Closed

Conversation

yosuke-dev
Copy link

@yosuke-dev yosuke-dev commented Jan 11, 2024

概要

  • PHPUnitは8.x系でもPHP8.2をサポートしていましたが、より精度を高めるために最新化して検証しました。
  • そのため、PHP7.x系のテストは実行していません。
    • ※PHPUnit 10.xではPHP8.1以上のサポートになったため。

WIPの理由

当PRは検証用のため、マージせずレビュー完了次第クローズするため。

検証内容

circleCIのCUIをローカルで動かし実行し、影響範囲を確認。
CircleCIの設定は未設定のため、 クラウド上でのCI実行は確認していない のでご注意ください。

実行コマンド

circleci local execute php82_test 

実行結果

  1. PHPUnitの設定で警告 4件
  2. PHPUnitのテストケース非推奨 15件
  3. PHPの非推奨 5件

1. PHPUnitの設定で警告 4件

当リポジトリ(パッケージ)を残す場合は対応の検討が必要

メッセージ
  - Element 'phpunit', attribute 'backupStaticAttributes': The attribute 'backupStaticAttributes' is not allowed.
  - Element 'phpunit', attribute 'convertErrorsToExceptions': The attribute 'convertErrorsToExceptions' is not allowed.
  - Element 'phpunit', attribute 'convertNoticesToExceptions': The attribute 'convertNoticesToExceptions' is not allowed.
  - Element 'phpunit', attribute 'convertWarningsToExceptions': The attribute 'convertWarningsToExceptions' is not allowed.
詳細
  • 以下の4属性は使えなくなりました
    • backupStaticAttributes
    • convertErrorsToExceptions
      • PHPUnit変更ログ
      • (概要)PHPUnit10で削除されました。Errorは常に異常としてマークされる必要があるからです。
    • convertNoticesToExceptions
      • PHPUnit変更ログ
      • (概要)PHPUnit10で削除されました。markNoticesAsRisky に切り替える必要があります。
        • ※ただしデフォルト値を使ってるので削除が良さそう。
        • ※さらに最新では削除されているよう(変更ログに記載なし、ドキュメントの記載から削除された)
    • convertWarningsToExceptions
      • PHPUnit変更ログ
      • (概要)PHPUnit10で削除されました。markWarningsAsRisky に切り替える必要があります。
        • ※ただしデフォルト値を使ってるので削除が良さそう。
        • ※さらに最新では削除されているよう(変更ログに記載なし、ドキュメントの記載から削除された)

2. PHPUnitのテストケース非推奨 15件

対応が必要
※ただし非推奨のみであるため、現状はテストを通過している。

メッセージ

長いので同じ内容のため、1件を抜粋し残りは割愛

1) Whiteplus_CsvFileTest::testRead
Data Provider method Whiteplus_CsvFileTest::validCsvFiles() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:44
詳細
  • Data Provider method myClass::myMethod() is not static
    • PHPUnit変更ログ
    • データプロバイダーの非staticは非推奨となりました。
    • static化する必要があります。

3. PHPの非推奨 5件

対応が必要
※ただし非推奨のみであるため、現状はテストを通過している。

メッセージ

長いので同じ内容のため、1件を抜粋し残りは割愛

1) /home/circleci/project/src/Whiteplus/Csv/Csv.php:319
Return type of Whiteplus\Csv\Csv::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Triggered by:

* Whiteplus_CsvFileTest::testExistingFileShouldBeCreated
  /home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:21
詳細

全ての結果

全ての実行結果を開く
$ circleci local execute php82_test 

Fetching latest build environment...
Docker image digest: sha256:008ba7f4223f1e26c11df9575283491b620074fa96da6961e0dcde47fb757014
====>> Spin up environment
Build-agent version  ()
System information:
 Server Version: 24.0.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Kernel Version: 6.5.11-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64

Starting container cimg/php:8.2
Warning: No authentication provided, using CircleCI credentials for pulls from Docker Hub.
  image is cached as cimg/php:8.2, but refreshing...
cimg/php:8.2:
  using image cimg/php@sha256:9d240dce6f94855c3eddb3fb6d8cdfa12b6f93500554c4e4eeef71f48f8c0415
  pull stats: Image was already available so the image was not pulled
  time to create container: 22ms
Creating Docker containers in parallel
8.2: Pulling from cimg/php
Digest: sha256:9d240dce6f94855c3eddb3fb6d8cdfa12b6f93500554c4e4eeef71f48f8c0415
Status: Image is up to date for cimg/php:8.2
Time to upload agent and config: 1.19790213s
Time to start containers: 196.554856ms
====>> Preparing environment variables
Using build environment variables:
  BASH_ENV=/tmp/.bash_env-localbuild-1704938402
  CI=true
  CIRCLECI=true
  CIRCLE_BRANCH=
  CIRCLE_BUILD_NUM=
  CIRCLE_JOB=php82_test
  CIRCLE_NODE_INDEX=0
  CIRCLE_NODE_TOTAL=1
  CIRCLE_REPOSITORY_URL=
  CIRCLE_SHA1=
  CIRCLE_SHELL_ENV=/tmp/.bash_env-localbuild-1704938402
  CIRCLE_WORKING_DIRECTORY=~/project


The redacted variables listed above will be masked in run step output.====>> Checkout code
Making checkout directory "/home/circleci/project"
Copying files from "/tmp/_circleci_local_build_repo" to "/home/circleci/project"
====>> Install dependencies
  #!/bin/bash -eo pipefail
composer install
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Lock file operations: 26 installs, 0 updates, 0 removals
  - Locking myclabs/deep-copy (1.11.1)
  - Locking nikic/php-parser (v5.0.0)
  - Locking phar-io/manifest (2.0.3)
  - Locking phar-io/version (3.2.1)
  - Locking phpunit/php-code-coverage (10.1.11)
  - Locking phpunit/php-file-iterator (4.1.0)
  - Locking phpunit/php-invoker (4.0.0)
  - Locking phpunit/php-text-template (3.0.1)
  - Locking phpunit/php-timer (6.0.0)
  - Locking phpunit/phpunit (10.5.5)
  - Locking sebastian/cli-parser (2.0.0)
  - Locking sebastian/code-unit (2.0.0)
  - Locking sebastian/code-unit-reverse-lookup (3.0.0)
  - Locking sebastian/comparator (5.0.1)
  - Locking sebastian/complexity (3.2.0)
  - Locking sebastian/diff (5.1.0)
  - Locking sebastian/environment (6.0.1)
  - Locking sebastian/exporter (5.1.1)
  - Locking sebastian/global-state (6.0.1)
  - Locking sebastian/lines-of-code (2.0.2)
  - Locking sebastian/object-enumerator (5.0.0)
  - Locking sebastian/object-reflector (3.0.0)
  - Locking sebastian/recursion-context (5.0.0)
  - Locking sebastian/type (4.0.0)
  - Locking sebastian/version (4.0.1)
  - Locking theseer/tokenizer (1.2.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 26 installs, 0 updates, 0 removals
  - Downloading sebastian/version (4.0.1)
  - Downloading sebastian/type (4.0.0)
  - Downloading sebastian/recursion-context (5.0.0)
  - Downloading sebastian/object-reflector (3.0.0)
  - Downloading sebastian/object-enumerator (5.0.0)
  - Downloading sebastian/global-state (6.0.1)
  - Downloading sebastian/exporter (5.1.1)
  - Downloading sebastian/environment (6.0.1)
  - Downloading sebastian/diff (5.1.0)
  - Downloading sebastian/comparator (5.0.1)
  - Downloading sebastian/code-unit (2.0.0)
  - Downloading sebastian/cli-parser (2.0.0)
  - Downloading phpunit/php-timer (6.0.0)
  - Downloading phpunit/php-text-template (3.0.1)
  - Downloading phpunit/php-invoker (4.0.0)
  - Downloading phpunit/php-file-iterator (4.1.0)
  - Downloading theseer/tokenizer (1.2.2)
  - Downloading nikic/php-parser (v5.0.0)
  - Downloading sebastian/lines-of-code (2.0.2)
  - Downloading sebastian/complexity (3.2.0)
  - Downloading sebastian/code-unit-reverse-lookup (3.0.0)
  - Downloading phpunit/php-code-coverage (10.1.11)
  - Downloading phar-io/version (3.2.1)
  - Downloading phar-io/manifest (2.0.3)
  - Downloading myclabs/deep-copy (1.11.1)
  - Downloading phpunit/phpunit (10.5.5)
  - Installing sebastian/version (4.0.1): Extracting archive
  - Installing sebastian/type (4.0.0): Extracting archive
  - Installing sebastian/recursion-context (5.0.0): Extracting archive
  - Installing sebastian/object-reflector (3.0.0): Extracting archive
  - Installing sebastian/object-enumerator (5.0.0): Extracting archive
  - Installing sebastian/global-state (6.0.1): Extracting archive
  - Installing sebastian/exporter (5.1.1): Extracting archive
  - Installing sebastian/environment (6.0.1): Extracting archive
  - Installing sebastian/diff (5.1.0): Extracting archive
  - Installing sebastian/comparator (5.0.1): Extracting archive
  - Installing sebastian/code-unit (2.0.0): Extracting archive
  - Installing sebastian/cli-parser (2.0.0): Extracting archive
  - Installing phpunit/php-timer (6.0.0): Extracting archive
  - Installing phpunit/php-text-template (3.0.1): Extracting archive
  - Installing phpunit/php-invoker (4.0.0): Extracting archive
  - Installing phpunit/php-file-iterator (4.1.0): Extracting archive
  - Installing theseer/tokenizer (1.2.2): Extracting archive
  - Installing nikic/php-parser (v5.0.0): Extracting archive
  - Installing sebastian/lines-of-code (2.0.2): Extracting archive
  - Installing sebastian/complexity (3.2.0): Extracting archive
  - Installing sebastian/code-unit-reverse-lookup (3.0.0): Extracting archive
  - Installing phpunit/php-code-coverage (10.1.11): Extracting archive
  - Installing phar-io/version (3.2.1): Extracting archive
  - Installing phar-io/manifest (2.0.3): Extracting archive
  - Installing myclabs/deep-copy (1.11.1): Extracting archive
  - Installing phpunit/phpunit (10.5.5): Extracting archive
2 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
23 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
====>> Test
  #!/bin/bash -eo pipefail
vendor/bin/phpunit
PHPUnit 10.5.5 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.14
Configuration: /home/circleci/project/phpunit.xml.dist

D....................................................             53 / 53 (100%)

Time: 00:00.037, Memory: 8.00 MB

There was 1 PHPUnit test runner warning:

1) Test results may not be as expected because the XML configuration file did not pass validation:

  Line 14:
  - Element 'phpunit', attribute 'backupStaticAttributes': The attribute 'backupStaticAttributes' is not allowed.
  - Element 'phpunit', attribute 'convertErrorsToExceptions': The attribute 'convertErrorsToExceptions' is not allowed.
  - Element 'phpunit', attribute 'convertNoticesToExceptions': The attribute 'convertNoticesToExceptions' is not allowed.
  - Element 'phpunit', attribute 'convertWarningsToExceptions': The attribute 'convertWarningsToExceptions' is not allowed.


--

15 tests triggered 15 PHPUnit deprecations:

1) Whiteplus_CsvFileTest::testRead
Data Provider method Whiteplus_CsvFileTest::validCsvFiles() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:44

2) Whiteplus_CsvFileTest::testParseJp
Data Provider method Whiteplus_CsvFileTest::validJpCsvTexts() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:115

3) Whiteplus_CsvFileTest::testWriteJp
Data Provider method Whiteplus_CsvFileTest::validJpCsvTexts() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:140

4) Whiteplus_CsvFileTest::testInvalidDelimiterShouldThrowException
Data Provider method Whiteplus_CsvFileTest::invalidDelimiters() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:183

5) Whiteplus_CsvFileTest::testInvalidEnclosureShouldThrowException
Data Provider method Whiteplus_CsvFileTest::invalidEnclosures() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:214

6) Whiteplus_CsvFileTest::testLineEndingsDetection
Data Provider method Whiteplus_CsvFileTest::validLineBreaksData() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:233

7) Whiteplus_CsvFileTest::testInvalidLineBreak
Data Provider method Whiteplus_CsvFileTest::invalidLineBreaksData() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:253

8) Whiteplus_CsvFileTest::testParseUtf16Le
Data Provider method Whiteplus_CsvFileTest::utf16LeCsvFiles() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:354

9) Whiteplus_CsvTextTest::testRead
Data Provider method Whiteplus_CsvTextTest::validCsvTexts() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvTextTest.php:51

10) Whiteplus_CsvTextTest::testParseJp
Data Provider method Whiteplus_CsvTextTest::validJpCsvTexts() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvTextTest.php:122

11) Whiteplus_CsvTextTest::testWriteJp
Data Provider method Whiteplus_CsvTextTest::validJpCsvTexts() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvTextTest.php:147

12) Whiteplus_CsvTextTest::testInvalidDelimiterShouldThrowException
Data Provider method Whiteplus_CsvTextTest::invalidDelimiters() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvTextTest.php:190

13) Whiteplus_CsvTextTest::testInvalidEnclosureShouldThrowException
Data Provider method Whiteplus_CsvTextTest::invalidEnclosures() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvTextTest.php:220

14) Whiteplus_CsvTextTest::testLineEndingsDetection
Data Provider method Whiteplus_CsvTextTest::validLineBreaksData() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvTextTest.php:239

15) Whiteplus_CsvTextTest::testInvalidLineBreak
Data Provider method Whiteplus_CsvTextTest::invalidLineBreaksData() is not static

/home/circleci/project/tests/Whiteplus/Csv/CsvTextTest.php:259

--

1 test triggered 5 PHP deprecations:

1) /home/circleci/project/src/Whiteplus/Csv/Csv.php:319
Return type of Whiteplus\Csv\Csv::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Triggered by:

* Whiteplus_CsvFileTest::testExistingFileShouldBeCreated
  /home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:21

2) /home/circleci/project/src/Whiteplus/Csv/Csv.php:330
Return type of Whiteplus\Csv\Csv::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Triggered by:

* Whiteplus_CsvFileTest::testExistingFileShouldBeCreated
  /home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:21

3) /home/circleci/project/src/Whiteplus/Csv/Csv.php:347
Return type of Whiteplus\Csv\Csv::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Triggered by:

* Whiteplus_CsvFileTest::testExistingFileShouldBeCreated
  /home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:21

4) /home/circleci/project/src/Whiteplus/Csv/Csv.php:359
Return type of Whiteplus\Csv\Csv::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Triggered by:

* Whiteplus_CsvFileTest::testExistingFileShouldBeCreated
  /home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:21

5) /home/circleci/project/src/Whiteplus/Csv/Csv.php:370
Return type of Whiteplus\Csv\Csv::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Triggered by:

* Whiteplus_CsvFileTest::testExistingFileShouldBeCreated
  /home/circleci/project/tests/Whiteplus/Csv/CsvFileTest.php:21

WARNINGS!
Tests: 53, Assertions: 63, Warnings: 1, Deprecations: 20.
Error:
Exited with code exit status 1

Step failed
Error: runner failed (exited with 101)
Task failed
Error: task failed

@yosuke-dev yosuke-dev self-assigned this Jan 11, 2024
@yosuke-dev yosuke-dev marked this pull request as draft January 11, 2024 03:20
@yosuke-dev yosuke-dev closed this Jan 11, 2024
@yosuke-dev yosuke-dev deleted the feature/support_php82 branch January 11, 2024 03:54
@yosuke-dev yosuke-dev restored the feature/support_php82 branch January 11, 2024 03:55
@yosuke-dev yosuke-dev reopened this Jan 11, 2024
@yosuke-dev yosuke-dev marked this pull request as ready for review January 11, 2024 08:30
@yosuke-dev
Copy link
Author

調査および内部レビューが終わったためクローズします。

@yosuke-dev yosuke-dev closed this Jan 16, 2024
@yosuke-dev yosuke-dev deleted the feature/support_php82 branch January 16, 2024 08:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant