Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation for the find method #255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Page-Carbajal
Copy link

$id is not always an array. Currently triggering "argument must be of type array|object" warning when using strings and integers. The validation fixes that issue.

$id may not always be an array. Currently triggering "argument must be of type array|object" warning. This validation fixes that issue.
@scrutinizer-notifier
Copy link

The inspection completed: No new issues

@zoe-edwards
Copy link
Collaborator

Which linter are you using out of interest?

@nelson6e65 nelson6e65 added missing tests Feature or bug that needs failing tests to replicate it needs more info More information is needed or was requested labels Feb 24, 2023
@nelson6e65 nelson6e65 self-requested a review April 18, 2023 06:13
Copy link
Collaborator

@nelson6e65 nelson6e65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this check in the isMultipleId method instead?

protected function isMultipleIds($id)
{
$keys = collect($this->model->getKeyNames());
// could be ['id' => 'foo'], ['id1' => 'foo', 'id2' => 'bar']
$single = $keys->first(function ($name) use ($id) {
return !isset($id[$name]);
}) === null;
if ($single) {
return false;
}
// could be ['foo', 'bar'], [['id1' => 'foo', 'id2' => 'bar'], ...]
return $this->model->hasCompositeKey() ? is_array(H::array_first($id)) : is_array($id);
}

@nelson6e65 nelson6e65 self-assigned this Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing tests Feature or bug that needs failing tests to replicate it needs more info More information is needed or was requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants