Fixes for notes in PR #468
This commit is contained in:
parent
548ecc8d3a
commit
2d60e980b4
|
@ -14,6 +14,7 @@
|
||||||
"inspection"
|
"inspection"
|
||||||
],
|
],
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"php": "^7.1",
|
||||||
"nikic/php-parser": "v4.0.1",
|
"nikic/php-parser": "v4.0.1",
|
||||||
"phpdocumentor/reflection-docblock": "^4.3",
|
"phpdocumentor/reflection-docblock": "^4.3",
|
||||||
"phpunit/phpunit": "7.1.4"
|
"phpunit/phpunit": "7.1.4"
|
||||||
|
|
|
@ -10,7 +10,7 @@ abstract class BasePHPElement
|
||||||
{
|
{
|
||||||
public $name;
|
public $name;
|
||||||
public $parseError;
|
public $parseError;
|
||||||
protected $relatedStubProblems = [];
|
protected $mutedProblems = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $object
|
* @param mixed $object
|
||||||
|
@ -26,7 +26,7 @@ abstract class BasePHPElement
|
||||||
*/
|
*/
|
||||||
abstract public function readObjectFromStubNode($node);
|
abstract public function readObjectFromStubNode($node);
|
||||||
|
|
||||||
abstract public function readStubProblems($jsonData);
|
abstract public function readMutedProblems($jsonData);
|
||||||
|
|
||||||
protected function getConstantFQN(NodeAbstract $node, string $nodeName): string
|
protected function getConstantFQN(NodeAbstract $node, string $nodeName): string
|
||||||
{
|
{
|
||||||
|
@ -52,8 +52,8 @@ abstract class BasePHPElement
|
||||||
return rtrim($fqn, "\\");
|
return rtrim($fqn, "\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function relatedStubHasProblem($stubProblemType): bool
|
public function hasMutedProblem($stubProblemType): bool
|
||||||
{
|
{
|
||||||
return in_array($stubProblemType, $this->relatedStubProblems, true);
|
return in_array($stubProblemType, $this->mutedProblems, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ class PHPClass extends BasePHPClass
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readStubProblems($jsonData): void
|
public function readMutedProblems($jsonData): void
|
||||||
{
|
{
|
||||||
/**@var stdClass $class */
|
/**@var stdClass $class */
|
||||||
foreach ($jsonData as $class) {
|
foreach ($jsonData as $class) {
|
||||||
|
@ -89,28 +89,28 @@ class PHPClass extends BasePHPClass
|
||||||
foreach ($class->problems as $problem) {
|
foreach ($class->problems as $problem) {
|
||||||
switch ($problem) {
|
switch ($problem) {
|
||||||
case 'wrong parent':
|
case 'wrong parent':
|
||||||
$this->relatedStubProblems[] = StubProblemType::WRONG_PARENT;
|
$this->mutedProblems[] = StubProblemType::WRONG_PARENT;
|
||||||
break;
|
break;
|
||||||
case 'wrong interface':
|
case 'wrong interface':
|
||||||
$this->relatedStubProblems[] = StubProblemType::WRONG_INTERFACE;
|
$this->mutedProblems[] = StubProblemType::WRONG_INTERFACE;
|
||||||
break;
|
break;
|
||||||
case 'missing class':
|
case 'missing class':
|
||||||
$this->relatedStubProblems[] = StubProblemType::STUB_IS_MISSED;
|
$this->mutedProblems[] = StubProblemType::STUB_IS_MISSED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->relatedStubProblems[] = -1;
|
$this->mutedProblems[] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($class->methods)) {
|
if (!empty($class->methods)) {
|
||||||
foreach ($this->methods as $method) {
|
foreach ($this->methods as $method) {
|
||||||
$method->readStubProblems($class->methods);
|
$method->readMutedProblems($class->methods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($class->constants)) {
|
if (!empty($class->constants)) {
|
||||||
foreach ($this->constants as $constant) {
|
foreach ($this->constants as $constant) {
|
||||||
$constant->readStubProblems($class->constants);
|
$constant->readMutedProblems($class->constants);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -55,7 +55,7 @@ class PHPConst extends BasePHPElement
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readStubProblems($jsonData): void
|
public function readMutedProblems($jsonData): void
|
||||||
{
|
{
|
||||||
/**@var stdClass $constant */
|
/**@var stdClass $constant */
|
||||||
foreach ($jsonData as $constant) {
|
foreach ($jsonData as $constant) {
|
||||||
|
@ -64,13 +64,13 @@ class PHPConst extends BasePHPElement
|
||||||
foreach ($constant->problems as $problem) {
|
foreach ($constant->problems as $problem) {
|
||||||
switch ($problem) {
|
switch ($problem) {
|
||||||
case 'wrong value':
|
case 'wrong value':
|
||||||
$this->relatedStubProblems[] = StubProblemType::WRONG_CONSTANT_VALUE;
|
$this->mutedProblems[] = StubProblemType::WRONG_CONSTANT_VALUE;
|
||||||
break;
|
break;
|
||||||
case 'missing constant':
|
case 'missing constant':
|
||||||
$this->relatedStubProblems[] = StubProblemType::STUB_IS_MISSED;
|
$this->mutedProblems[] = StubProblemType::STUB_IS_MISSED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->relatedStubProblems[] = -1;
|
$this->mutedProblems[] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ class PHPFunction extends BasePHPElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readStubProblems($jsonData): void
|
public function readMutedProblems($jsonData): void
|
||||||
{
|
{
|
||||||
/**@var stdClass $function */
|
/**@var stdClass $function */
|
||||||
foreach ($jsonData as $function) {
|
foreach ($jsonData as $function) {
|
||||||
|
@ -110,16 +110,16 @@ class PHPFunction extends BasePHPElement
|
||||||
foreach ($function->problems as $problem) {
|
foreach ($function->problems as $problem) {
|
||||||
switch ($problem) {
|
switch ($problem) {
|
||||||
case 'parameter mismatch':
|
case 'parameter mismatch':
|
||||||
$this->relatedStubProblems[] = StubProblemType::FUNCTION_PARAMETER_MISMATCH;
|
$this->mutedProblems[] = StubProblemType::FUNCTION_PARAMETER_MISMATCH;
|
||||||
break;
|
break;
|
||||||
case 'missing function':
|
case 'missing function':
|
||||||
$this->relatedStubProblems[] = StubProblemType::STUB_IS_MISSED;
|
$this->mutedProblems[] = StubProblemType::STUB_IS_MISSED;
|
||||||
break;
|
break;
|
||||||
case 'deprecated function':
|
case 'deprecated function':
|
||||||
$this->relatedStubProblems[] = StubProblemType::FUNCTION_IS_DEPRECATED;
|
$this->mutedProblems[] = StubProblemType::FUNCTION_IS_DEPRECATED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->relatedStubProblems[] = -1;
|
$this->mutedProblems[] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class PHPInterface extends BasePHPClass
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readStubProblems($jsonData): void
|
public function readMutedProblems($jsonData): void
|
||||||
{
|
{
|
||||||
/**@var stdClass $interface */
|
/**@var stdClass $interface */
|
||||||
foreach ($jsonData as $interface) {
|
foreach ($jsonData as $interface) {
|
||||||
|
@ -70,25 +70,25 @@ class PHPInterface extends BasePHPClass
|
||||||
foreach ($interface->problems as $problem) {
|
foreach ($interface->problems as $problem) {
|
||||||
switch ($problem) {
|
switch ($problem) {
|
||||||
case 'wrong parent':
|
case 'wrong parent':
|
||||||
$this->relatedStubProblems[] = StubProblemType::WRONG_PARENT;
|
$this->mutedProblems[] = StubProblemType::WRONG_PARENT;
|
||||||
break;
|
break;
|
||||||
case 'missing interface':
|
case 'missing interface':
|
||||||
$this->relatedStubProblems[] = StubProblemType::STUB_IS_MISSED;
|
$this->mutedProblems[] = StubProblemType::STUB_IS_MISSED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->relatedStubProblems[] = -1;
|
$this->mutedProblems[] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($interface->methods)) {
|
if (!empty($interface->methods)) {
|
||||||
foreach ($this->methods as $method) {
|
foreach ($this->methods as $method) {
|
||||||
$method->readStubProblems($interface->methods);
|
$method->readMutedProblems($interface->methods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($interface->constants)) {
|
if (!empty($interface->constants)) {
|
||||||
foreach ($this->constants as $constant) {
|
foreach ($this->constants as $constant) {
|
||||||
$constant->readStubProblems($interface->constants);
|
$constant->readMutedProblems($interface->constants);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -71,7 +71,7 @@ class PHPMethod extends PHPFunction
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readStubProblems($jsonData): void
|
public function readMutedProblems($jsonData): void
|
||||||
{
|
{
|
||||||
/**@var stdClass $method */
|
/**@var stdClass $method */
|
||||||
foreach ($jsonData as $method) {
|
foreach ($jsonData as $method) {
|
||||||
|
@ -80,16 +80,16 @@ class PHPMethod extends PHPFunction
|
||||||
foreach ($method->problems as $problem) {
|
foreach ($method->problems as $problem) {
|
||||||
switch ($problem) {
|
switch ($problem) {
|
||||||
case 'parameter mismatch':
|
case 'parameter mismatch':
|
||||||
$this->relatedStubProblems[] = StubProblemType::FUNCTION_PARAMETER_MISMATCH;
|
$this->mutedProblems[] = StubProblemType::FUNCTION_PARAMETER_MISMATCH;
|
||||||
break;
|
break;
|
||||||
case 'missing method':
|
case 'missing method':
|
||||||
$this->relatedStubProblems[] = StubProblemType::STUB_IS_MISSED;
|
$this->mutedProblems[] = StubProblemType::STUB_IS_MISSED;
|
||||||
break;
|
break;
|
||||||
case 'deprecated method':
|
case 'deprecated method':
|
||||||
$this->relatedStubProblems[] = StubProblemType::FUNCTION_IS_DEPRECATED;
|
$this->mutedProblems[] = StubProblemType::FUNCTION_IS_DEPRECATED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->relatedStubProblems[] = -1;
|
$this->mutedProblems[] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class PHPParameter extends BasePHPElement
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readStubProblems($jsonData): void
|
public function readMutedProblems($jsonData): void
|
||||||
{
|
{
|
||||||
/**@var stdClass $parameter */
|
/**@var stdClass $parameter */
|
||||||
foreach ($jsonData as $parameter) {
|
foreach ($jsonData as $parameter) {
|
||||||
|
@ -58,16 +58,16 @@ class PHPParameter extends BasePHPElement
|
||||||
foreach ($parameter->problems as $problem) {
|
foreach ($parameter->problems as $problem) {
|
||||||
switch ($problem) {
|
switch ($problem) {
|
||||||
case 'parameter type mismatch':
|
case 'parameter type mismatch':
|
||||||
$this->relatedStubProblems[] = StubProblemType::PARAMETER_TYPE_MISMATCH;
|
$this->mutedProblems[] = StubProblemType::PARAMETER_TYPE_MISMATCH;
|
||||||
break;
|
break;
|
||||||
case 'parameter reference':
|
case 'parameter reference':
|
||||||
$this->relatedStubProblems[] = StubProblemType::PARAMETER_REFERENCE;
|
$this->mutedProblems[] = StubProblemType::PARAMETER_REFERENCE;
|
||||||
break;
|
break;
|
||||||
case 'parameter vararg':
|
case 'parameter vararg':
|
||||||
$this->relatedStubProblems[] = StubProblemType::PARAMETER_VARARG;
|
$this->mutedProblems[] = StubProblemType::PARAMETER_VARARG;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->relatedStubProblems[] = -1;
|
$this->mutedProblems[] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,14 @@ class PHPReflectionParser
|
||||||
$const_groups = Utils::flattenArray($const_groups, true);
|
$const_groups = Utils::flattenArray($const_groups, true);
|
||||||
foreach ($const_groups as $name => $value) {
|
foreach ($const_groups as $name => $value) {
|
||||||
$constant = (new PHPDefineConstant())->readObjectFromReflection([$name, $value]);
|
$constant = (new PHPDefineConstant())->readObjectFromReflection([$name, $value]);
|
||||||
$constant->readStubProblems($jsonData->constants);
|
$constant->readMutedProblems($jsonData->constants);
|
||||||
$stubs->addConstant($constant);
|
$stubs->addConstant($constant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@var ReflectionFunction $function */
|
/**@var ReflectionFunction $function */
|
||||||
foreach (get_defined_functions()['internal'] as $function) {
|
foreach (get_defined_functions()['internal'] as $function) {
|
||||||
$phpFunction = (new PHPFunction())->readObjectFromReflection($function);
|
$phpFunction = (new PHPFunction())->readObjectFromReflection($function);
|
||||||
$phpFunction->readStubProblems($jsonData->functions);
|
$phpFunction->readMutedProblems($jsonData->functions);
|
||||||
$stubs->addFunction($phpFunction);
|
$stubs->addFunction($phpFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class PHPReflectionParser
|
||||||
$reflectionClass = new ReflectionClass($clazz);
|
$reflectionClass = new ReflectionClass($clazz);
|
||||||
if ($reflectionClass->isInternal()) {
|
if ($reflectionClass->isInternal()) {
|
||||||
$class = (new PHPClass())->readObjectFromReflection($clazz);
|
$class = (new PHPClass())->readObjectFromReflection($clazz);
|
||||||
$class->readStubProblems($jsonData->classes);
|
$class->readMutedProblems($jsonData->classes);
|
||||||
$stubs->addClass($class);
|
$stubs->addClass($class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class PHPReflectionParser
|
||||||
$reflectionInterface = new ReflectionClass($interface);
|
$reflectionInterface = new ReflectionClass($interface);
|
||||||
if ($reflectionInterface->isInternal()) {
|
if ($reflectionInterface->isInternal()) {
|
||||||
$phpInterface = (new PHPInterface())->readObjectFromReflection($interface);
|
$phpInterface = (new PHPInterface())->readObjectFromReflection($interface);
|
||||||
$phpInterface->readStubProblems($jsonData->interfaces);
|
$phpInterface->readMutedProblems($jsonData->interfaces);
|
||||||
$stubs->addInterface($phpInterface);
|
$stubs->addInterface($phpInterface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,11 @@ class StubParser
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($stubs->getInterfaces() as $interface) {
|
foreach ($stubs->getInterfaces() as $interface) {
|
||||||
$stubs->getInterface($interface->name)->parentInterfaces = $visitor->combineParentInterfaces($interface);
|
$interface->parentInterfaces = $visitor->combineParentInterfaces($interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($stubs->getClasses() as $class) {
|
foreach ($stubs->getClasses() as $class) {
|
||||||
$stubs->getClass($class->name)->interfaces =
|
$class->interfaces =
|
||||||
Utils::flattenArray($visitor->combineImplementedInterfaces($class), false);
|
Utils::flattenArray($visitor->combineImplementedInterfaces($class), false);
|
||||||
}
|
}
|
||||||
return $stubs;
|
return $stubs;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace StubTests;
|
namespace StubTests;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Link;
|
use phpDocumentor\Reflection\DocBlock\Tags\Link;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url;
|
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||||
|
@ -11,6 +10,7 @@ use SebastianBergmann\RecursionContext\InvalidArgumentException;
|
||||||
use StubTests\Model\BasePHPClass;
|
use StubTests\Model\BasePHPClass;
|
||||||
use StubTests\Model\PHPClass;
|
use StubTests\Model\PHPClass;
|
||||||
use StubTests\Model\PHPConst;
|
use StubTests\Model\PHPConst;
|
||||||
|
use StubTests\Model\PHPDocElement;
|
||||||
use StubTests\Model\PHPFunction;
|
use StubTests\Model\PHPFunction;
|
||||||
use StubTests\Model\PHPInterface;
|
use StubTests\Model\PHPInterface;
|
||||||
use StubTests\Model\PHPMethod;
|
use StubTests\Model\PHPMethod;
|
||||||
|
@ -29,7 +29,7 @@ class TestStubs extends TestCase
|
||||||
$constantName = $constant->name;
|
$constantName = $constant->name;
|
||||||
$constantValue = $constant->value;
|
$constantValue = $constant->value;
|
||||||
$stubConstants = PhpStormStubsSingleton::getPhpStormStubs()->getConstants();
|
$stubConstants = PhpStormStubsSingleton::getPhpStormStubs()->getConstants();
|
||||||
if ($constant->relatedStubHasProblem(StubProblemType::STUB_IS_MISSED)) {
|
if ($constant->hasMutedProblem(StubProblemType::STUB_IS_MISSED)) {
|
||||||
static::markTestSkipped('constant is excluded');
|
static::markTestSkipped('constant is excluded');
|
||||||
}
|
}
|
||||||
static::assertArrayHasKey(
|
static::assertArrayHasKey(
|
||||||
|
@ -48,9 +48,8 @@ class TestStubs extends TestCase
|
||||||
{
|
{
|
||||||
$constantName = $constant->name;
|
$constantName = $constant->name;
|
||||||
$constantValue = $constant->value;
|
$constantValue = $constant->value;
|
||||||
/**@var PHPConst[] $stubConstants */
|
|
||||||
$stubConstants = PhpStormStubsSingleton::getPhpStormStubs()->getConstants();
|
$stubConstants = PhpStormStubsSingleton::getPhpStormStubs()->getConstants();
|
||||||
if ($constant->relatedStubHasProblem(StubProblemType::WRONG_CONSTANT_VALUE)) {
|
if ($constant->hasMutedProblem(StubProblemType::WRONG_CONSTANT_VALUE)) {
|
||||||
static::markTestSkipped('constant is excluded');
|
static::markTestSkipped('constant is excluded');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,19 +71,18 @@ class TestStubs extends TestCase
|
||||||
$functionName = $function->name;
|
$functionName = $function->name;
|
||||||
$stubFunctions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions();
|
$stubFunctions = PhpStormStubsSingleton::getPhpStormStubs()->getFunctions();
|
||||||
$params = self::getParameterRepresentation($function);
|
$params = self::getParameterRepresentation($function);
|
||||||
if ($function->relatedStubHasProblem(StubProblemType::STUB_IS_MISSED)) {
|
if ($function->hasMutedProblem(StubProblemType::STUB_IS_MISSED)) {
|
||||||
static::markTestSkipped('function is excluded');
|
static::markTestSkipped('function is excluded');
|
||||||
}
|
}
|
||||||
static::assertArrayHasKey($functionName, $stubFunctions, "Missing function: function $functionName($params){}");
|
static::assertArrayHasKey($functionName, $stubFunctions, "Missing function: function $functionName($params){}");
|
||||||
/**@var PHPFunction $phpstormFunction */
|
|
||||||
$phpstormFunction = $stubFunctions[$functionName];
|
$phpstormFunction = $stubFunctions[$functionName];
|
||||||
if (!$function->relatedStubHasProblem(StubProblemType::FUNCTION_IS_DEPRECATED)) {
|
if (!$function->hasMutedProblem(StubProblemType::FUNCTION_IS_DEPRECATED)) {
|
||||||
static::assertFalse(
|
static::assertFalse(
|
||||||
$function->is_deprecated && $phpstormFunction->is_deprecated !== true,
|
$function->is_deprecated && $phpstormFunction->is_deprecated !== true,
|
||||||
"Function $functionName is not deprecated in stubs"
|
"Function $functionName is not deprecated in stubs"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$function->relatedStubHasProblem(StubProblemType::FUNCTION_PARAMETER_MISMATCH)) {
|
if (!$function->hasMutedProblem(StubProblemType::FUNCTION_PARAMETER_MISMATCH)) {
|
||||||
static::assertSameSize(
|
static::assertSameSize(
|
||||||
$function->parameters,
|
$function->parameters,
|
||||||
$phpstormFunction->parameters,
|
$phpstormFunction->parameters,
|
||||||
|
@ -103,13 +101,12 @@ class TestStubs extends TestCase
|
||||||
{
|
{
|
||||||
$className = $class->name;
|
$className = $class->name;
|
||||||
$stubClasses = PhpStormStubsSingleton::getPhpStormStubs()->getClasses();
|
$stubClasses = PhpStormStubsSingleton::getPhpStormStubs()->getClasses();
|
||||||
if ($class->relatedStubHasProblem(StubProblemType::STUB_IS_MISSED)) {
|
if ($class->hasMutedProblem(StubProblemType::STUB_IS_MISSED)) {
|
||||||
static::markTestSkipped('class is skipped');
|
static::markTestSkipped('class is skipped');
|
||||||
}
|
}
|
||||||
static::assertArrayHasKey($className, $stubClasses, "Missing class $className: class $className {}");
|
static::assertArrayHasKey($className, $stubClasses, "Missing class $className: class $className {}");
|
||||||
/**@var PHPClass $stubClass */
|
|
||||||
$stubClass = $stubClasses[$className];
|
$stubClass = $stubClasses[$className];
|
||||||
if (!$class->relatedStubHasProblem(StubProblemType::WRONG_PARENT)) {
|
if (!$class->hasMutedProblem(StubProblemType::WRONG_PARENT)) {
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
$class->parentClass,
|
$class->parentClass,
|
||||||
$stubClass->parentClass,
|
$stubClass->parentClass,
|
||||||
|
@ -117,7 +114,7 @@ class TestStubs extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
foreach ($class->constants as $constant) {
|
foreach ($class->constants as $constant) {
|
||||||
if (!$constant->relatedStubHasProblem(StubProblemType::STUB_IS_MISSED)) {
|
if (!$constant->hasMutedProblem(StubProblemType::STUB_IS_MISSED)) {
|
||||||
static::assertArrayHasKey(
|
static::assertArrayHasKey(
|
||||||
$constant->name,
|
$constant->name,
|
||||||
$stubClass->constants,
|
$stubClass->constants,
|
||||||
|
@ -128,35 +125,35 @@ class TestStubs extends TestCase
|
||||||
foreach ($class->methods as $method) {
|
foreach ($class->methods as $method) {
|
||||||
$params = self::getParameterRepresentation($method);
|
$params = self::getParameterRepresentation($method);
|
||||||
$methodName = $method->name;
|
$methodName = $method->name;
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::STUB_IS_MISSED)) {
|
if (!$method->hasMutedProblem(StubProblemType::STUB_IS_MISSED)) {
|
||||||
static::assertArrayHasKey(
|
static::assertArrayHasKey(
|
||||||
$methodName,
|
$methodName,
|
||||||
$stubClass->methods,
|
$stubClass->methods,
|
||||||
"Missing method $className::$methodName($params){}"
|
"Missing method $className::$methodName($params){}"
|
||||||
);
|
);
|
||||||
$stubMethod = $stubClass->methods[$methodName];
|
$stubMethod = $stubClass->methods[$methodName];
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::FUNCTION_IS_FINAL)) {
|
if (!$method->hasMutedProblem(StubProblemType::FUNCTION_IS_FINAL)) {
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
$method->is_final,
|
$method->is_final,
|
||||||
$stubMethod->is_final,
|
$stubMethod->is_final,
|
||||||
"Method $className::$methodName final modifier is incorrect"
|
"Method $className::$methodName final modifier is incorrect"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::FUNCTION_IS_STATIC)) {
|
if (!$method->hasMutedProblem(StubProblemType::FUNCTION_IS_STATIC)) {
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
$method->is_static,
|
$method->is_static,
|
||||||
$stubMethod->is_static,
|
$stubMethod->is_static,
|
||||||
"Method $className::$methodName static modifier is incorrect"
|
"Method $className::$methodName static modifier is incorrect"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::FUNCTION_ACCESS)) {
|
if (!$method->hasMutedProblem(StubProblemType::FUNCTION_ACCESS)) {
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
$method->access,
|
$method->access,
|
||||||
$stubMethod->access,
|
$stubMethod->access,
|
||||||
"Method $className::$methodName access modifier is incorrect"
|
"Method $className::$methodName access modifier is incorrect"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::FUNCTION_PARAMETER_MISMATCH)) {
|
if (!$method->hasMutedProblem(StubProblemType::FUNCTION_PARAMETER_MISMATCH)) {
|
||||||
static::assertSameSize(
|
static::assertSameSize(
|
||||||
$method->parameters,
|
$method->parameters,
|
||||||
$stubMethod->parameters,
|
$stubMethod->parameters,
|
||||||
|
@ -167,7 +164,7 @@ class TestStubs extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($class->interfaces as $interface) {
|
foreach ($class->interfaces as $interface) {
|
||||||
if (!$class->relatedStubHasProblem(StubProblemType::WRONG_INTERFACE)) {
|
if (!$class->hasMutedProblem(StubProblemType::WRONG_INTERFACE)) {
|
||||||
static::assertContains(
|
static::assertContains(
|
||||||
$interface,
|
$interface,
|
||||||
$stubClass->interfaces,
|
$stubClass->interfaces,
|
||||||
|
@ -185,9 +182,8 @@ class TestStubs extends TestCase
|
||||||
public function testInterfaces(PHPInterface $interface): void
|
public function testInterfaces(PHPInterface $interface): void
|
||||||
{
|
{
|
||||||
$interfaceName = $interface->name;
|
$interfaceName = $interface->name;
|
||||||
/**@var PHPInterface[] $stubInterfaces */
|
|
||||||
$stubInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces();
|
$stubInterfaces = PhpStormStubsSingleton::getPhpStormStubs()->getInterfaces();
|
||||||
if ($interface->relatedStubHasProblem(StubProblemType::STUB_IS_MISSED)) {
|
if ($interface->hasMutedProblem(StubProblemType::STUB_IS_MISSED)) {
|
||||||
static::markTestSkipped('interface is skipped');
|
static::markTestSkipped('interface is skipped');
|
||||||
}
|
}
|
||||||
static::assertArrayHasKey(
|
static::assertArrayHasKey(
|
||||||
|
@ -196,11 +192,11 @@ class TestStubs extends TestCase
|
||||||
"Missing interface $interfaceName: interface $interfaceName {}"
|
"Missing interface $interfaceName: interface $interfaceName {}"
|
||||||
);
|
);
|
||||||
$stubInterface = $stubInterfaces[$interfaceName];
|
$stubInterface = $stubInterfaces[$interfaceName];
|
||||||
if (!$interface->relatedStubHasProblem(StubProblemType::WRONG_PARENT)) {
|
if (!$interface->hasMutedProblem(StubProblemType::WRONG_PARENT)) {
|
||||||
static::assertEquals($stubInterface->parentInterfaces, $interface->parentInterfaces);
|
static::assertEquals($stubInterface->parentInterfaces, $interface->parentInterfaces);
|
||||||
}
|
}
|
||||||
foreach ($interface->constants as $constant) {
|
foreach ($interface->constants as $constant) {
|
||||||
if (!$constant->relatedStubHasProblem(StubProblemType::STUB_IS_MISSED)) {
|
if (!$constant->hasMutedProblem(StubProblemType::STUB_IS_MISSED)) {
|
||||||
static::assertArrayHasKey(
|
static::assertArrayHasKey(
|
||||||
$constant->name,
|
$constant->name,
|
||||||
$stubInterface->constants,
|
$stubInterface->constants,
|
||||||
|
@ -211,35 +207,35 @@ class TestStubs extends TestCase
|
||||||
foreach ($interface->methods as $method) {
|
foreach ($interface->methods as $method) {
|
||||||
$params = self::getParameterRepresentation($method);
|
$params = self::getParameterRepresentation($method);
|
||||||
$methodName = $method->name;
|
$methodName = $method->name;
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::STUB_IS_MISSED)) {
|
if (!$method->hasMutedProblem(StubProblemType::STUB_IS_MISSED)) {
|
||||||
static::assertArrayHasKey(
|
static::assertArrayHasKey(
|
||||||
$methodName,
|
$methodName,
|
||||||
$stubInterface->methods,
|
$stubInterface->methods,
|
||||||
"Missing method $interfaceName::$methodName($params){}"
|
"Missing method $interfaceName::$methodName($params){}"
|
||||||
);
|
);
|
||||||
$stubMethod = $stubInterface->methods[$methodName];
|
$stubMethod = $stubInterface->methods[$methodName];
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::FUNCTION_IS_FINAL)) {
|
if (!$method->hasMutedProblem(StubProblemType::FUNCTION_IS_FINAL)) {
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
$method->is_final,
|
$method->is_final,
|
||||||
$stubMethod->is_final,
|
$stubMethod->is_final,
|
||||||
"Method $interfaceName::$methodName final modifier is incorrect"
|
"Method $interfaceName::$methodName final modifier is incorrect"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::FUNCTION_IS_STATIC)) {
|
if (!$method->hasMutedProblem(StubProblemType::FUNCTION_IS_STATIC)) {
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
$method->is_static,
|
$method->is_static,
|
||||||
$stubMethod->is_static,
|
$stubMethod->is_static,
|
||||||
"Method $interfaceName::$methodName static modifier is incorrect"
|
"Method $interfaceName::$methodName static modifier is incorrect"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::FUNCTION_ACCESS)) {
|
if (!$method->hasMutedProblem(StubProblemType::FUNCTION_ACCESS)) {
|
||||||
static::assertEquals(
|
static::assertEquals(
|
||||||
$method->access,
|
$method->access,
|
||||||
$stubMethod->access,
|
$stubMethod->access,
|
||||||
"Method $interfaceName::$methodName access modifier is incorrect"
|
"Method $interfaceName::$methodName access modifier is incorrect"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$method->relatedStubHasProblem(StubProblemType::FUNCTION_PARAMETER_MISMATCH)) {
|
if (!$method->hasMutedProblem(StubProblemType::FUNCTION_PARAMETER_MISMATCH)) {
|
||||||
static::assertSameSize(
|
static::assertSameSize(
|
||||||
$method->parameters,
|
$method->parameters,
|
||||||
$stubMethod->parameters,
|
$stubMethod->parameters,
|
||||||
|
@ -331,9 +327,13 @@ class TestStubs extends TestCase
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param PHPDocElement $element
|
||||||
|
* @param string $elementName
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
private function checkLinks($element, $elementName): void
|
private function checkLinks($element, $elementName): void
|
||||||
{
|
{
|
||||||
/**@var Tag $link */
|
|
||||||
foreach ($element->links as $link) {
|
foreach ($element->links as $link) {
|
||||||
if ($link instanceof Link) {
|
if ($link instanceof Link) {
|
||||||
static::assertStringStartsWith(
|
static::assertStringStartsWith(
|
||||||
|
@ -343,7 +343,6 @@ class TestStubs extends TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**@var Tag $see */
|
|
||||||
foreach ($element->see as $see) {
|
foreach ($element->see as $see) {
|
||||||
if ($see instanceof See && $see->getReference() instanceof Url && strncmp($see, 'http', 4) === 0) {
|
if ($see instanceof See && $see->getReference() instanceof Url && strncmp($see, 'http', 4) === 0) {
|
||||||
static::assertStringStartsWith('https', $see, "In $elementName @see doesn't start with https");
|
static::assertStringStartsWith('https', $see, "In $elementName @see doesn't start with https");
|
||||||
|
|
Loading…
Reference in New Issue