From 4c4b6e990268ce14ae35d2ed79e98b71064f52f9 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Wed, 12 Oct 2016 01:38:29 -0400 Subject: [PATCH] Add docblocks where relevant --- src/Psalm/Checker/ClassChecker.php | 1 + src/Psalm/Checker/ClassLikeChecker.php | 50 ++++++++++++++++++++------ src/Psalm/Checker/FileChecker.php | 4 +++ src/Psalm/Checker/MethodChecker.php | 4 +++ 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/Psalm/Checker/ClassChecker.php b/src/Psalm/Checker/ClassChecker.php index 7e753f2f3..46a45aafb 100644 --- a/src/Psalm/Checker/ClassChecker.php +++ b/src/Psalm/Checker/ClassChecker.php @@ -137,6 +137,7 @@ class ClassChecker extends ClassLikeChecker public static function getInterfacesForClass($absolute_class) { if (!isset(self::$class_implements[$absolute_class])) { + /** @var string[] */ $class_implements = class_implements($absolute_class); self::$class_implements[$absolute_class] = []; diff --git a/src/Psalm/Checker/ClassLikeChecker.php b/src/Psalm/Checker/ClassLikeChecker.php index 7e2452eb3..4799294b8 100644 --- a/src/Psalm/Checker/ClassLikeChecker.php +++ b/src/Psalm/Checker/ClassLikeChecker.php @@ -28,7 +28,7 @@ abstract class ClassLikeChecker implements StatementsSource protected $file_name; /** - * @var string + * @var string|null */ protected $include_file_name; @@ -87,7 +87,7 @@ abstract class ClassLikeChecker implements StatementsSource /** * A lookup table of all methods on a given class * - * @var array + * @var array> */ protected static $class_methods = []; @@ -101,49 +101,49 @@ abstract class ClassLikeChecker implements StatementsSource /** * A lookup table for public class properties * - * @var array + * @var array> */ protected static $public_class_properties = []; /** * A lookup table for protected class properties * - * @var array + * @var array> */ protected static $protected_class_properties = []; /** * A lookup table for protected class properties * - * @var array + * @var array> */ protected static $private_class_properties = []; /** * A lookup table for public static class properties * - * @var array + * @var array> */ protected static $public_static_class_properties = []; /** * A lookup table for protected static class properties * - * @var array + * @var array> */ protected static $protected_static_class_properties = []; /** * A lookup table for private static class properties * - * @var array + * @var array> */ protected static $private_static_class_properties = []; /** * A lookup table for public class constants * - * @var array + * @var array> */ protected static $public_class_constants = []; @@ -157,7 +157,7 @@ abstract class ClassLikeChecker implements StatementsSource /** * A lookup table used for storing the results of ClassChecker::classImplements * - * @var array + * @var array> */ protected static $class_implements = []; @@ -239,7 +239,7 @@ abstract class ClassLikeChecker implements StatementsSource return false; } - self::registerClass($this->parent_class); + self::registerClass($this->parent_class); $this->registerInheritedMethods($this->parent_class); @@ -341,6 +341,7 @@ abstract class ClassLikeChecker implements StatementsSource continue; } + /** @var TraitChecker */ $trait_checker = FileChecker::getClassLikeCheckerFromClass($trait_name); $trait_checker->setMethodMap($method_map); @@ -591,6 +592,12 @@ abstract class ClassLikeChecker implements StatementsSource return self::getAbsoluteClassFromString(implode('\\', $class_name->parts), $namespace, $aliased_classes); } + /** + * @param string $class + * @param string $namespace + * @param array $imported_namespaces + * @return string + */ public static function getAbsoluteClassFromString($class, $namespace, array $imported_namespaces) { if (empty($class)) { @@ -684,6 +691,10 @@ abstract class ClassLikeChecker implements StatementsSource return $this->has_custom_get; } + /** + * @param string $class_name + * @return boolean + */ public static function registerClass($class_name) { if (isset(self::$registered_classes[$class_name])) { @@ -721,6 +732,7 @@ abstract class ClassLikeChecker implements StatementsSource self::$protected_static_class_properties[$class_name] = []; self::$private_static_class_properties[$class_name] = []; + /** @var \ReflectionProperty $class_property */ foreach ($class_properties as $class_property) { if ($class_property->isStatic()) { if ($class_property->isPublic()) { @@ -793,6 +805,7 @@ abstract class ClassLikeChecker implements StatementsSource self::$class_methods[$class_name] = []; + /** @var \ReflectionMethod $reflection_method */ foreach ($reflection_methods as $reflection_method) { MethodChecker::extractReflectionMethodInfo($reflection_method); @@ -830,6 +843,11 @@ abstract class ClassLikeChecker implements StatementsSource } } + /** + * @param string $class_name + * @param mixed $visibility + * @return array + */ public static function getInstancePropertiesForClass($class_name, $visibility) { if (self::registerClass($class_name) === false) { @@ -856,6 +874,11 @@ abstract class ClassLikeChecker implements StatementsSource throw new \InvalidArgumentException('Must specify $visibility'); } + /** + * @param string $class_name + * @param mixed $visibility + * @return array + */ public static function getStaticPropertiesForClass($class_name, $visibility) { if (self::registerClass($class_name) === false) { @@ -882,6 +905,11 @@ abstract class ClassLikeChecker implements StatementsSource throw new \InvalidArgumentException('Must specify $visibility'); } + /** + * @param string $class_name + * @param mixed $visibility + * @return array + */ public static function getConstantsForClass($class_name, $visibility) { // remove for PHP 7.1 support diff --git a/src/Psalm/Checker/FileChecker.php b/src/Psalm/Checker/FileChecker.php index 4ef8323f5..c7bcc6baf 100644 --- a/src/Psalm/Checker/FileChecker.php +++ b/src/Psalm/Checker/FileChecker.php @@ -442,6 +442,10 @@ class FileChecker implements StatementsSource return self::$file_checkers[$file_name]; } + /** + * @param string $class_name + * @return ClassLikeChecker|null + */ public static function getClassLikeCheckerFromClass($class_name) { $file_name = (new \ReflectionClass($class_name))->getFileName(); diff --git a/src/Psalm/Checker/MethodChecker.php b/src/Psalm/Checker/MethodChecker.php index c2178bc03..abd05dfbc 100644 --- a/src/Psalm/Checker/MethodChecker.php +++ b/src/Psalm/Checker/MethodChecker.php @@ -383,6 +383,10 @@ class MethodChecker extends FunctionLikeChecker self::$declaring_methods[$method_id] = $declaring_method_id; } + /** + * @param string $method_id + * @return string + */ public static function getDeclaringMethod($method_id) { return self::$declaring_methods[$method_id];