Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Property info cannot resolve trait namespace #34191

Copy link
Copy link
Closed
@webmake

Description

@webmake
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.