Skip to content

Commit 6bab466

Browse files
[shopsys] Upgraded to PHP 8.3 (#3002)
2 parents 9f433f0 + 8a626dd commit 6bab466

File tree

9 files changed

+29
-49
lines changed

9 files changed

+29
-49
lines changed

.github/workflows/run-checks-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Install PHP, extensions and tools
1616
uses: shivammathur/setup-php@v2
1717
with:
18-
php-version: '8.1'
18+
php-version: '8.3'
1919
extensions: bcmath, gd, intl, pdo_pgsql, redis, pgsql, zip
2020
tools: composer
2121
- name: Install Composer dependencies

build.xml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@
332332
<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"/>
333333

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

350350
<target name="db-fixtures-performance" depends="production-protection" description="Loads performance data fixtures into main DB." hidden="true">
351-
<exec executable="MESSENGER_TRANSPORT_DSN=" passthru="true" checkreturn="true">
352-
<arg value="${path.php.executable}"/>
351+
<exec executable="${path.php.executable}" passthru="true" checkreturn="true">
352+
<env key="MESSENGER_TRANSPORT_DSN" value=""/>
353353
<arg value="${path.bin-console}"/>
354354
<arg value="shopsys:performance-data"/>
355355
<arg value="--verbose"/>
@@ -753,7 +753,9 @@
753753
<if>
754754
<not><isset property="environment"/></not>
755755
<then>
756-
<exec command="php ${path.app}/getEnvironment.php" outputProperty="environment"/>
756+
<exec executable="${path.php.executable}" outputProperty="environment">
757+
<arg value="${path.app}/getEnvironment.php"/>
758+
</exec>
757759

758760
<property name="environment" value="${environment}"/>
759761
<echo>Current environment: ${environment}</echo>
@@ -997,8 +999,8 @@
997999
</target>
9981000

9991001
<target name="plugin-demo-data-load" description="Loads data fixtures of all registered plugins." hidden="true">
1000-
<exec executable="MESSENGER_TRANSPORT_DSN=" passthru="true" checkreturn="true">
1001-
<arg value="${path.php.executable}"/>
1002+
<exec executable="${path.php.executable}" passthru="true" checkreturn="true">
1003+
<env key="MESSENGER_TRANSPORT_DSN" value=""/>
10021004
<arg value="${path.bin-console}"/>
10031005
<arg value="shopsys:plugin-data-fixtures:load"/>
10041006
<arg value="--verbose"/>
@@ -1134,8 +1136,8 @@
11341136
</target>
11351137

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

11541156
<target name="test-db-fixtures-performance" depends="production-protection" description="Loads performance data fixtures into test DB." hidden="true">
1155-
<exec executable="MESSENGER_TRANSPORT_DSN=" passthru="true" checkreturn="true">
1156-
<arg value="${path.php.executable}"/>
1157+
<exec executable="${path.php.executable}" passthru="true" checkreturn="true">
1158+
<env key="MESSENGER_TRANSPORT_DSN" value=""/>
11571159
<arg value="${path.bin-console}"/>
11581160
<arg value="--env=test"/>
11591161
<arg value="shopsys:performance-data"/>

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121
},
2222
"require": {
23-
"php": "^8.1",
23+
"php": "^8.3",
2424
"ext-bcmath": "*",
2525
"ext-ctype": "*",
2626
"ext-curl": "*",
@@ -75,7 +75,7 @@
7575
"prezent/doctrine-translatable-bundle": "^1.4",
7676
"psr/log": "^1.0",
7777
"ramsey/uuid": "^4.3.1",
78-
"roave/better-reflection": "^5.4.0",
78+
"roave/better-reflection": "^6.0",
7979
"shopsys/form-types-bundle": "14.0.x-dev",
8080
"shopsys/jsformvalidator-bundle": "^1.7.0",
8181
"shopsys/migrations": "14.0.x-dev",

src/Component/ArrayUtils/RecursiveArraySorter.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/Component/ClassExtension/AnnotationsAdder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function addAnnotationToClass(
3030
return;
3131
}
3232

33-
if ($projectClassDocComment === '') {
33+
if ($projectClassDocComment === '' || $projectClassDocComment === null) {
3434
$classKeywordWithName = 'class ' . $betterReflectionClass->getShortName();
3535
$this->fileContentReplacer->replaceInFile(
3636
$projectClassFileName,

src/Component/ClassExtension/DocBlockParser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public function __construct()
2121
}
2222

2323
/**
24-
* @param string $docBlock
24+
* @param string|null $docBlock
2525
* @return \phpDocumentor\Reflection\Type[]
2626
*/
27-
public function getReturnTypes(string $docBlock): array
27+
public function getReturnTypes(?string $docBlock): array
2828
{
29-
if ($docBlock === '') {
29+
if ($docBlock === '' || $docBlock === null) {
3030
return [];
3131
}
3232

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

46-
if ($docBlock === '') {
46+
if ($docBlock === '' || $docBlock === null) {
4747
return null;
4848
}
4949

@@ -72,7 +72,7 @@ public function getPropertyType(ReflectionProperty $reflectionProperty): ?Type
7272
{
7373
$docBlock = $reflectionProperty->getDocComment();
7474

75-
if ($docBlock === '') {
75+
if ($docBlock === '' || $docBlock === null) {
7676
return null;
7777
}
7878

src/Component/ClassExtension/Exception/DocBlockParserAmbiguousTagException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DocBlockParserAmbiguousTagException extends DocBlockParserException
1313
public function __construct(string $tagName, string $propertyPath)
1414
{
1515
parent::__construct(
16-
"Doc block should have only 1 ${tagName} tag.\nProperty: ${propertyPath}\n",
16+
"Doc block should have only 1 {$tagName} tag.\nProperty: {$propertyPath}\n",
1717
);
1818
}
1919
}

src/Component/ClassExtension/MethodAnnotationsFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getProjectClassNecessaryMethodAnnotationsLines(
5151
foreach ($frameworkClassBetterReflection->getMethods() as $method) {
5252
$methodAnnotationLine = $this->getMethodAnnotationLine($method, $projectClassBetterReflection);
5353

54-
if ($methodAnnotationLine !== '' && strpos($projectClassDocBlock, $methodAnnotationLine) === false) {
54+
if ($methodAnnotationLine !== '' && !str_contains($projectClassDocBlock ?? '', $methodAnnotationLine)) {
5555
$methodAnnotationsLines .= $methodAnnotationLine;
5656
}
5757
}

src/Component/ClassExtension/PropertyAnnotationsFactory.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getProjectClassNecessaryPropertyAnnotationsLines(
3434
foreach ($frameworkClassBetterReflection->getProperties() as $property) {
3535
$propertyAnnotationLine = $this->getPropertyAnnotationLine($property, $projectClassBetterReflection);
3636

37-
if ($propertyAnnotationLine !== '' && strpos($projectClassDocBlock, $propertyAnnotationLine) === false) {
37+
if ($propertyAnnotationLine !== '' && !str_contains($projectClassDocBlock ?? '', $propertyAnnotationLine)) {
3838
$propertyAnnotationsLines .= $propertyAnnotationLine;
3939
}
4040
}
@@ -102,7 +102,10 @@ protected function isPropertyOfTypeThatIsExtendedInProject(
102102
ReflectionProperty $reflectionProperty,
103103
string $frameworkClassPattern,
104104
): bool {
105-
$propertyTypeString = $reflectionProperty->getDocComment() !== '' ? $reflectionProperty->getDocComment() : TypehintHelper::getPropertyTypeFromTypehint($reflectionProperty);
105+
$docComment = $reflectionProperty->getDocComment() ?? '';
106+
107+
$propertyTypeString = $docComment !== '' ? $docComment : TypehintHelper::getPropertyTypeFromTypehint($reflectionProperty);
108+
106109

107110
return (bool)preg_match(
108111
$frameworkClassPattern,

0 commit comments

Comments
 (0)