Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
okolya opened this issue Oct 21, 2022 · 2 comments
Open

Comments

@okolya
Copy link

okolya commented Oct 21, 2022

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

@m2-assistant
Copy link

m2-assistant bot commented Oct 21, 2022

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


@fredden
Copy link
Member

fredden commented Oct 23, 2022

Both classes exist in the code-base.

https://github.com/magento/magento2/tree/5a022f69ada01effe32a207000a2391e1c918625/lib/internal/Magento/Framework/Validator
https://github.com/magento/magento2/blob/5a022f69ada01effe32a207000a2391e1c918625/lib/internal/Magento/Framework/Validator/Exception.php
https://github.com/magento/magento2/blob/5a022f69ada01effe32a207000a2391e1c918625/lib/internal/Magento/Framework/Validator/ValidateException.php

From what I can tell, ValidateException was specifically introduced as a replacement for Zend_Validate_Exception.

https://github.com/magento/magento2/commits/5a022f69ada01effe32a207000a2391e1c918625/lib/internal/Magento/Framework/Validator/ValidateException.php

Perhaps this change request should be paired with a change to the code-base to remove usage of ValidateException in favour of ...\Validator\Exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants