Skip to content

getItemsByColumnValue wrong type declaration #33070

Open
@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

Area: FrameworkComponent: Framework/DataIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: PR in progressReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions