magento/magento-coding-standard

Exception class Magento\Framework\Validator\ValidateException does not exist

okolya opened this issue · 2 comments

Preconditions

Add attribute in Data Patch using $eavSetup->addAttribute() method.
Place DataPatch in Vendor/Module/Setup/Patch/Data/AddTestAttribute.php file.

Example

$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$eavSetup->addAttribute(Product::ENTITY, $attributeCode, $attribute);

Steps to reproduce

run vendor/bin/phpcs --standard=Magento2 app/code/Vendor/Module/Setup/Patch/Data/AddTestAttribute.php

Expected result

class 'Zend_Validate_Exception' is restricted in app/code/Vendor/Module/Setup/Patch/Data/AddTestAttribute.php. 
Suggested replacement: Magento\Framework\Validator\Exception

Actual result

class 'Zend_Validate_Exception' is restricted in app/code/Vendor/Module/Setup/Patch/Data/AddTestAttribute.php. 
Suggested replacement: Magento\Framework\Validator\ValidateException

Line

'replacement' => 'Magento\Framework\Validator\ValidateException',

Solution

The Magento\Framework\Validator\ValidateException should be replaced with Magento\Framework\Validator\Exception

Hi @okolya. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this