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
8000
Allow null as default value for getClaim #249
Closed
@iluuu1994

Description

@iluuu1994

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) {

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0