Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SpoofedCollaborator implement or extend wrapped class #6

Open
akondas opened this issue Dec 31, 2018 · 4 comments
Open

Make SpoofedCollaborator implement or extend wrapped class #6

akondas opened this issue Dec 31, 2018 · 4 comments

Comments

@akondas
Copy link
Contributor

akondas commented Dec 31, 2018

This is problem, when collaborator is used not only in Subject or Collaborator, for example:

public function it_should_be_nice_spec(Client $client): void
{
    $this->doSomethingMore($client);

    $this->make($client)->shouldReturn('magic');
}

private function doSomethingMore(Client $client): void
{
}
  34     Parameter #1 $client of method                                                                
         spec\SomeSpec::doSomethingMore() expects                  
         Client,                                                            
         class@anonymous\/var/www/proget/vendor/proget-hq/phpstan-phpspec/src/NodeVisitor/Collab  
         oratorResolver.php(42) : eval()'d code0x7f3a250371b2 given.  
@akondas
Copy link
Contributor Author

akondas commented Dec 31, 2018

This is more complex but should be possible. We must find out (on parse level) is source class is interface or standard class. Of course, if the class is final then 💀.

@babaorum
Copy link

babaorum commented Jan 3, 2019

Just stated testing this extension, right now I see 2 problems:

  1. what is described just above.

  2. almost the opposite

function it_do_something()
{
    $this->doSomethingMore(new Foo());
}

private function doSomethingMore(Foo $foo)
{
    foreach ($foo as $bar) {
        // ...
    }
}
  97     Argument of an invalid type                                                          
         class@anonymous\/www-data/vendor/proget-hq/phpstan-phpspec/src/NodeVisi              
         tor/CollaboratorResolver.php(42) : eval()'d code0x7ff73082e752 supplied              
         for foreach, only iterables are supported.  

with a foo class that implement \IteratorAggregate for example.

I am not sure if the second problem is unrelated to the first one. If so I can create a dedicated issue.

@akondas
Copy link
Contributor Author

akondas commented Jan 3, 2019

The second problem concerns the same, so the same fix will solve both cases.

@akondas
Copy link
Contributor Author

akondas commented Jan 10, 2019

This is more complicated, because in the case of an interface, you need to add an implementation, but he is in the middle of work, I will inform you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants