Skip to content

Visibility worklog setter causes error. #180

@ArchieDoe

Description

@ArchieDoe

\JiraRestApi\Issue\Worklog

/**
 * Function to set visibility of worklog.
 *
 * @param string $type  value can be group or role
 * @param string $value
 *
 * @return Worklog
 */
public function setVisibility($type, $value)
{
    $this->visibility = [
        'type'  => $type,
        'value' => $value,
    ];

    return $this;
}

In this code setVisibility has 2 parameters, both are annotated as string.

Worklog json visibility looks like this

"visibility": {
  "type": "role",
  "value": "Developers"
},

so json mapper converts value as stdClass

When JsonMapper tries to detect type of visibility property, it reads first annotation parameter type in setVisibility method, since it believes that this is a setter for class:

\JsonMapper::inspectProperty

After that it tries to case object of stdClass to string which causes

Recoverable fatal error: Object of class stdClass could not be converted to string in 
JsonMapper->map()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions