-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: Better version of
ContainerExtension
for PHPStan and fixes.
Also disabled following Larastan extensions because we want to use `Interface` not the actual implementation (it is more safe for package) * `Larastan\Larastan\ReturnTypes\ContainerArrayAccessDynamicMethodReturnTypeExtension` * `Larastan\Larastan\ReturnTypes\ContainerMakeDynamicReturnTypeExtension`
- Loading branch information
1 parent
a342eae
commit ad9af60
Showing
12 changed files
with
183 additions
and
53 deletions.
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
45 changes: 45 additions & 0 deletions
45
dev/Larastan/ReturnTypes/ContainerArrayAccessDynamicMethodReturnTypeExtension.php
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,45 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Larastan\Larastan\ReturnTypes; | ||
|
||
use Illuminate\Contracts\Container\Container; | ||
use Override; | ||
use PhpParser\Node\Expr\MethodCall; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Reflection\MethodReflection; | ||
use PHPStan\Type\DynamicMethodReturnTypeExtension; | ||
use PHPStan\Type\Type; | ||
|
||
/** | ||
* Original class uses {@see Container::make()} it is slow and unwanted | ||
* | ||
* @internal | ||
* | ||
* @see ContainerExtension | ||
*/ | ||
class ContainerArrayAccessDynamicMethodReturnTypeExtension implements DynamicMethodReturnTypeExtension { | ||
public function __construct( | ||
private readonly string $className = Container::class, | ||
) { | ||
// empty | ||
} | ||
|
||
#[Override] | ||
public function getClass(): string { | ||
return $this->className; | ||
} | ||
|
||
#[Override] | ||
public function isMethodSupported(MethodReflection $methodReflection): bool { | ||
return false; | ||
} | ||
|
||
#[Override] | ||
public function getTypeFromMethodCall( | ||
MethodReflection $methodReflection, | ||
MethodCall $methodCall, | ||
Scope $scope, | ||
): ?Type { | ||
return null; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
dev/Larastan/ReturnTypes/ContainerMakeDynamicReturnTypeExtension.php
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,40 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Larastan\Larastan\ReturnTypes; | ||
|
||
use Illuminate\Contracts\Container\Container; | ||
use LastDragon_ru\LaraASP\Dev\PhpStan\Extensions\Container\ContainerExtension; | ||
use Override; | ||
use PhpParser\Node\Expr\MethodCall; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Reflection\MethodReflection; | ||
use PHPStan\Type\DynamicMethodReturnTypeExtension; | ||
use PHPStan\Type\Type; | ||
|
||
/** | ||
* Original class uses {@see Container::make()} it is slow and unwanted | ||
* | ||
* @internal | ||
* | ||
* @see ContainerExtension | ||
*/ | ||
class ContainerMakeDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { | ||
#[Override] | ||
public function getClass(): string { | ||
return Container::class; | ||
} | ||
|
||
#[Override] | ||
public function isMethodSupported(MethodReflection $methodReflection): bool { | ||
return false; | ||
} | ||
|
||
#[Override] | ||
public function getTypeFromMethodCall( | ||
MethodReflection $methodReflection, | ||
MethodCall $methodCall, | ||
Scope $scope, | ||
): ?Type { | ||
return null; | ||
} | ||
} |
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
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
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