8000 Allow null as default value for getClaim · Issue #249 · lcobucci/jwt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow null as default value for getClaim #249

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

Closed
iluuu1994 opened this issue Jul 11, 2018 · 2 comments · Fixed by #432
Closed

Allow null as default value for getClaim #249

iluuu1994 opened this issue Jul 11, 2018 · 2 comments · Fixed by #432
Assignees
Milestone

Comments

@iluuu1994
Copy link

Disclaimer: I'm not sure if this is still relevant for 4.0.

The current implementation of getClaim does not allow null-values:

public function getClaim($name, $default = null)
{
    if ($this->hasClaim($name)) {
        return $this->claims[$name]->getValue();
    }

    if ($default === null) {
        throw new OutOfBoundsException('Requested claim is not configured');
    }

    return $default;
}

Even if you specifically provide the default value:

$token->getClaim('sub', null);

OutOfBoundsException

This could be solved by simply changing this line:

if ($default === null) {

to

if (func_num_args() === 1) {
@lcobucci
Copy link
Owner

@iluuu1994 it's indeed not relevant for v4 but we can plan it for v3.3. I'll be working on it in the upcoming month 👍

@lcobucci
Copy link
Owner

Handled by #432

@lcobucci lcobucci self-assigned this Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0