Open
Description
Preconditions (*)
- Magento 2.4.2-p2
Steps to reproduce (*)
- Add an extension attribute to the CustomerInterface with a specific Model :
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="Magento\Customer\Api\Data\CustomerInterface">
<attribute code="myObj" type="Vendor\Merchant\Model\Response"/>
</extension_attributes>
</config>
<?php
declare(strict_types=1);
namespace Vendor\Merchant\Model;
class MyObj
{
private InnerAttribute $myAttribute;
/**
* @return InnerAttribute
*/
public function getMyAttribute(): InnerAttribute
{
return $this->myAttribute;
}
/**
* @param InnerAttribute $myAttribute
*/
public function setMyAttribute(InnerAttribute $myAttribute): void
{
$this->myAttribute = $myAttribute;
}
}
With InnerAttribute defined in the same folder :
<?php
declare(strict_types=1);
namespace Vendor\Merchant\Model;
class InnerAttribute
{
}
-
Class will not be instantied in Reflection and you will get an error from
vendor/magento/framework/Reflection/DataObjectProcessor.php
-
While the
getParamType
fromvendor/magento/framework/Reflection/TypeProcessor.php
resolves the FQN when not specified, the functiongetGetterReturnType
is not resolving the FQN which leads to an error.
Expected result (*)
- Reflection should be made on FQN and not on relative class name
Actual result (*)
- Error is thrown "Class InnerAttribute does not exist"
As a quick fix, I made the function resolving the FQN as the param does :
public function getGetterReturnType($methodReflection)
{
$returnAnnotation = $this->getMethodReturnAnnotation($methodReflection);
$types = $returnAnnotation->getTypes();
$returnType = null;
foreach ($types as $type) {
if ($type !== 'null') {
$returnType = $type;
break;
}
}
$returnType = $this->resolveFullyQualifiedClassName($methodReflection->getDeclaringClass(), $returnType);
$nullable = in_array('null', $types);
return [
'type' => $returnType,
'isRequired' => !$nullable,
'description' => $returnAnnotation->getDescription(),
'parameterCount' => $methodReflection->getNumberOfRequiredParameters()
];
}
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmedA defect with this priority could have functionality issues which are not to expectations.The issue has been reproduced on latest 2.4-develop branchIssue related to Developer Experience and needs help with Triage to Confirm or Reject it