-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@mixin
above classes with __callStatic()
creates static methods
- Loading branch information
1 parent
acb9d70
commit aa38695
Showing
4 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Reflection\Mixin; | ||
|
||
use PHPStan\Reflection\ClassMemberReflection; | ||
use PHPStan\Reflection\ClassReflection; | ||
use PHPStan\Reflection\MethodReflection; | ||
use PHPStan\TrinaryLogic; | ||
use PHPStan\Type\Type; | ||
|
||
class MixinMethodReflection implements MethodReflection | ||
{ | ||
|
||
private MethodReflection $reflection; | ||
|
||
private bool $static; | ||
|
||
public function __construct(MethodReflection $reflection, bool $static) | ||
{ | ||
$this->reflection = $reflection; | ||
$this->static = $static; | ||
} | ||
|
||
public function getDeclaringClass(): ClassReflection | ||
{ | ||
return $this->reflection->getDeclaringClass(); | ||
} | ||
|
||
public function isStatic(): bool | ||
{ | ||
return $this->static; | ||
} | ||
|
||
public function isPrivate(): bool | ||
{ | ||
return $this->reflection->isPrivate(); | ||
} | ||
|
||
public function isPublic(): bool | ||
{ | ||
return $this->reflection->isPublic(); | ||
} | ||
|
||
public function getDocComment(): ?string | ||
{ | ||
return $this->reflection->getDocComment(); | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->reflection->getName(); | ||
} | ||
|
||
public function getPrototype(): ClassMemberReflection | ||
{ | ||
return $this->reflection->getPrototype(); | ||
} | ||
|
||
public function getVariants(): array | ||
{ | ||
return $this->reflection->getVariants(); | ||
} | ||
|
||
public function isDeprecated(): TrinaryLogic | ||
{ | ||
return $this->reflection->isDeprecated(); | ||
} | ||
|
||
public function getDeprecatedDescription(): ?string | ||
{ | ||
return $this->reflection->getDeprecatedDescription(); | ||
} | ||
|
||
public function isFinal(): TrinaryLogic | ||
{ | ||
return $this->reflection->isFinal(); | ||
} | ||
|
||
public function isInternal(): TrinaryLogic | ||
{ | ||
return $this->reflection->isInternal(); | ||
} | ||
|
||
public function getThrowType(): ?Type | ||
{ | ||
return $this->reflection->getThrowType(); | ||
} | ||
|
||
public function hasSideEffects(): TrinaryLogic | ||
{ | ||
return $this->reflection->hasSideEffects(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Bug3641; | ||
|
||
class Foo | ||
{ | ||
public function bar(): int | ||
{ | ||
return 5; | ||
} | ||
} | ||
|
||
/** | ||
* @mixin Foo | ||
*/ | ||
class Bar | ||
{ | ||
/** | ||
* @param mixed[] $args | ||
* @return mixed | ||
*/ | ||
public static function __callStatic(string $method, $args) | ||
{ | ||
$instance = new Foo; | ||
|
||
return $instance->$method(...$args); | ||
} | ||
} | ||
|
||
function (): void { | ||
Bar::bar(); | ||
Bar::bar(1); | ||
}; |