Skip to content

Access to an undefined property object::$FULLNAME #2357

@andig

Description

@andig

Bug report

Code snippet that reproduces the problem

/**
 * @param mixed $vcard
 * @return mixed
 */
public function enrichVcard($vcard)
{
    if (isset($vcard->FN)) {
        $vcard->FULLNAME = (string)$vcard->FN;
    }
}

gives

  Line   CardDav/Backend.php                                 
 ------ ---------------------------------------------------- 
  252    Access to an undefined property object::$FULLNAME.  
 ------ ---------------------------------------------------- 

Here is a similar stan: https://phpstan.org/r/2e641f19-1d8a-486c-8be6-06233e1ee9a8

Expected output

No error. It should be possible to intentionally create properties on objects.

Vcard is an actual Sabre\VObject\Document that uses getter/setter magic to provide dynamic properties. I need to convince stan that these properties exist. mixed doesn't work, object doesn't work, using the actual type as hint doesn't work, also another hint right above doesn't work:

    /** @var \stdClass $vcard */

I've re-read #928 but couldn't find the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions