diff --git a/src/CodeInspector/FileChecker.php b/src/CodeInspector/FileChecker.php index 146e01929..6e63d113c 100644 --- a/src/CodeInspector/FileChecker.php +++ b/src/CodeInspector/FileChecker.php @@ -162,9 +162,9 @@ class FileChecker implements StatementsSource return !self::$_var_dump_fn || call_user_func(self::$_var_dump_fn, $file_name); } - public static function shouldCheckClassProperties($file_name, ClassChecker $class_checker = null) + public static function shouldCheckClassProperties($file_name) { - return !self::$_class_property_fn || call_user_func(self::$_class_property_fn, $file_name, $class_checker); + return !self::$_class_property_fn || call_user_func(self::$_class_property_fn, $file_name); } public function registerFunction(PhpParser\Node\Stmt\Function_ $function) diff --git a/src/CodeInspector/StatementsChecker.php b/src/CodeInspector/StatementsChecker.php index b0b17b98f..13823b6bc 100644 --- a/src/CodeInspector/StatementsChecker.php +++ b/src/CodeInspector/StatementsChecker.php @@ -752,8 +752,9 @@ class StatementsChecker { if ($stmt->var instanceof PhpParser\Node\Expr\Variable) { if ($stmt->var->name === 'this') { - $class_checker = $this->_source->getClassChecker(); - if ($class_checker) { + if (!FileChecker::shouldCheckClassProperties($this->_file_name)) { + // ignore this property + } elseif ($class_checker = $this->_source->getClassChecker()) { if (is_string($stmt->name)) { $property_names = $class_checker->getPropertyNames(); @@ -894,10 +895,6 @@ class StatementsChecker if ($return_type !== 'array' && $return_type !== 'Traversable' && $return_type !== $this->_class_name) { ClassChecker::checkAbsoluteClass($return_type, $stmt, $this->_file_name); - - if (!ClassChecker::classImplements($return_type, 'Traversable')) { - throw new IteratorException('Class ' . $return_type . ' does not implement the Traversable interface', $this->_file_name, $stmt->getLine()); - } } } }