Blame view
public/vendor/nesbot/carbon/src/Carbon/PHPStan/MacroExtension.php
2.5 KB
86143e36f Коммит вторник |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
<?php /** * This file is part of the Carbon package. * * (c) Brian Nesbitt <brian@nesbot.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Carbon\PHPStan; use PHPStan\Reflection\Assertions; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\MethodsClassReflectionExtension; use PHPStan\Reflection\Php\PhpMethodReflectionFactory; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\TypehintHelper; /** * Class MacroExtension. * * @codeCoverageIgnore Pure PHPStan wrapper. */ final class MacroExtension implements MethodsClassReflectionExtension { /** * @var PhpMethodReflectionFactory */ protected $methodReflectionFactory; /** * @var MacroScanner */ protected $scanner; /** * Extension constructor. * * @param PhpMethodReflectionFactory $methodReflectionFactory * @param ReflectionProvider $reflectionProvider */ public function __construct( PhpMethodReflectionFactory $methodReflectionFactory, ReflectionProvider $reflectionProvider ) { $this->scanner = new MacroScanner($reflectionProvider); $this->methodReflectionFactory = $methodReflectionFactory; } /** * {@inheritdoc} */ public function hasMethod(ClassReflection $classReflection, string $methodName): bool { return $this->scanner->hasMethod($classReflection->getName(), $methodName); } /** * {@inheritdoc} */ public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection { $builtinMacro = $this->scanner->getMethod($classReflection->getName(), $methodName); $supportAssertions = class_exists(Assertions::class); return $this->methodReflectionFactory->create( $classReflection, null, $builtinMacro, $classReflection->getActiveTemplateTypeMap(), [], TypehintHelper::decideTypeFromReflection($builtinMacro->getReturnType()), null, null, $builtinMacro->isDeprecated()->yes(), $builtinMacro->isInternal(), $builtinMacro->isFinal(), $supportAssertions ? null : $builtinMacro->getDocComment(), $supportAssertions ? Assertions::createEmpty() : null, null, $builtinMacro->getDocComment(), [] ); } } |