magento / magento/magento-coding-standard
Exception class Magento\Framework\Validator\ValidateException does not exist
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 375
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
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
Solution
The Magento\Framework\Validator\ValidateException should be replaced with Magento\Framework\Validator\Exception
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect Magento2/Sniffs/Legacy/_files/restricted_classes.php at line 129, where the replacement for Zend_Validate_Exception is defined. Run vendor/bin/phpcs --standard=Magento2 against the example Data Patch and update the suggested replacement to Magento\Framework\Validator\Exception; done means the output names the existing replacement and no longer references ValidateException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100