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

Request helper hasAny returning different booleans for arrays #22917

Closed
bbashy opened this issue Jan 25, 2018 · 2 comments
Closed

Request helper hasAny returning different booleans for arrays #22917

bbashy opened this issue Jan 25, 2018 · 2 comments

Comments

@bbashy
Copy link
Contributor

bbashy commented Jan 25, 2018

  • Laravel Version: 5.5.32
  • PHP Version: 7.1.13
  • Database Driver & Version: MariaDB 10.2.12

Description:

When using hasAny() on the request helper, it returns false when using an array but true when using multiple params.

laravel/framework/src/Illuminate/Http/Concerns/InteractsWithInput.php hasAny() function receives the keys like this;

// via array

array:1 [▼
  0 => array:3 [▼
    0 => "from"
    1 => "to"
    2 => "manager"
  ]
]

// via params

array:3 [▼
  0 => "from"
  1 => "to"
  2 => "manager"
]

Steps To Reproduce:

URL: http://domain.ext?from=17-01-2018

  1. When using hasAny with array, this will return false.
  2. When using hasAny with multiple params, this will return true.
dd(
    request()->all(),
    request()->hasAny('from', 'to', 'manager'),
    request()->hasAny(['from', 'to', 'manager'])
);
@devcircus
Copy link
Contributor

See the code. The method expects individual parameters. So the array is recognized as a single param. Maybe a PR?

@themsaid
Copy link
Member

PR submitted to 5.6 branch #22952

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants