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

No $return_array option. #252

Closed
cihantas opened this issue Nov 6, 2018 · 2 comments
Closed

No $return_array option. #252

cihantas opened this issue Nov 6, 2018 · 2 comments
Assignees
Labels
Milestone

Comments

@cihantas
Copy link
Contributor

cihantas commented Nov 6, 2018

* @return \stdClass the object containing the browsers details. Array if
* $return_array is set to true.

There's not parameter $return_array that I can pass to ->getBrowser(). Is this a bug or am I missing something?

@jaydiablo
Copy link
Contributor

I think this is probably just a documentation issue (looks like that parameter was removed long ago. It was in the 2.0 implementation: https://github.com/browscap/browscap-php/blob/2.x/src/phpbrowscap/Browscap.php#L297 but was removed by the first alpha version of the 3.0 release: https://github.com/browscap/browscap-php/blob/3.0.0-alpha.1/src/Browscap.php#L285)

Since getBrowser returns a stdClass, you can just cast that to an array, like so:

$browser = (array) $browscap->getBrowser('user-agent');

example: https://3v4l.org/mRXqA

@cihantas
Copy link
Contributor Author

cihantas commented Nov 6, 2018

Thank you! I was a bit confused, but it's working. Did a pull request. See: #253

@cihantas cihantas closed this as completed Nov 6, 2018
@asgrim asgrim reopened this Nov 6, 2018
@asgrim asgrim added the bug label Nov 6, 2018
@asgrim asgrim added this to the 4.2.0 milestone Nov 6, 2018
@asgrim asgrim self-assigned this Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants