add test for internal @meta tag. php7.4 migration

This commit is contained in:
Ivan Fedorov 2020-01-19 21:23:34 +03:00
parent afd7a81f83
commit 29235cf84c
24 changed files with 200 additions and 80 deletions

View File

@ -14,7 +14,7 @@
"inspection" "inspection"
], ],
"require-dev": { "require-dev": {
"php": "^7.1", "php": "^7.4",
"nikic/php-parser": "^4", "nikic/php-parser": "^4",
"phpdocumentor/reflection-docblock": "^4.3", "phpdocumentor/reflection-docblock": "^4.3",
"phpunit/phpunit": "^7" "phpunit/phpunit": "^7"

View File

@ -10,10 +10,10 @@ abstract class BasePHPClass extends BasePHPElement
/** /**
* @var PHPMethod[] * @var PHPMethod[]
*/ */
public $methods = []; public array $methods = [];
/** /**
* @var PHPConst[] * @var PHPConst[]
*/ */
public $constants = []; public array $constants = [];
} }

View File

@ -3,12 +3,14 @@ declare(strict_types=1);
namespace StubTests\Model; namespace StubTests\Model;
use Exception;
abstract class BasePHPElement abstract class BasePHPElement
{ {
public $name; public string $name;
public $stubBelongsToCore = false; public bool $stubBelongsToCore = false;
public $parseError; public ?Exception $parseError = null;
protected $mutedProblems = []; protected array $mutedProblems = [];
/** /**
* @param mixed $object * @param mixed $object

View File

@ -5,15 +5,13 @@ namespace StubTests\Model;
use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Class_;
use ReflectionClass; use ReflectionClass;
use ReflectionClassConstant;
use ReflectionException; use ReflectionException;
use ReflectionMethod;
use stdClass; use stdClass;
class PHPClass extends BasePHPClass class PHPClass extends BasePHPClass
{ {
public $parentClass; public $parentClass;
public $interfaces = []; public array $interfaces = [];
/** /**
* @param ReflectionClass $clazz * @param ReflectionClass $clazz
@ -30,7 +28,6 @@ class PHPClass extends BasePHPClass
} }
$this->interfaces = $reflectionClass->getInterfaceNames(); $this->interfaces = $reflectionClass->getInterfaceNames();
/**@var ReflectionMethod $method */
foreach ($reflectionClass->getMethods() as $method) { foreach ($reflectionClass->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() !== $this->name) { if ($method->getDeclaringClass()->getName() !== $this->name) {
continue; continue;
@ -38,7 +35,6 @@ class PHPClass extends BasePHPClass
$this->methods[$method->name] = (new PHPMethod())->readObjectFromReflection($method); $this->methods[$method->name] = (new PHPMethod())->readObjectFromReflection($method);
} }
/**@var ReflectionClassConstant $constant */
foreach ($reflectionClass->getReflectionConstants() as $constant) { foreach ($reflectionClass->getReflectionConstants() as $constant) {
if ($constant->getDeclaringClass()->getName() !== $this->name) { if ($constant->getDeclaringClass()->getName() !== $this->name) {
continue; continue;

View File

@ -1,22 +1,21 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
namespace StubTests\Model; namespace StubTests\Model;
use PhpParser\Node\Const_; use PhpParser\Node\Const_;
use PhpParser\Node\Expr\UnaryMinus;
use PhpParser\Node\Stmt\ClassConst; use PhpParser\Node\Stmt\ClassConst;
use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\Namespace_;
use PhpParser\NodeAbstract; use PhpParser\NodeAbstract;
use ReflectionClassConstant; use ReflectionClassConstant;
use stdClass; use stdClass;
use PhpParser\Node\Expr\UnaryMinus;
class PHPConst extends BasePHPElement class PHPConst extends BasePHPElement
{ {
use PHPDocElement; use PHPDocElement;
public $parentName; public ?string $parentName = null;
public $value; public $value;
/** /**

View File

@ -13,22 +13,24 @@ trait PHPDocElement
/** /**
* @var Tag[] * @var Tag[]
*/ */
public $links = []; public array $links = [];
/** /**
* @var Tag[] * @var Tag[]
*/ */
public $see = []; public array $see = [];
/** /**
* @var Tag[] * @var Tag[]
*/ */
public $sinceTags = []; public array $sinceTags = [];
/** /**
* @var Tag[] * @var Tag[]
*/ */
public $deprecatedTags = []; public array $deprecatedTags = [];
public bool $hasInternalMetaTag = false;
protected function collectLinks(Node $node): void protected function collectLinks(Node $node): void
{ {
@ -38,7 +40,7 @@ trait PHPDocElement
$this->links = $phpDoc->getTagsByName('link'); $this->links = $phpDoc->getTagsByName('link');
$this->see = $phpDoc->getTagsByName('see'); $this->see = $phpDoc->getTagsByName('see');
} catch (Exception $e) { } catch (Exception $e) {
$this->parseError = $e->getMessage(); $this->parseError = $e;
} }
} }
} }
@ -51,7 +53,19 @@ trait PHPDocElement
$this->sinceTags = $phpDoc->getTagsByName('since'); $this->sinceTags = $phpDoc->getTagsByName('since');
$this->deprecatedTags = $phpDoc->getTagsByName('deprecated'); $this->deprecatedTags = $phpDoc->getTagsByName('deprecated');
} catch (Exception $e) { } catch (Exception $e) {
$this->parseError = $e->getMessage(); $this->parseError = $e;
}
}
}
protected function checkIfHasInternalMetaTag(Node $node): void
{
if ($node->getDocComment() !== null) {
try {
$phpDoc = DocFactoryProvider::getDocFactory()->create($node->getDocComment()->getText());
$this->hasInternalMetaTag = $phpDoc->hasTag('meta');
} catch (Exception $e) {
$this->parseError = $e;
} }
} }
} }

View File

@ -10,7 +10,6 @@ use PhpParser\Node\FunctionLike;
use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Function_;
use ReflectionException; use ReflectionException;
use ReflectionFunction; use ReflectionFunction;
use ReflectionParameter;
use stdClass; use stdClass;
use StubTests\Parsers\DocFactoryProvider; use StubTests\Parsers\DocFactoryProvider;
@ -21,15 +20,15 @@ class PHPFunction extends BasePHPElement
/** /**
* @var boolean $is_deprecated * @var boolean $is_deprecated
*/ */
public $is_deprecated; public bool $is_deprecated;
/** /**
* @var PHPParameter[] * @var PHPParameter[]
*/ */
public $parameters = []; public array $parameters = [];
/** /**
* @var Type $returnTag * @var Type $returnTag
*/ */
public $returnTag; public ?Type $returnTag = null;
/** /**
* @param ReflectionFunction $function * @param ReflectionFunction $function
@ -41,7 +40,6 @@ class PHPFunction extends BasePHPElement
$reflectionFunction = new ReflectionFunction($function); $reflectionFunction = new ReflectionFunction($function);
$this->name = $reflectionFunction->name; $this->name = $reflectionFunction->name;
$this->is_deprecated = $reflectionFunction->isDeprecated(); $this->is_deprecated = $reflectionFunction->isDeprecated();
/**@var ReflectionParameter $parameter */
foreach ($reflectionFunction->getParameters() as $parameter) { foreach ($reflectionFunction->getParameters() as $parameter) {
$this->parameters[] = (new PHPParameter())->readObjectFromReflection($parameter); $this->parameters[] = (new PHPParameter())->readObjectFromReflection($parameter);
} }
@ -66,6 +64,7 @@ class PHPFunction extends BasePHPElement
$this->collectLinks($node); $this->collectLinks($node);
$this->collectSinceDeprecatedVersions($node); $this->collectSinceDeprecatedVersions($node);
$this->checkIfHasInternalMetaTag($node);
$this->checkDeprecationTag($node); $this->checkDeprecationTag($node);
$this->checkReturnTag($node); $this->checkReturnTag($node);
return $this; return $this;
@ -82,7 +81,7 @@ class PHPFunction extends BasePHPElement
$this->is_deprecated = true; $this->is_deprecated = true;
} }
} catch (Exception $e) { } catch (Exception $e) {
$this->parseError = $e->getMessage(); $this->parseError = $e;
} }
} }
} }
@ -94,10 +93,10 @@ class PHPFunction extends BasePHPElement
$phpDoc = DocFactoryProvider::getDocFactory()->create($node->getDocComment()->getText()); $phpDoc = DocFactoryProvider::getDocFactory()->create($node->getDocComment()->getText());
$parsedReturnTag = $phpDoc->getTagsByName('return'); $parsedReturnTag = $phpDoc->getTagsByName('return');
if (!empty($parsedReturnTag) && $parsedReturnTag[0] instanceof Return_) { if (!empty($parsedReturnTag) && $parsedReturnTag[0] instanceof Return_) {
$this->returnTag = $parsedReturnTag[0]->getType() . ''; $this->returnTag = $parsedReturnTag[0]->getType();
} }
} catch (Exception $e) { } catch (Exception $e) {
$this->parseError = $e->getMessage(); $this->parseError = $e;
} }
} }
} }

