add checks to avoid NPE

This commit is contained in:
Ivan Fedorov 2018-12-17 14:08:28 +03:00
parent d100b4ff83
commit 548ecc8d3a
6 changed files with 19 additions and 18 deletions

View File

@ -72,7 +72,6 @@ class PHPClass extends BasePHPClass
foreach ($interfaceObject->parts as $interface) {
$interfaceFQN .= "\\$interface";
}
$this->interfaces[] = ltrim($interfaceFQN, "\\");
}
}

View File

@ -59,7 +59,7 @@ class PHPConst extends BasePHPElement
{
/**@var stdClass $constant */
foreach ($jsonData as $constant) {
if ($constant->name === $this->name) {
if ($constant->name === $this->name && !empty($constant->problems)) {
/**@var stdClass $problem */
foreach ($constant->problems as $problem) {
switch ($problem) {

View File

@ -105,7 +105,7 @@ class PHPFunction extends BasePHPElement
{
/**@var stdClass $function */
foreach ($jsonData as $function) {
if ($function->name === $this->name) {
if ($function->name === $this->name && !empty($function->problems)) {
/**@var stdClass $problem */
foreach ($function->problems as $problem) {
switch ($problem) {

View File

@ -64,19 +64,21 @@ class PHPInterface extends BasePHPClass
{
/**@var stdClass $interface */
foreach ($jsonData as $interface) {
if ($interface->name === $this->name && !empty($interface->problems)) {
/**@var stdClass $problem */
foreach ($interface->problems as $problem) {
switch ($problem) {
case 'wrong parent':
$this->relatedStubProblems[] = StubProblemType::WRONG_PARENT;
break;
case 'missing interface':
$this->relatedStubProblems[] = StubProblemType::STUB_IS_MISSED;
break;
default:
$this->relatedStubProblems[] = -1;
break;
if ($interface->name === $this->name) {
if (!empty($interface->problems)) {
/**@var stdClass $problem */
foreach ($interface->problems as $problem) {
switch ($problem) {
case 'wrong parent':
$this->relatedStubProblems[] = StubProblemType::WRONG_PARENT;
break;
case 'missing interface':
$this->relatedStubProblems[] = StubProblemType::STUB_IS_MISSED;
break;
default:
$this->relatedStubProblems[] = -1;
break;
}
}
}
if (!empty($interface->methods)) {

View File

@ -75,7 +75,7 @@ class PHPMethod extends PHPFunction
{
/**@var stdClass $method */
foreach ($jsonData as $method) {
if ($method->name === $this->name) {
if ($method->name === $this->name && !empty($method->problems)) {
/**@var stdClass $problem */
foreach ($method->problems as $problem) {
switch ($problem) {

View File

@ -53,7 +53,7 @@ class PHPParameter extends BasePHPElement
{
/**@var stdClass $parameter */
foreach ($jsonData as $parameter) {
if ($parameter->name === $this->name) {
if ($parameter->name === $this->name && !empty($parameter->problems)) {
/**@var stdClass $problem */
foreach ($parameter->problems as $problem) {
switch ($problem) {