Skip to content

Regression on actual methods #55

@dereuromark

Description

@dereuromark

With our last change, we now have issues with actually existing methods:

  Line   Controller/Admin/SupplierProductsController.php                        
 ------ ----------------------------------------------------------------------- 
  281    Method Cake\ORM\Table::findOrCreateBySku() invoked with 2 parameters,  
         1 required.                                                            
         🪪  arguments.count                                                    
  282    Access to an undefined property Cake\ORM\Query\SelectQuery::$id.       
         🪪  property.notFound                                                  
         💡  Learn more: https://phpstan.org/blog/solving-phpstan-access-to-und  
         efined-property       
    /**
     * @param string $sku
     * @param string $name
     *
     * @return \App\Model\Entity\Product
     */
    public function findOrCreateBySku(string $sku, string $name): Product
    {
        $product = $this->find()
            ->where(['sku' => $sku])
            ->first();
        if (!$product) {
            $product = $this->newEntity([
                'sku' => $sku,
                'name' => $name,
            ]);
            $product = $this->saveOrFail($product);
        }

        return $product;
    }

I think we need to check if the method actually exists and then skip our checks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions