Skip to content

exception message is wrong and misleading in findAccessorMethodName() of Magento\Framework\Reflection\NameFinder #9764

Closed
@dbsdsun

Description

@dbsdsun

Preconditions

  1. Magento 2.1.2

Steps to reproduce

  1. This function gets getter name. and It call findAccessorMethodName()
    

public function getGetterMethodName(ClassReflection $class, $camelCaseProperty)
{
$getterName = 'get' . $camelCaseProperty;
$boolGetterName = 'is' . $camelCaseProperty;
return $this->findAccessorMethodName($class, $camelCaseProperty, $getterName, $boolGetterName);
}

  1. In my case, 
           $getterName = getIsDefaultBilling
           $class->name = "Magento\Customer\Api\Data\AddressInterface"
    
  2. Obviously, Magento is looking for a getter in findAccessorMethodName()
    

    When there is no getter, findAccessorMethodName() generates an exception with message:
    ' ... does not have corresponding setter in class ... '

    This exception is wrong and misleading.

Expected result

  1. In findAccessorMethodName() of Magento\Framework\Reflection\NameFinder, the exception message should be
         throw new \LogicException(
             sprintf(
                 'Property "%s" does not have accessor method "%s" in class "%s".',
                 $camelCaseProperty,
                 $accessorName,
                 $class->getName()
             )
         );
    

Actual result

  1. [Screenshot, logs]
    

"message": "Property "IsDefaultBilling" does not have corresponding setter in class "Magento\Customer\Api\Data\AddressInterface".",
trace":
#0 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Reflection\NameFinder.php(59): Magento\Framework\Reflection\NameFinder->findAccessorMethodName(Object(Zend\Code\Reflection\ClassReflection), 'IsDefaultBillin...', 'getIsDefaultBil...', 'isIsDefaultBill...')

#1 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(158): Magento\Framework\Reflection\NameFinder->getGetterMethodName(Object(Zend\Code\Reflection\ClassReflection), 'IsDefaultBillin...')

#2 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(318): Magento\Framework\Webapi\ServiceInputProcessor->_createFromArray('\Magento\Custom...', Array)

#3 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(175): Magento\Framework\Webapi\ServiceInputProcessor->convertValue(Array, '\Magento\Custom...')

#4 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(322): Magento\Framework\Webapi\ServiceInputProcessor->_createFromArray('Wilson\Accounta...', Array)

#5 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Webapi\ServiceInputProcessor.php(119): Magento\Framework\Webapi\ServiceInputProcessor->convertValue(Array, 'Wilson\Accounta...')

#6 D:\nginx-1.8.0\websites\magento21\vendor\magento\module-webapi\Controller\Rest\InputParamsResolver.php(101): Magento\Framework\Webapi\ServiceInputProcessor->process('Wilson\Accounta...', 'createProntoAcc...', Array)

#7 D:\nginx-1.8.0\websites\magento21\vendor\magento\module-webapi\Controller\Rest.php(299): Magento\Webapi\Controller\Rest\InputParamsResolver->resolve()

#8 D:\nginx-1.8.0\websites\magento21\vendor\magento\module-webapi\Controller\Rest.php(216): Magento\Webapi\Controller\Rest->processApiRequest()

#9 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Interception\Interceptor.php(74): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))

#10 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Interception\Chain\Chain.php(70): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array)

#11 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Interception\Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Webapi\...', 'dispatch', Object(Magento\Webapi\Controller\Rest\Interceptor), Array, 'infortis_cgen_m...')

#12 D:\nginx-1.8.0\websites\magento21\app\code\Infortis\Cgen\Plugin\Magento\Framework\App\FrontController.php(32): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

#13 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\Interception\Interceptor.php(142): Infortis\Cgen\Plugin\Magento\Framework\App\FrontController->aroundDispatch(Object(Magento\Webapi\Controller\Rest\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

#14 D:\nginx-1.8.0\websites\magento21\var\generation\Magento\Webapi\Controller\Rest\Interceptor.php(39): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)

#15 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\App\Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

#16 D:\nginx-1.8.0\websites\magento21\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http->launch()

#17 D:\nginx-1.8.0\websites\magento21\pub\index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))

#18 {main}

Metadata

Metadata

Assignees

Labels

Fixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasebug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions