Skip to content

Commit

Permalink
[shopsys] Upgraded to PHP 8.3 (#3002)
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmannmartin committed Feb 9, 2024
2 parents 3c36c82 + 41d5fb3 commit 13f4854
Show file tree
Hide file tree
Showing 62 changed files with 119 additions and 130 deletions.
7 changes: 7 additions & 0 deletions UPGRADE-14.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,13 @@ Follow the instructions in relevant sections, e.g. `shopsys/coding-standards` or
- see #project-base-diff to update your project
- fix consumer deployment ([#3019](https://github.com/shopsys/shopsys/pull/3019))
- see #project-base-diff to update your project
- upgrade to PHP 8.3 ([#3002](https://github.com/shopsys/shopsys/pull/3002))
- class `Shopsys\FrameworkBundle\Component\ArrayUtils\RecursiveArraySorter` was removed
- the minimum required version is now PHP 8.3
- check your code for any Incompatibilities with PHP 8.2 and PHP 8.3
- https://www.php.net/manual/en/migration82.php
- https://www.php.net/manual/en/migration83.php
- see #project-base-diff to update your project

### Storefront

Expand Down
7 changes: 6 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@

<target name="frontend-api-generate-apiary-blueprint">
<echo level="info" message="Generating apiary blueprint"/>
<exec command="npx hercule ${path.frontend-api}/apiary/index.md -o ${path.frontend-api}/apiary.apib" passthru="true" checkreturn="true"/>
<exec executable="npx" passthru="true" checkreturn="true">
<arg value="hercule"/>
<arg value="${path.frontend-api}/apiary/index.md"/>
<arg value="-o"/>
<arg value="${path.frontend-api}/apiary.apib"/>
</exec>
<echo message="Apiary blueprint was generated, commit changes when needed"/>
</target>

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
}
},
"require": {
"php": "^8.1",
"php": "^8.3",
"ext-bcmath": "*",
"ext-ctype": "*",
"ext-curl": "*",
Expand Down Expand Up @@ -125,14 +125,14 @@
"overblog/dataloader-bundle": "^0.6.0",
"overblog/graphiql-bundle": "^0.3",
"overblog/graphql-bundle": "^1.0",
"phing/phing": "^2.17.3",
"phing/phing": "3.0.0-rc6",
"phpdocumentor/reflection-docblock": "^5.3.0",
"presta/sitemap-bundle": "^3.3",
"prezent/doctrine-translatable": "^3.3.0",
"prezent/doctrine-translatable-bundle": "^1.4",
"psr/log": "^1.0",
"ramsey/uuid": "^4.3.1",
"roave/better-reflection": "^5.4.0",
"roave/better-reflection": "^6.0",
"scheb/2fa-bundle": "^5.7",
"scheb/2fa-email": "^5.7",
"scheb/2fa-google-authenticator": "^5.7",
Expand Down Expand Up @@ -229,7 +229,7 @@
"component-dir": "project-base/app/web/components",
"sort-packages": true,
"platform": {
"php": "8.1"
"php": "8.3"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
Expand Down
4 changes: 2 additions & 2 deletions docs/docker/docker-troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ Docker images may fail to build during `docker-compose up -d` due to invalid ref

```no-highlight
Building php-fpm
Step 1/41 : FROM php:8.1-fpm-bullseye as base
ERROR: Service 'php-fpm' failed to build: Error parsing reference: "php:8.1-fpm-bullseye as base" is not a valid repository/tag: invalid reference format
Step 1/41 : FROM php:8.3-fpm-bullseye as base
ERROR: Service 'php-fpm' failed to build: Error parsing reference: "php:8.3-fpm-bullseye as base" is not a valid repository/tag: invalid reference format
```

This is because you have a version of Docker that does not support [multi-stage builds](https://docs.docker.com/develop/develop-images/multistage-build/).
Expand Down
4 changes: 2 additions & 2 deletions docs/installation/application-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To be able to install, develop and run Shopsys Platform, the system should have

- [GIT](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [PostgreSQL 12.1](https://wiki.postgresql.org/wiki/Detailed_installation_guides)
- [PHP 8.1 or higher](http://php.net/manual/en/install.php) (configure your `php.ini` by [Required PHP Configuration](../introduction/required-php-configuration.md))
- [PHP 8.3 or higher](http://php.net/manual/en/install.php) (configure your `php.ini` by [Required PHP Configuration](../introduction/required-php-configuration.md))
- [Composer](https://getcomposer.org/doc/00-intro.md#globally)
- [Node.js with npm](https://nodejs.org/en/download/) (npm is automatically installed when you install Node.js)
- [Redis](https://redis.io/topics/quickstart)
Expand All @@ -21,7 +21,7 @@ To be able to install, develop and run Shopsys Platform, the system should have

- [GIT](https://git-scm.com/download/win)
- [PostgreSQL 12.1](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads#windows)
- [PHP 8.1 or higher](http://php.net/manual/en/install.windows.php) (configure your `php.ini` by [Required PHP Configuration](../introduction/required-php-configuration.md))
- [PHP 8.3 or higher](http://php.net/manual/en/install.windows.php) (configure your `php.ini` by [Required PHP Configuration](../introduction/required-php-configuration.md))
- [Composer](https://getcomposer.org/doc/00-intro.md#installation-windows)
- [Node.js with npm](https://nodejs.org/en/download/) (npm is automatically installed when you install Node.js)
- [Redis](https://github.com/MicrosoftArchive/redis/releases)
Expand Down
2 changes: 1 addition & 1 deletion docs/installation/installation-using-docker-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Take a look at the article about [Monorepo](../introduction/monorepo.md) for mor

- [GIT](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [PHP](http://php.net/manual/en/install.unix.php)
- At least version **8.1 or higher**
- At least version **8.3 or higher**
- [Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)
- [Docker](https://docs.docker.com/engine/installation/)
- At least version **17.05 or higher** so it supports [multi-stage builds](https://docs.docker.com/develop/develop-images/multistage-build/).
Expand Down
2 changes: 1 addition & 1 deletion docs/installation/installation-using-docker-macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This solution uses [_Mutagen_](https://mutagen.io) (for relatively fast two-way

- [GIT](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [PHP](http://php.net/manual/en/install.macosx.php)
- At least version **8.1 or higher**
- At least version **8.3 or higher**
- [Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)
- [Docker Desktop](https://docs.docker.com/engine/install/)
- Enable Docker Compose V2 in General settings
Expand Down
6 changes: 3 additions & 3 deletions docs/introduction/faq-and-common-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ _Note: You can also view the outgoing emails in the Symfony profiler._

Yes, you can! Check [the quick guide](../automated-testing/running-acceptance-tests.md#how-to-watch-what-is-going-on-in-the-selenium-browser).

## Why is there a faked PHP 8.1 platform in the Composer config?
## Why is there a faked PHP 8.3 platform in the Composer config?

As a general rule, packages and libraries that depend on PHP 8.1 will work as expected even on any higher 8.x version, but not vice versa.
Maintainers of PHP are focusing on backward-compatibility (even if there were [some incompatible changes](https://www.php.net/manual/en/migration81.incompatible.php) introduced in PHP 8.1, in practice it doesn't cause issues).
As a general rule, packages and libraries that depend on PHP 8.3 will work as expected even on any higher 8.x version, but not vice versa.
Maintainers of PHP are focusing on backward-compatibility (even if there were [some incompatible changes](https://www.php.net/manual/en/migration81.incompatible.php) introduced in PHP 8.3, in practice it doesn't cause issues).

Using [the `config.platform.php` option](https://getcomposer.org/doc/06-config.md#platform) in `composer.json` allows us to force Composer to install such dependencies, that work for all supported versions of PHP by Shopsys Platform.
These dependencies are locked during each release of Shopsys Platform so users that install it can download exact versions of all libraries and tools that were tested and proved working.
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction/shopsys-framework-on-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ kind of recipe by which final image is cooked.
Dockerfile example command:

```dockerfile
FROM php:8.1-fpm-bullseye
FROM php:8.3-fpm-bullseye
```

!!! note
Expand Down
12 changes: 6 additions & 6 deletions docs/introduction/start-building-your-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ To do so, remove the `config.platform.php` option from your `composer.json`:
"preferred-install": "dist",
- "component-dir": "project-base/web/components",
- "platform": {
- "php": "8.1"
- "php": "8.3"
- }
+ "component-dir": "project-base/web/components"
},
Expand All @@ -158,7 +158,7 @@ After all, your production server is the one that matters the most.
First, run `php -v` on your server to find our the exact version, for example:

```no-highlight
PHP 8.1.3 (cli) (built: Mar 1 2022 09:21:02) ( NTS )
PHP 8.3.2 (cli)
Copyright (c) The PHP Group
Zend Engine v4.1.3, Copyright (c) Zend Technologies
with Zend OPcache v8.1.3, Copyright (c), by Zend Technologies
Expand All @@ -167,8 +167,8 @@ Zend Engine v4.1.3, Copyright (c) Zend Technologies
Then change the version in your `docker/php-fpm/Dockerfile`:

```diff
- FROM php:8.1-fpm-bullseye as base
+ FROM php:8.1.3-fpm-bullseye as base
- FROM php:8.3-fpm-bullseye as base
+ FROM php:8.3.2-fpm-bullseye as base
```

After running `docker-compose up -d --build` you'll have the application running on the same PHP.
Expand All @@ -177,8 +177,8 @@ Now you can modify the version in your `composer.json` as well so all packages w

```diff
"platform": {
- "php": "8.1"
+ "php": "8.1.3"
- "php": "8.3"
+ "php": "8.3.2"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ https://github.com/nodejs/docker-node/blob/main/LICENSE

### Php

Image: `php:8.1-fpm-bullseye`
Image: `php:8.3-fpm-bullseye`
License: The PHP License
http://php.net/license/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install PHP, extensions and tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.3'
extensions: bcmath, gd, intl, pdo_pgsql, redis, pgsql, zip
tools: composer
- name: Install Composer dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/category-feed-persoo/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
},
"require": {
"php": "^8.1",
"php": "^8.3",
"ext-json": "*",
"ext-pdo": "*",
"doctrine/dbal": "^3.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
php-versions: ['8.1']
php-versions: ['8.3']
composer-prefered-dependencies: ['--prefer-lowest', '']
fail-fast: false
steps:
Expand Down
2 changes: 1 addition & 1 deletion packages/coding-standards/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.3",
"ext-tokenizer": "*",
"friendsofphp/php-cs-fixer": "^3.3.1",
"nette/utils": "^3.1.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install PHP, extensions and tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.3'
extensions: bcmath, gd, intl, pdo_pgsql, redis, pgsql, zip
tools: composer
- name: Install Composer dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/form-types-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
},
"require": {
"php": "^8.1",
"php": "^8.3",
"symfony/config": "^5.4",
"symfony/dependency-injection": "^5.4",
"symfony/form": "^5.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/.github/workflows/run-checks-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install PHP, extensions and tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.3'
extensions: bcmath, gd, intl, pdo_pgsql, redis, pgsql, zip
tools: composer
- name: Install Composer dependencies
Expand Down
24 changes: 13 additions & 11 deletions packages/framework/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@
<target name="db-demo" depends="production-protection,frontend-api-generate-new-keys,db-wipe-public-schema,clean,clean-redis,db-import-basic-structure,db-migrations,domains-data-create,db-fixtures-demo,plugin-demo-data-load,friendly-urls-generate,friendly-url-entity-mapping-check,domains-urls-replace" description="Creates DB and fills it with demo data" hidden="true"/>

<target name="db-fixtures-demo" depends="production-protection" description="Loads demo data fixtures." hidden="true">
<exec executable="MESSENGER_TRANSPORT_DSN=" passthru="true" checkreturn="true">
<arg value="${path.php.executable}"/>
<exec executable="${path.php.executable}" passthru="true" checkreturn="true">
<env key="MESSENGER_TRANSPORT_DSN" value=""/>
<arg value="${path.bin-console}"/>
<arg value="doctrine:fixtures:load"/>
<arg value="--append"/>
Expand All @@ -348,8 +348,8 @@
</target>

<target name="db-fixtures-performance" depends="production-protection" description="Loads performance data fixtures into main DB." hidden="true">
<exec executable="MESSENGER_TRANSPORT_DSN=" passthru="true" checkreturn="true">
<arg value="${path.php.executable}"/>
<exec executable="${path.php.executable}" passthru="true" checkreturn="true">
<env key="MESSENGER_TRANSPORT_DSN" value=""/>
<arg value="${path.bin-console}"/>
<arg value="shopsys:performance-data"/>
<arg value="--verbose"/>
Expand Down Expand Up @@ -753,7 +753,9 @@
<if>
<not><isset property="environment"/></not>
<then>
<exec command="php ${path.app}/getEnvironment.php" outputProperty="environment"/>
<exec executable="${path.php.executable}" outputProperty="environment">
<arg value="${path.app}/getEnvironment.php"/>
</exec>

<property name="environment" value="${environment}"/>
<echo>Current environment: ${environment}</echo>
Expand Down Expand Up @@ -997,8 +999,8 @@
</target>

<target name="plugin-demo-data-load" description="Loads data fixtures of all registered plugins." hidden="true">
<exec executable="MESSENGER_TRANSPORT_DSN=" passthru="true" checkreturn="true">
<arg value="${path.php.executable}"/>
<exec executable="${path.php.executable}" passthru="true" checkreturn="true">
<env key="MESSENGER_TRANSPORT_DSN" value=""/>
<arg value="${path.bin-console}"/>
<arg value="shopsys:plugin-data-fixtures:load"/>
<arg value="--verbose"/>
Expand Down Expand Up @@ -1134,8 +1136,8 @@
</target>

<target name="test-db-fixtures-demo" depends="production-protection" description="Loads demo data fixtures into test DB." hidden="true">
<exec executable="MESSENGER_TRANSPORT_DSN=" passthru="true" checkreturn="true">
<arg value="${path.php.executable}"/>
<exec executable="${path.php.executable}" passthru="true" checkreturn="true">
<env key="MESSENGER_TRANSPORT_DSN" value=""/>
<arg value="${path.bin-console}"/>
<arg value="--env=test"/>
<arg value="doctrine:fixtures:load"/>
Expand All @@ -1152,8 +1154,8 @@
</target>

<target name="test-db-fixtures-performance" depends="production-protection" description="Loads performance data fixtures into test DB." hidden="true">
<exec executable="MESSENGER_TRANSPORT_DSN=" passthru="true" checkreturn="true">
<arg value="${path.php.executable}"/>
<exec executable="${path.php.executable}" passthru="true" checkreturn="true">
<env key="MESSENGER_TRANSPORT_DSN" value=""/>
<arg value="${path.bin-console}"/>
<arg value="--env=test"/>
<arg value="shopsys:performance-data"/>
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
},
"require": {
"php": "^8.1",
"php": "^8.3",
"ext-bcmath": "*",
"ext-ctype": "*",
"ext-curl": "*",
Expand Down Expand Up @@ -75,7 +75,7 @@
"prezent/doctrine-translatable-bundle": "^1.4",
"psr/log": "^1.0",
"ramsey/uuid": "^4.3.1",
"roave/better-reflection": "^5.4.0",
"roave/better-reflection": "^6.0",
"shopsys/form-types-bundle": "14.0.x-dev",
"shopsys/jsformvalidator-bundle": "^1.7.0",
"shopsys/migrations": "14.0.x-dev",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function addAnnotationToClass(
return;
}

if ($projectClassDocComment === '') {
if ($projectClassDocComment === '' || $projectClassDocComment === null) {
$classKeywordWithName = 'class ' . $betterReflectionClass->getShortName();
$this->fileContentReplacer->replaceInFile(
$projectClassFileName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public function __construct()
}

/**
* @param string $docBlock
* @param string|null $docBlock
* @return \phpDocumentor\Reflection\Type[]
*/
public function getReturnTypes(string $docBlock): array
public function getReturnTypes(?string $docBlock): array
{
if ($docBlock === '') {
if ($docBlock === '' || $docBlock === null) {
return [];
}

Expand All @@ -43,7 +43,7 @@ public function getParameterType(ReflectionParameter $reflectionParameter): ?Typ
{
$docBlock = $reflectionParameter->getDeclaringFunction()->getDocComment();

if ($docBlock === '') {
if ($docBlock === '' || $docBlock === null) {
return null;
}

Expand Down Expand Up @@ -72,7 +72,7 @@ public function getPropertyType(ReflectionProperty $reflectionProperty): ?Type
{
$docBlock = $reflectionProperty->getDocComment();

if ($docBlock === '') {
if ($docBlock === '' || $docBlock === null) {
return null;
}

Expand Down

0 comments on commit 13f4854

Please sign in to comment.