1

When I try to use my own copyright I get this warning when running phpcs:

"0: line: 3, col: 1, Copyright is missing or has wrong format"

But if I use Magento copyright, I get no warning.

No Warning:

/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

Warning:

/**
 * Copyright © MyCompany, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

Actual Code

<?php
/**
 * Copyright © MyCompany All rights reserved.
 * See License for license details.
 */

namespace MyCompany\MyApp\ViewModel;

use Magento\Framework\View\Element\Block\ArgumentInterface;
use Magento\Framework\View\Element\Template;

/**
 * Gets current products Categories
 */
class CalculatorLogic extends Template implements 

ArgumentInterface
{
    /**
     * @param Registry $registry
     * @param Category $categoryModel
     */
    public function __construct(
        \Magento\Framework\Registry $registry,
        \Magento\Catalog\Model\Category $categoryModel
    ) {
        $this->registry = $registry;
        $this->categoryModel = $categoryModel;
    }
    
    /**
     * Gets current products Categories
     *
     * @return Category[]
     */
    public function getProductCatagory()
    {
        $product = $this->registry->registry('current_product');
        $categories = $product->getCategoryIds(); /*will return category ids array*/
        $arr =[];
        foreach ($categories as $category) {
            $cat = $this->categoryModel->load($category);
            $arr[] = $cat->getName();
        }
        return $arr;
    }
}

phpcs results

{"totals":{"errors":0,"warnings":1,"fixable":0},"files":{"\/var\/www\/html\/mage\/app\/code\/MyComany\/MyApp\/ViewModel\/CalculatorLogic.php":{"errors":0,"warnings":1,"messages":[{"message":"Copyright is missing or has wrong format","source":"Magento2.Legacy.Copyright.FoundCopyrightMissingOrWrongFormat","severity":5,"fixable":false,"type":"WARNING","line":3,"column":1}]}}}
4
  • can you share any one file with the code? Oct 28, 2021 at 4:17
  • I added the code. Oct 28, 2021 at 5:31
  • Did anyone find the solutions? May 10 at 13:54
  • @JustinCollins are you able to resolve this? May 10 at 14:16

3 Answers 3

0

try this code :

<?php
/**
 * Copyright © MyCompany All rights reserved.
 * See COPYING.txt for license details.
 */
namespace MyCompany\MyApp\ViewModel;
3
  • It doesn't work. Perhaps its just the way I have phpcs configured. Oct 28, 2021 at 5:45
  • Kindly check you did not put any extra space over there. Oct 28, 2021 at 5:51
  • I am certain, there is no extra space. Oct 28, 2021 at 5:53
0

This is because of Magento uses its own CopyrightSniff where they require text 'Copyright © Magento' :)

0
0

overwrite vendor/magento/magento-coding-standard/Magento2Framework/Sniffs/Header/CopyrightSniff.php file's process. giving

public function process(File $phpcsFile, $stackPtr)
{
    return;
}

please do it if you are bother with text error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.