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 authored Feb 9, 2024
2 parents 9f433f0 + 8a626dd commit 6bab466
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .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 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 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
25 changes: 0 additions & 25 deletions src/Component/ArrayUtils/RecursiveArraySorter.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Component/ClassExtension/AnnotationsAdder.php
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
10 changes: 5 additions & 5 deletions src/Component/ClassExtension/DocBlockParser.php
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DocBlockParserAmbiguousTagException extends DocBlockParserException
public function __construct(string $tagName, string $propertyPath)
{
parent::__construct(
"Doc block should have only 1 ${tagName} tag.\nProperty: ${propertyPath}\n",
"Doc block should have only 1 {$tagName} tag.\nProperty: {$propertyPath}\n",
);
}
}
2 changes: 1 addition & 1 deletion src/Component/ClassExtension/MethodAnnotationsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getProjectClassNecessaryMethodAnnotationsLines(
foreach ($frameworkClassBetterReflection->getMethods() as $method) {
$methodAnnotationLine = $this->getMethodAnnotationLine($method, $projectClassBetterReflection);

if ($methodAnnotationLine !== '' && strpos($projectClassDocBlock, $methodAnnotationLine) === false) {
if ($methodAnnotationLine !== '' && !str_contains($projectClassDocBlock ?? '', $methodAnnotationLine)) {
$methodAnnotationsLines .= $methodAnnotationLine;
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/Component/ClassExtension/PropertyAnnotationsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getProjectClassNecessaryPropertyAnnotationsLines(
foreach ($frameworkClassBetterReflection->getProperties() as $property) {
$propertyAnnotationLine = $this->getPropertyAnnotationLine($property, $projectClassBetterReflection);

if ($propertyAnnotationLine !== '' && strpos($projectClassDocBlock, $propertyAnnotationLine) === false) {
if ($propertyAnnotationLine !== '' && !str_contains($projectClassDocBlock ?? '', $propertyAnnotationLine)) {
$propertyAnnotationsLines .= $propertyAnnotationLine;
}
}
Expand Down Expand Up @@ -102,7 +102,10 @@ protected function isPropertyOfTypeThatIsExtendedInProject(
ReflectionProperty $reflectionProperty,
string $frameworkClassPattern,
): bool {
$propertyTypeString = $reflectionProperty->getDocComment() !== '' ? $reflectionProperty->getDocComment() : TypehintHelper::getPropertyTypeFromTypehint($reflectionProperty);
$docComment = $reflectionProperty->getDocComment() ?? '';

$propertyTypeString = $docComment !== '' ? $docComment : TypehintHelper::getPropertyTypeFromTypehint($reflectionProperty);


return (bool)preg_match(
$frameworkClassPattern,
Expand Down

0 comments on commit 6bab466

Please sign in to comment.