From 9b64b9afadff1d020847ed67179f746949a03c07 Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 7 Jul 2025 11:25:44 +0200 Subject: [PATCH 1/6] Update student docs for PHP 8.4 / PHPUnit 11 --- README.md | 2 +- docs/INSTALLATION.md | 40 +++++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3732cea6..de33c63c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The following system dependencies are required: - `composer`, as recommended in the [PHP track installation docs][exercism-track-installation-composer]. - [`bash` shell][gnu-bash]. -- PHP V8.3+ CLI. +- PHP V8.4+ CLI. - An active Internet connection for installing required tools / composer packages. Run the following command to get started with this project: diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 309eb1b5..398ff218 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -3,7 +3,7 @@ ## Which version to chose? We encourage to use a stable PHP release with active support. -Currently this is **PHP 8.1, 8.2 and 8.3**. +Currently this is **PHP 8.2, 8.3 and 8.4**. Details on current releases and their timelines can be found in [the official PHP documentation](https://www.php.net/supported-versions.php). ## Install PHP @@ -38,9 +38,9 @@ For further instructions, read the PHP manual on [Installation on Unix systems]( While PHP is often bundled with macOS, it is often outdated. We recommended installing PHP through [Homebrew](https://brew.sh/). -You can install Homebrew following the instructions [here](https://brew.sh/#install). +You can install Homebrew following the instructions [on their homepage](https://brew.sh/#install). -To confirm its installation try the following command, it should output Homebrew `4.2.x` at the time of this writing. +To confirm its installation try the following command, it should output Homebrew `4.5.x` at the time of this writing. ```shell brew --version @@ -49,10 +49,10 @@ brew --version Install PHP via homebrew ```shell -brew install php@8.3 +brew install php@8.4 ``` -This should display the now installed version of PHP, at least version `8.1.0`. +This should display the now installed version of PHP, at least version `8.2.0`. ```shell php -v @@ -77,12 +77,12 @@ You will also need [Docker](https://docs.docker.com/engine/install/). If you want to use a different OS, see instruction on [php.net/manual/en/install](https://www.php.net/manual/en/install.php). -## Install Composer - -Install [Composer](https://getcomposer.org) following your devices OS [installation instructions](https://getcomposer.org/doc/00-intro.md). We recommend installing it globally for ease of use. - ## Install PHPUnit +~~~~exercism/note +PHPUnit 12 is not supported, yet! +~~~~ + ### Via PHP Archive (PHAR) The easiest way to use PHPUnit for Exercism exercises is downloading a distribution that is packaged as a PHP Archive (PHAR), which is also the recommended way to use PHPUnit. @@ -91,7 +91,7 @@ Store the PHAR where you stored the `exercism` CLI to run PHPUnit from wherever You can download a release of PHPUnit packages as a PHP archive: ```shell -wget -O phpunit.phar https://phar.phpunit.de/phpunit-10.phar +wget -O phpunit.phar https://phar.phpunit.de/phpunit-11.phar ``` Then make the downloaded file executable: @@ -114,20 +114,26 @@ phpunit --version The output should look like this: +```text +PHPUnit 11.5.45 by Sebastian Bergmann and contributors. ``` -PHPUnit 10.5.45 by Sebastian Bergmann and contributors. -``` +You can also follow the official [Installing PHPUnit instructions](https://docs.phpunit.de/en/11.5/installation.html#installing-phpunit) to install PHPUnit. +### Via Composer -You can also follow the official [Installing PHPUnit instructions](https://docs.phpunit.de/en/10.5/installation.html#installing-phpunit) to install PHPUnit. +PHPUnit version 11 can also be installed via [Composer](https://getcomposer.org). -### Via Composer +#### Install Composer + +Install [Composer](https://getcomposer.org) following your devices OS [installation instructions](https://getcomposer.org/doc/00-intro.md). We recommend installing it globally for ease of use. + +#### Add PHPUnit as global tool -PHPUnit version 10 can also be installed globally via [Composer](https://getcomposer.org), using the following command: +Using the following command: ```shell -composer global require phpunit/phpunit ^10.5 +composer global require phpunit/phpunit ^11.5 ``` -Please make sure you install version 10.5 or later. \ No newline at end of file +Please make sure you install version 11.5 or later. From 68b5e82dbf34ae6122b1fab858ddcea9ebf279c8 Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 7 Jul 2025 11:26:15 +0200 Subject: [PATCH 2/6] Fix markdown syntax --- exercises/shared/.docs/help.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/shared/.docs/help.md b/exercises/shared/.docs/help.md index 519bddb9..dcbcc99b 100644 --- a/exercises/shared/.docs/help.md +++ b/exercises/shared/.docs/help.md @@ -1,6 +1,6 @@ # Help - To get help if you're having trouble, you can use one of the following resources: +To get help if you're having trouble, you can use one of the following resources: - - [/r/php](https://www.reddit.com/r/php) is the PHP subreddit. - - [StackOverflow](https://stackoverflow.com/questions/tagged/php) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. +- [/r/php](https://www.reddit.com/r/php) is the PHP subreddit. +- [StackOverflow](https://stackoverflow.com/questions/tagged/php) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. From 6db678623e0a64029429999c2eb517532b0846c9 Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 7 Jul 2025 11:26:56 +0200 Subject: [PATCH 3/6] Improve markdown, sync / link to website docs --- exercises/shared/.docs/tests.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/exercises/shared/.docs/tests.md b/exercises/shared/.docs/tests.md index 8527d5e8..25a34b5a 100644 --- a/exercises/shared/.docs/tests.md +++ b/exercises/shared/.docs/tests.md @@ -3,20 +3,21 @@ 1. Go to the root of your PHP exercise directory, which is `/php`. To find the Exercism workspace run - exercism debug | grep Workspace + ```shell + exercism workspace + ``` -2. Get [PHPUnit] if you don't have it already. +2. Install [PHPUnit] if you don't have it already. +3. Execute the tests with: - wget -O phpunit https://phar.phpunit.de/phpunit-10.phar - chmod +x phpunit - ./phpunit --version - -3. Execute the tests: - - ./phpunit test_file.php + ```shell + phpunit test_file.php + ``` For example, to run the tests for the Hello World exercise, you would run: - ./phpunit HelloWorldTest.php + ```shell + phpunit HelloWorldTest.php + ``` -[PHPUnit]: https://phpunit.de +[PHPUnit]: https://exercism.org/docs/tracks/php/installation#h-via-php-archive-phar From 2a123d0192275d3840108378424c9998df629aa4 Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 7 Jul 2025 11:41:22 +0200 Subject: [PATCH 4/6] Undo workaround for PHPUnit 10.5 timeouts --- .../practice/robot-name/RobotNameTest.php | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/exercises/practice/robot-name/RobotNameTest.php b/exercises/practice/robot-name/RobotNameTest.php index c30071b9..c38e6e33 100644 --- a/exercises/practice/robot-name/RobotNameTest.php +++ b/exercises/practice/robot-name/RobotNameTest.php @@ -73,34 +73,18 @@ public function testResetName(): void $this->assertMatchesRegularExpression('/\w{2}\d{3}/', $name2); } - /** - * PHPUnit ^10.5 has an issue with - * $this->assertArrayNotHasKey($name, $names, sprintf... - * that leads to test timeouts. This is fixed in PHPUnit ^11. - * Revert workaround - * $this->assertFalse(isset($names[$name]), sprintf... - * when upgrading. - */ - public function testNameArentRecycled(): void + public function testNamesArentRecycled(): void { $names = []; for ($i = 0; $i < 10000; $i++) { $name = $this->robot->getName(); - $this->assertFalse(isset($names[$name]), sprintf('Name %s reissued after Reset.', $name)); + $this->assertArrayNotHasKey($name, $names, sprintf('Name %s reissued after Reset.', $name)); $names[$name] = true; $this->robot->reset(); } } - /** - * PHPUnit ^10.5 has an issue with - * $this->assertArrayNotHasKey($name, $names, sprintf... - * that leads to test timeouts. This is fixed in PHPUnit ^11. - * Revert workaround - * $this->assertFalse(isset($names[$name]), sprintf... - * when upgrading. - */ // This test is optional. public function testNameUniquenessManyRobots(): void { @@ -108,7 +92,7 @@ public function testNameUniquenessManyRobots(): void for ($i = 0; $i < 10000; $i++) { $name = (new Robot())->getName(); - $this->assertFalse(isset($names[$name]), sprintf('Name %s reissued after %d robots', $name, $i)); + $this->assertArrayNotHasKey($name, $names, sprintf('Name %s reissued after %d robots', $name, $i)); $names[$name] = true; } } From 457f910e6256cee8a4d6e357582a1b39753687b1 Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 7 Jul 2025 11:50:35 +0200 Subject: [PATCH 5/6] Fix Dependabot syntax --- .github/dependabot.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b06751ab..5799dc4d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,8 @@ updates: interval: 'monthly' groups: github-actions: - patterns: '*' + patterns: + - '*' # Keep dependencies for Composer up-to-date - package-ecosystem: 'composer' @@ -18,4 +19,5 @@ updates: interval: 'monthly' groups: composer: - patterns: '*' + patterns: + - '*' From 02097e4b3f982d341916e58c93c2f8bb840aa772 Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 7 Jul 2025 11:51:37 +0200 Subject: [PATCH 6/6] Upgrade CI to PHP 8.2 - 8.4 / PHPUnit 11.5 --- .../workflows/exercise-lint-phpcs-psr-12.yml | 2 +- .../workflows/exercise-tests-phpunit-10.yml | 45 ------------------- .../workflows/exercise-tests-phpunit-11.yml | 7 +-- 3 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/exercise-tests-phpunit-10.yml diff --git a/.github/workflows/exercise-lint-phpcs-psr-12.yml b/.github/workflows/exercise-lint-phpcs-psr-12.yml index 7cb59ba8..feca0b9e 100644 --- a/.github/workflows/exercise-lint-phpcs-psr-12.yml +++ b/.github/workflows/exercise-lint-phpcs-psr-12.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: [8.2] + php-version: [8.4] os: [ubuntu-24.04] steps: diff --git a/.github/workflows/exercise-tests-phpunit-10.yml b/.github/workflows/exercise-tests-phpunit-10.yml deleted file mode 100644 index 57e12775..00000000 --- a/.github/workflows/exercise-tests-phpunit-10.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Exercise tests with PHPUnit 10 - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - -jobs: - test: - name: PHP ${{ matrix.php-version }} - ${{ matrix.os }} - ${{ github.event_name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - php-version: [8.1, 8.2, 8.3] - os: [ubuntu-24.04, windows-2022, macOS-14] - - steps: - - name: Set git line endings - if: ${{ matrix.os == 'windows-2022' }} - run: | - git config --system core.autocrlf false - git config --system core.eol lf - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - - uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e - with: - php-version: ${{ matrix.php-version }} - extensions: gmp - - - name: Install dependencies - shell: bash - run: | - curl -Lo ./bin/phpunit-10.phar https://phar.phpunit.de/phpunit-10.phar - chmod +x bin/phpunit-10.phar - - - name: Test exercises - shell: bash - env: - PHPUNIT_BIN: 'bin/phpunit-10.phar' - XDEBUG_MODE: off - run: bin/test.sh diff --git a/.github/workflows/exercise-tests-phpunit-11.yml b/.github/workflows/exercise-tests-phpunit-11.yml index 11e3e811..0b2d10f9 100644 --- a/.github/workflows/exercise-tests-phpunit-11.yml +++ b/.github/workflows/exercise-tests-phpunit-11.yml @@ -14,10 +14,8 @@ jobs: strategy: fail-fast: false matrix: - # php-version: [8.2, 8.3, 8.4] - # os: [ubuntu-24.04, windows-2022, macOS-14] - php-version: [8.4] - os: [ubuntu-24.04] + php-version: [8.2, 8.3, 8.4] + os: [ubuntu-24.04, windows-2022, macOS-14] steps: - name: Set git line endings @@ -40,7 +38,6 @@ jobs: chmod +x bin/phpunit-11.phar - name: Test exercises - continue-on-error: true shell: bash env: PHPUNIT_BIN: 'bin/phpunit-11.phar'