Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Type annotations and use statement doesn't work #27

Closed
snapshotpl opened this issue Jun 30, 2015 · 5 comments
Closed

Type annotations and use statement doesn't work #27

snapshotpl opened this issue Jun 30, 2015 · 5 comments
Assignees
Labels
Milestone

Comments

@snapshotpl
Copy link

I have code like this:

namespace RstGroup;

use Doctrine\DBAL\Logging\DebugStack;
use Psr\Log\LoggerInterface;

class SqlLogger extends DebugStack
{
    /**
     * @var LoggerInterface
     */
    protected $logger;

    public function __construct(LoggerInterface $logger)
    {
        $this->logger = $logger;
    }
}

And an exception will be thrown:

Argument 1 passed to StrictPhp\TypeChecker\TypeChecker\ObjectTypeChecker::{closure}() must be an instance of RstGroup\LoggerInterface, instance of ProxyManagerGeneratedProxy\__PM__\Monolog\Logger\Generatedfed9df116512e1fdede47c68f47e49b5 given, called in /vendor/roave/strict-php/src/StrictPhp/TypeChecker/TypeChecker/ObjectTypeChecker.php on line 80 and defined in /vendor/roave/strict-php/src/StrictPhp/TypeChecker/TypeChecker/ObjectTypeChecker.php(78) : eval()'d code on line 1

If I change annotation to @var \Psr\Log\LoggerInterface checking goes on. I think that checker should using used namespaces to resolve class names.

@GeeH
Copy link
Collaborator

GeeH commented Jun 30, 2015

I have a method in the Sevenificator to assume this - should probably move
to Better Reflection tho @asgrim?

On Tue, 30 Jun 2015 at 13:10 Witold Wasiczko notifications@github.com
wrote:

I have code like this:

namespace RstGroup;use Doctrine\DBAL\Logging\DebugStack;use Psr\Log\LoggerInterface;class SqlLogger extends DebugStack{ /** * @var LoggerInterface */ protected $logger; public function __construct(LoggerInterface $logger) { $this->logger = $logger; }}

And an exception will be thrown:

Argument 1 passed to StrictPhp\TypeChecker\TypeChecker\ObjectTypeChecker::{closure}() must be an instance of RstGroup\LoggerInterface, instance of ProxyManagerGeneratedProxy__PM__\Monolog\Logger\Generatedfed9df116512e1fdede47c68f47e49b5 given, called in /vendor/roave/strict-php/src/StrictPhp/TypeChecker/TypeChecker/ObjectTypeChecker.php on line 80 and defined in /vendor/roave/strict-php/src/StrictPhp/TypeChecker/TypeChecker/ObjectTypeChecker.php(78) : eval()'d code on line 1

If I change annotation to @var https://github.com/var
\Psr\Log\LoggerInterface checking goes on. I think that checker should
using used namespaces to resolve class names.


Reply to this email directly or view it on GitHub
#27.

@Ocramius
Copy link
Member

@snapshotpl that's a good catch - I actually wrote tests for this, but I'll obviously need to fix them, as it seems.

@asgrim
Copy link
Member

asgrim commented Jun 30, 2015

@GeeH I've opened an issue to implement this into Better Reflection

@snapshotpl
Copy link
Author

Thanks for blazing fast reaction! StrictPhp looks very promising

@Ocramius
Copy link
Member

Ocramius commented Jul 1, 2015

Handled in #29

@Ocramius Ocramius closed this as completed Jul 1, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants