10000 Property info cannot resolve trait namespace · Issue #34191 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Property info cannot resolve trait namespace #34191
Closed
@webmake

Description

@webmake

Symfony version(s) affected: 4.3.5

Description
Hello, I have encountered with problem deserializing object, and eventually pointed to property-info, that my trait exists elsewhere than class itself. It seems
that getPhpTypeAndClass is too simple for traits (?).

How to reproduce

namespace Command\Common\Traits;

use Command\Model\Payment\UserAccountDetails;

trait UserDetailsAwareTrait
{
    /**
     * @var UserAccountDetails
     */
    protected $userAccountDetails;

    public function getUserAccountDetails(): UserAccountDetails
    {
        return $this->userAccountDetails;
    }

    public function setUserAccountDetails(UserAccountDetails $userAccountDetails): void
    {
        $this->userAccountDetails = $userAccountDetails;
    }
}
namespace Command\Bank;

use Command\Common\Traits\UserDetailsAwareTrait;

class DepositCommand
{
    use UserDetailsAwareTrait;
}
namespace Command\Model\Payment;

class UserAccountDetails
{
    /**
     * @var bool|null
     */
    private $accountVerified;

    public function isAccountVerified(): ?bool
    {
        return $this->accountVerified;
    }

    public function setAccountVerified(?bool $accountVerified): UserAccountDetails
    {
        $this->accountVerified = $accountVerified;

        return $this;
    }
}

Possible Solution

It seems that another library have already resolved this issue, you can take a look and this one

Additional context
as you can see structure passed to https://github.com/phpDocumentor/ReflectionDocBlock/blob/4.3.2/src/DocBlockFactory.php#L73 within $context variable
image
gives https://github.com/symfony/property-info/blob/v4.3.5/Extractor/PhpDocExtractor.php#L150
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0