magento / magento/magento-coding-standard

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

Open
#427 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Progress: ready for grooming
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

https://github.com/magento/magento-coding-standard/blob/097bda3e015f35dc7c2efc0b8c7a7d8dfc158a63/Magento2/Sniffs/Legacy/_files/restricted_classes.php#L129

Solution

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.