View File

@ -5,14 +5,12 @@ namespace StubTests\Model;
use PhpParser\Node\Stmt\Interface_; use PhpParser\Node\Stmt\Interface_;
use ReflectionClass; use ReflectionClass;
use ReflectionClassConstant;
use ReflectionException; use ReflectionException;
use ReflectionMethod;
use stdClass; use stdClass;
class PHPInterface extends BasePHPClass class PHPInterface extends BasePHPClass
{ {
public $parentInterfaces = []; public array $parentInterfaces = [];
/** /**
* @param ReflectionClass $interface * @param ReflectionClass $interface
@ -23,7 +21,6 @@ class PHPInterface extends BasePHPClass
try { try {
$reflectionInterface = new ReflectionClass($interface); $reflectionInterface = new ReflectionClass($interface);
$this->name = $reflectionInterface->getName(); $this->name = $reflectionInterface->getName();
/**@var ReflectionMethod $method */
foreach ($reflectionInterface->getMethods() as $method) { foreach ($reflectionInterface->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() !== $this->name) { if ($method->getDeclaringClass()->getName() !== $this->name) {
continue; continue;
@ -31,7 +28,6 @@ class PHPInterface extends BasePHPClass
$this->methods[$method->name] = (new PHPMethod())->readObjectFromReflection($method); $this->methods[$method->name] = (new PHPMethod())->readObjectFromReflection($method);
} }
$this->parentInterfaces = $reflectionInterface->getInterfaceNames(); $this->parentInterfaces = $reflectionInterface->getInterfaceNames();
/**@var ReflectionClassConstant $constant */
foreach ($reflectionInterface->getReflectionConstants() as $constant) { foreach ($reflectionInterface->getReflectionConstants() as $constant) {
if ($constant->getDeclaringClass()->getName() !== $this->name) { if ($constant->getDeclaringClass()->getName() !== $this->name) {
continue; continue;

View File

@ -4,18 +4,18 @@ declare(strict_types=1);
namespace StubTests\Model; namespace StubTests\Model;
use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\ClassMethod;
use ReflectionParameter; use ReflectionMethod;
use stdClass; use stdClass;
class PHPMethod extends PHPFunction class PHPMethod extends PHPFunction
{ {
public $access; public string $access;
public $is_static; public bool $is_static;
public $is_final; public bool $is_final;
public $parentName; public string $parentName;
/** /**
* @param \ReflectionMethod $method * @param ReflectionMethod $method
* @return $this * @return $this
*/ */
public function readObjectFromReflection($method) public function readObjectFromReflection($method)
@ -23,7 +23,6 @@ class PHPMethod extends PHPFunction
$this->name = $method->name; $this->name = $method->name;
$this->is_static = $method->isStatic(); $this->is_static = $method->isStatic();
$this->is_final = $method->isFinal(); $this->is_final = $method->isFinal();
/**@var ReflectionParameter $parameter */
foreach ($method->getParameters() as $parameter) { foreach ($method->getParameters() as $parameter) {
$this->parameters[] = (new PHPParameter())->readObjectFromReflection($parameter); $this->parameters[] = (new PHPParameter())->readObjectFromReflection($parameter);
} }
@ -50,6 +49,7 @@ class PHPMethod extends PHPFunction
$this->collectLinks($node); $this->collectLinks($node);
$this->collectSinceDeprecatedVersions($node); $this->collectSinceDeprecatedVersions($node);
$this->checkIfHasInternalMetaTag($node);
$this->checkDeprecationTag($node); $this->checkDeprecationTag($node);
$this->checkReturnTag($node); $this->checkReturnTag($node);

View File

@ -4,14 +4,15 @@ declare(strict_types=1);
namespace StubTests\Model; namespace StubTests\Model;
use PhpParser\Node\Param; use PhpParser\Node\Param;
use ReflectionNamedType;
use ReflectionParameter; use ReflectionParameter;
use stdClass; use stdClass;
class PHPParameter extends BasePHPElement class PHPParameter extends BasePHPElement
{ {
public $type = ''; public string $type = '';
public $is_vararg; public bool $is_vararg;
public $is_passed_by_ref; public bool $is_passed_by_ref;
/** /**
* @param ReflectionParameter $parameter * @param ReflectionParameter $parameter
@ -20,8 +21,9 @@ class PHPParameter extends BasePHPElement
public function readObjectFromReflection($parameter): self public function readObjectFromReflection($parameter): self
{ {
$this->name = $parameter->name; $this->name = $parameter->name;
if (!empty($parameter->getType())) { $parameterType = $parameter->getType();
$this->type = $parameter->getType()->getName(); if (!empty($parameterType) && $parameterType instanceof ReflectionNamedType) {
$this->type = $parameterType->getName();
} }
$this->is_vararg = $parameter->isVariadic(); $this->is_vararg = $parameter->isVariadic();
$this->is_passed_by_ref = $parameter->isPassedByReference(); $this->is_passed_by_ref = $parameter->isPassedByReference();

View File

@ -3,6 +3,7 @@ declare(strict_types=1);
namespace StubTests\Model; namespace StubTests\Model;
use Exception;
use function array_key_exists; use function array_key_exists;
class StubsContainer class StubsContainer
@ -10,19 +11,19 @@ class StubsContainer
/** /**
* @var PHPConst[] * @var PHPConst[]
*/ */
private $constants = []; private array $constants = [];
/** /**
* @var PHPFunction[] * @var PHPFunction[]
*/ */
private $functions = []; private array $functions = [];
/** /**
* @var PHPClass[] * @var PHPClass[]
*/ */
private $classes = []; private array $classes = [];
/** /**
* @var PHPInterface[] * @var PHPInterface[]
*/ */
private $interfaces = []; private array $interfaces = [];
/** /**
* @return PHPConst[] * @return PHPConst[]
@ -34,11 +35,12 @@ class StubsContainer
/** /**
* @param PHPConst $constant * @param PHPConst $constant
* @throws Exception
*/ */
public function addConstant(PHPConst $constant): void public function addConstant(PHPConst $constant): void
{ {
if (array_key_exists($constant->name, $this->constants)) { if (array_key_exists($constant->name, $this->constants)) {
throw new \Exception($constant->name . " is already defined in stubs"); throw new Exception($constant->name . " is already defined in stubs");
} }
$this->constants[$constant->name] = $constant; $this->constants[$constant->name] = $constant;
} }
@ -61,7 +63,7 @@ class StubsContainer
/** /**
* @param string $name * @param string $name
* @return PHPClass | null * @return PHPClass|null
*/ */
public function getClass(string $name): ?PHPClass public function getClass(string $name): ?PHPClass
{ {
@ -82,18 +84,19 @@ class StubsContainer
/** /**
* @param PHPClass $class * @param PHPClass $class
* @throws Exception
*/ */
public function addClass(PHPClass $class): void public function addClass(PHPClass $class): void
{ {
if (array_key_exists($class->name, $this->classes)) { if (array_key_exists($class->name, $this->classes)) {
throw new \Exception($class->name . " is already defined in stubs"); throw new Exception($class->name . " is already defined in stubs");
} }
$this->classes[$class->name] = $class; $this->classes[$class->name] = $class;
} }
/** /**
* @param string $name * @param string $name
* @return PHPInterface | null * @return PHPInterface|null
*/ */
public function getInterface(string $name): ?PHPInterface public function getInterface(string $name): ?PHPInterface
{ {
@ -114,11 +117,12 @@ class StubsContainer
/** /**
* @param PHPInterface $interface * @param PHPInterface $interface
* @throws Exception
*/ */
public function addInterface(PHPInterface $interface): void public function addInterface(PHPInterface $interface): void
{ {
if (array_key_exists($interface->name, $this->interfaces)) { if (array_key_exists($interface->name, $this->interfaces)) {
throw new \Exception($interface->name . " is already defined in stubs"); throw new Exception($interface->name . " is already defined in stubs");
} }
$this->interfaces[$interface->name] = $interface; $this->interfaces[$interface->name] = $interface;
} }

View File

@ -7,7 +7,7 @@ use phpDocumentor\Reflection\DocBlockFactory;
class DocFactoryProvider class DocFactoryProvider
{ {
private static $docFactory; private static ?DocBlockFactory $docFactory = null;
public static function getDocFactory(): DocBlockFactory public static function getDocFactory(): DocBlockFactory
{ {

View File

@ -8,16 +8,16 @@ class ExpectedFunctionArgumentsInfo
/** /**
* @var Expr|null * @var Expr|null
*/ */
private $functionReference; private ?Expr $functionReference;
/** /**
* @var Expr[] * @var Expr[]
*/ */
private $expectedArguments; private array $expectedArguments;
/** /**
* @var int * @var int
*/ */
private $index; private int $index;
/** /**
* ExpectedFunctionArgumentsInfo constructor. * ExpectedFunctionArgumentsInfo constructor.

View File

@ -19,11 +19,11 @@ class MetaExpectedArgumentsCollector extends NodeVisitorAbstract
/** /**
* @var ExpectedFunctionArgumentsInfo[] * @var ExpectedFunctionArgumentsInfo[]
*/ */
private $expectedArgumentsInfos; private array $expectedArgumentsInfos;
/** /**
* @var String[] * @var String[]
*/ */
private $registeredArgumentsSet; private array $registeredArgumentsSet;
public function __construct() public function __construct()
{ {

View File

@ -21,7 +21,7 @@ use UnexpectedValueException;
class StubParser class StubParser
{ {
private static $stubs; private static ?StubsContainer $stubs = null;
public static function getPhpStormStubs(): StubsContainer public static function getPhpStormStubs(): StubsContainer
{ {
@ -30,7 +30,7 @@ class StubParser
$coreStubVisitor = new CoreStubASTVisitor(self::$stubs); $coreStubVisitor = new CoreStubASTVisitor(self::$stubs);
/** @noinspection PhpUnhandledExceptionInspection */ /** @noinspection PhpUnhandledExceptionInspection */
self::processStubs($visitor, $coreStubVisitor, function ($file) { self::processStubs($visitor, $coreStubVisitor, function ($file) {
return true; return $file->getFilename() !== '.phpstorm.meta.php';
}); });
foreach (self::$stubs->getInterfaces() as $interface) { foreach (self::$stubs->getInterfaces() as $interface) {
$interface->parentInterfaces = $visitor->combineParentInterfaces($interface); $interface->parentInterfaces = $visitor->combineParentInterfaces($interface);

View File

@ -22,8 +22,8 @@ use StubTests\Parsers\Utils;
class ASTVisitor extends NodeVisitorAbstract class ASTVisitor extends NodeVisitorAbstract
{ {
protected $stubs; protected StubsContainer $stubs;
protected $isStubCore; protected bool $isStubCore;
public function __construct(StubsContainer $stubs) public function __construct(StubsContainer $stubs)
{ {

View File

@ -1,9 +1,8 @@
<?php <?php
declare(strict_types=1);
namespace StubTests\Parsers\Visitors; namespace StubTests\Parsers\Visitors;
use StubTests\Model\StubsContainer; use StubTests\Model\StubsContainer;
class CoreStubASTVisitor extends ASTVisitor class CoreStubASTVisitor extends ASTVisitor
@ -13,4 +12,4 @@ class CoreStubASTVisitor extends ASTVisitor
parent::__construct($stubs); parent::__construct($stubs);
$this->isStubCore = true; $this->isStubCore = true;
} }
} }

View File

@ -0,0 +1,53 @@
<?php
namespace StubTests\Parsers\Visitors;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\NodeVisitorAbstract;
use RuntimeException;
use SplFileInfo;
use StubTests\Parsers\StubParser;
class MetaOverrideFunctionsParser extends NodeVisitorAbstract
{
private const OVERRIDE_FUNCTION = 'override';
/**
* @var string[]
*/
public array $overridenFunctions;
public function __construct()
{
$this->overridenFunctions = [];
StubParser::processStubs($this, null, function (SplFileInfo $file) {
return $file->getFilename() === '.phpstorm.meta.php';
});
}
public function enterNode(Node $node)
{
if ($node instanceof Node\Expr\FuncCall) {
if ((string)$node->name === self::OVERRIDE_FUNCTION) {
$args = $node->args;
if (count($args) < 2) {
throw new RuntimeException('Expected at least 2 arguments for override call');
}
$this->overridenFunctions[] = $this->getOverrideFunctionName($args[0]);
}
}
}
private function getOverrideFunctionName($param)
{
$paramValue = $param->value;
$targetFunction = null;
if ($paramValue instanceof Expr\StaticCall) {
$targetFunction = $paramValue->class . "::" . $paramValue->name;
} else {
$targetFunction = (string)$paramValue->name;
}
return $targetFunction;
}
}

View File

@ -11,7 +11,10 @@ use PhpParser\NodeVisitorAbstract;
*/ */
class ParentConnector extends NodeVisitorAbstract class ParentConnector extends NodeVisitorAbstract
{ {
private $stack; /**
* @var Node[]
*/
private array $stack;
public function beforeTraverse(array $nodes) public function beforeTraverse(array $nodes)
{ {

View File

@ -7,7 +7,6 @@ use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\ConstFetch; use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_; use PhpParser\Node\Scalar\String_;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use StubTests\Model\PHPConst; use StubTests\Model\PHPConst;
@ -21,14 +20,14 @@ class StubsMetaExpectedArgumentsTest extends TestCase
/** /**
* @var ExpectedFunctionArgumentsInfo[] * @var ExpectedFunctionArgumentsInfo[]
*/ */
private static $expectedArguments; private static array $expectedArguments;
/** /**
* @var String[] * @var String[]
*/ */
private static $registeredArgumentsSet; private static array $registeredArgumentsSet;
private static $functionsFqns; private static $functionsFqns;
private static $methodsFqns; private static array $methodsFqns;
private static $constantsFqns; private static array $constantsFqns;
public static function setUpBeforeClass(): void public static function setUpBeforeClass(): void
{ {

View File

@ -0,0 +1,53 @@
<?php
namespace StubTests;
use PHPUnit\Framework\TestCase;
use StubTests\Parsers\Visitors\MetaOverrideFunctionsParser;
use StubTests\TestData\Providers\PhpStormStubsSingleton;
class StubsMetaInternalTagTest extends TestCase
{
/**
* @var array
*/
private static array $overridenFunctionsInMeta;
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
self::$overridenFunctionsInMeta = (new MetaOverrideFunctionsParser())->overridenFunctions;
}
public function testFunctionInternalMetaTag(): void
{
$functions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions();
foreach ($functions as $function) {
if ($function->hasInternalMetaTag) {
$this->checkInternalMetaInOverride($function->name);
}
}
}
public function testMethodsInternalMetaTag(): void
{
foreach (PhpStormStubsSingleton::getPhpStormStubs()->getClasses() as $className => $class) {
foreach ($class->methods as $methodName => $method) {
if ($method->hasInternalMetaTag) {
$this->checkInternalMetaInOverride($className . "::" . $methodName);
} else {
$this->expectNotToPerformAssertions();
}
}
}
}
/**
* @param string $elementName
*/
private function checkInternalMetaInOverride(string $elementName): void
{
self::assertContains($elementName, self::$overridenFunctionsInMeta,
"$elementName contains @meta in phpdoc but isn't added to 'override()' functions in meta file");
}
}

View File

@ -1,14 +1,13 @@
<?php <?php
declare(strict_types=1);
namespace StubTests\TestData\Providers; namespace StubTests\TestData\Providers;
use StubTests\Parsers\Utils; use StubTests\Parsers\Utils;
class PhpCoreStubsProvider class PhpCoreStubsProvider
{ {
private static $StubDirectoryMap = [ private static array $StubDirectoryMap = [
'CORE' => [ 'CORE' => [
'Core', 'Core',
'date', 'date',
@ -153,4 +152,4 @@ class PhpCoreStubsProvider
return Utils::flattenArray($coreStubs, false); return Utils::flattenArray($coreStubs, false);
} }
} }

View File

@ -1,4 +1,6 @@
<?php <?php
declare(strict_types=1);
namespace StubTests\TestData\Providers; namespace StubTests\TestData\Providers;
use StubTests\Model\StubsContainer; use StubTests\Model\StubsContainer;
@ -6,7 +8,7 @@ use StubTests\Parsers\StubParser;
class PhpStormStubsSingleton class PhpStormStubsSingleton
{ {
private static $phpstormStubs; private static ?StubsContainer $phpstormStubs = null;
public static function getPhpStormStubs(): StubsContainer public static function getPhpStormStubs(): StubsContainer
{ {

View File

@ -43,7 +43,7 @@ class ReflectionTestDataProviders
class ReflectionStubsSingleton class ReflectionStubsSingleton
{ {
private static $reflectionStubs; private static ?StubsContainer $reflectionStubs = null;
public static function getReflectionStubs(): StubsContainer public static function getReflectionStubs(): StubsContainer
{ {