Skip to content

getItemsByColumnValue wrong type declaration #33070

@vaso123

Description

@vaso123

Preconditions (*)

Magento 2.4.2

Steps to reproduce (*)

Call getItemsByColumnValue([string], [array]) on any collection.

Expected result (*)

Get the collection

Actual result (*)

Get null.

Component: magento-framework
File: vendor/magento/framework/Data/Collection.php

Description

The problem is that the input parameter $value has defined as an array in the annotation.
If you are using an array with a single value, you will get back nothing and IDEs will mark it as an error.

You should use primitives (int, string, float, etc...).

The problem is that you defined the function like this:

/**
* @param string $column
* @param array $value
* @return array
*/
public function getItemsByColumnValue($column, $value)

but later you says:

if ($item->getData($column) == $value) {

So the value should be a primitive type, not an array.

Please fix it.

Issue: Confirmed

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions