Skip to content

Commit 3b97322

Browse files
authored
Merge pull request #274 from shochdoerfer/fix/ext_attr_array
Don't use ?array type hint in ext attributes
2 parents 6e0172b + 9a5e2ef commit 3b97322

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

src/bitExpert/PHPStan/Magento/Autoload/ExtensionAutoloader.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ public function getFileContents(string $className): string
8989
* @see \Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator::_getClassMethods
9090
*/
9191

92-
// treat array types properly in the generated code. Similar to Magento core MyInterface[] type gets
93-
// converted to just an array
94-
$paramType = $type;
95-
if (strpos($type, '[]') !== false) {
96-
$paramType = '?array';
97-
}
98-
9992
$generator->addMethodFromGenerator(
10093
MethodGenerator::fromArray([
10194
'name' => 'get' . ucfirst($propertyName),
@@ -109,7 +102,7 @@ public function getFileContents(string $className): string
109102
$generator->addMethodFromGenerator(
110103
MethodGenerator::fromArray([
111104
'name' => 'set' . ucfirst($propertyName),
112-
'parameters' => [new ParameterGenerator($propertyName, $paramType)],
105+
'parameters' => [$propertyName],
113106
'docblock' => DocBlockGenerator::fromArray([
114107
'tags' => [
115108
new ParamTag($propertyName, [$type]),

src/bitExpert/PHPStan/Magento/Autoload/ExtensionInterfaceAutoloader.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,6 @@ public function getFileContents(string $interfaceName): string
105105
* @see \Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator::_getClassMethods
106106
*/
107107

108-
// treat array types properly in the generated code. Similar to Magento core MyInterface[] type gets
109-
// converted to just an array
110-
$paramType = $type;
111-
if (strpos($type, '[]') !== false) {
112-
$paramType = '?array';
113-
}
114-
115108
$generator->addMethodFromGenerator(
116109
MethodGenerator::fromArray([
117110
'name' => 'get' . ucfirst($propertyName),
@@ -125,7 +118,7 @@ public function getFileContents(string $interfaceName): string
125118
$generator->addMethodFromGenerator(
126119
MethodGenerator::fromArray([
127120
'name' => 'set' . ucfirst($propertyName),
128-
'parameters' => [new ParameterGenerator($propertyName, $paramType)],
121+
'parameters' => [$propertyName],
129122
'docblock' => DocBlockGenerator::fromArray([
130123
'tags' => [
131124
new ParamTag($propertyName, [$type]),

0 commit comments

Comments
 (0)