Forward methods on proxied classes to the real class #4230
-
Support questionhttps://github.com/conedevelopment/bazar/blob/master/src/Proxies/Product.php class Product extends Proxy
{
public static function getProxiedContract(): string
{
return Contract::class;
}
} ...then the Proxy class will call all methods on I think this can be done with public function hasMethod(ClassReflection $classReflection, string $methodName): bool
{
if ($classReflection->getParentClass()->getName() !== Proxy::class) {
return false;
}
if (! $classReflection->hasNativeMethod('getProxiedContract')) {
return false;
}
var_dump($classReflection->getNativeReflection()->getMethod('getProxiedContract')->getName());
return false;
} Could you help me how to the get the return value of Please advise. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, you don't actually need to write an extension for this case. You can combine generics with Docs: https://phpstan.org/writing-php-code/phpdocs-basics#mixins |
Beta Was this translation helpful? Give feedback.
-
As for your other questions:
I don't think that's true, you should trust yourself more and be more confident in your abilities. Sometimes it's just a matter of starting.
It has some (https://phpstan.org/developing-extensions/extension-types), but I agree it could be improved. But it doesn't block some folks to have meaningful contributions to PHPStan itself and to the rich 3rd party extension ecosystem (https://phpstan.org/user-guide/extension-library).
Usually you can define an empty implementation, put You can also learn by inspecting some of the hundreds of extensions in PHPStan core itself and hundreds others in 3rd party packages. For example here (szepeviktor/phpstan-wordpress#30 (comment)) I feel like I told you everything you need to know to write such an extension. Please try it and let me know if you hit any blockers, I'm happy to help you. |
Beta Was this translation helpful? Give feedback.
Hi, you don't actually need to write an extension for this case. You can combine generics with
@mixin
annotation like this: https://phpstan.org/r/3d8bc66a-df60-45e1-a8b7-76120dd68441Docs: https://phpstan.org/writing-php-code/phpdocs-basics#mixins