Traits are not supported (`Mockery::mock()`)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start by reproducing the two Mockery::mock() examples, comparing a class-only mock with one that includes trait T. Trace how the extension handles Mockery::mock() arguments and verify that trait methods are represented while unknown methods remain rejected; the dumped type should no longer be NEVER.
Written by the indexing model from the issue text.
Description
Mockery::mock() allow to add traits into mocks:
<?php declare(strict_types = 1);
class C {
public function helloClass(): string { return 'hello class'; }
}
trait T {
public function helloTrait(): string { return 'hello trait'; }
}
$mock = Mockery::mock(C::class, T::class);
$mock->makePartial();
\PHPStan\dumpType($mock);
echo $mock->helloTrait();
will output hello trait. Unfortunately, it is not supported by this extension (and seems phpstan also cannot create intersections with traits?) so the dumped type will be *NEVER* -> the $mock->helloTrait() actually not validated at all... :(
Mockery::mock(C::class)->helloUnknown(); // Call to an undefined method C&Mockery\MockInterface::helloUnknown()
Mockery::mock(C::class, T::class)->helloUnknown(); // nothing
If we are on Level 10 and doing something like Mockery::mock(C::class)->getSomething()->method(); we also will get "Cannot call method method() on mixed.".
- Dominant language
- PHP
- Stars
- 109
- Forks
- 25
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-mockery
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
phpstan/phpstan-mockery#77 · 1 reaction ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
phpstan/phpstan-mockery#55 · 1 comment · 1 reaction ·
-
Dependency DashboardOpen
Difficulty 4/5 3-5 days Newbie friendliness 10/100
phpstan/phpstan-mockery#46 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
phpstan/phpstan-mockery#34 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
phpstan/phpstan-mockery#18 · 1 comment · 6 reactions ·
All issues in phpstan/phpstan-mockery
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
matomo-org/device-detector#8405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 4 days