From 960445b2fdfd489402e6887b004743d5f5bace7e Mon Sep 17 00:00:00 2001 From: Thomas Lallement Date: Thu, 1 Nov 2012 16:08:59 +0100 Subject: [PATCH] CS Fixes - Replaced "array of type" by "Type[]" in PHPDoc block --- Kernel.php | 65 ++++++++--------------------- KernelInterface.php | 6 +-- Profiler/MongoDbProfilerStorage.php | 32 +++++--------- Profiler/PdoProfilerStorage.php | 2 +- Profiler/Profile.php | 62 ++++++++++++++++++++++++--- Profiler/Profiler.php | 23 +++++++--- 6 files changed, 107 insertions(+), 83 deletions(-) diff --git a/Kernel.php b/Kernel.php index cedd367b97..046d0c8a6a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -46,7 +46,11 @@ */ abstract class Kernel implements KernelInterface, TerminableInterface { + /** + * @var BundleInterface[] + */ protected $bundles; + protected $bundleMap; protected $container; protected $rootDir; @@ -157,9 +161,7 @@ public function terminate(Request $request, Response $response) } /** - * Shutdowns the kernel. - * - * This method is mainly useful when doing functional testing. + * {@inheritdoc} * * @api */ @@ -204,10 +206,8 @@ protected function getHttpKernel() } /** - * Gets the registered bundle instances. - * - * @return array An array of registered bundle instances - * + * {@inheritdoc} + * * @api */ public function getBundles() @@ -216,11 +216,7 @@ public function getBundles() } /** - * Checks if a given class name belongs to an active bundle. - * - * @param string $class A class name - * - * @return Boolean true if the class belongs to an active bundle, false otherwise + * {@inheritdoc} * * @api */ @@ -236,14 +232,7 @@ public function isClassInActiveBundle($class) } /** - * Returns a bundle and optionally its descendants by its name. - * - * @param string $name Bundle name - * @param Boolean $first Whether to return the first bundle only or together with its descendants - * - * @return BundleInterface|Array A BundleInterface instance or an array of BundleInterface instances if $first is false - * - * @throws \InvalidArgumentException when the bundle is not enabled + * {@inheritdoc} * * @api */ @@ -346,9 +335,7 @@ public function locateResource($name, $dir = null, $first = true) } /** - * Gets the name of the kernel - * - * @return string The kernel name + * {@inheritdoc} * * @api */ @@ -362,9 +349,7 @@ public function getName() } /** - * Gets the environment. - * - * @return string The current environment + * {@inheritdoc} * * @api */ @@ -374,9 +359,7 @@ public function getEnvironment() } /** - * Checks if debug mode is enabled. - * - * @return Boolean true if debug mode is enabled, false otherwise + * {@inheritdoc} * * @api */ @@ -386,9 +369,7 @@ public function isDebug() } /** - * Gets the application root dir. - * - * @return string The application root dir + * {@inheritdoc} * * @api */ @@ -403,9 +384,7 @@ public function getRootDir() } /** - * Gets the current container. - * - * @return ContainerInterface A ContainerInterface instance + * {@inheritdoc} * * @api */ @@ -436,9 +415,7 @@ public function setClassCache(array $classes) } /** - * Gets the request start time (not available if debug is disabled). - * - * @return integer The request start timestamp + * {@inheritdoc} * * @api */ @@ -448,9 +425,7 @@ public function getStartTime() } /** - * Gets the cache directory. - * - * @return string The cache directory + * {@inheritdoc} * * @api */ @@ -460,9 +435,7 @@ public function getCacheDir() } /** - * Gets the log directory. - * - * @return string The log directory + * {@inheritdoc} * * @api */ @@ -472,9 +445,7 @@ public function getLogDir() } /** - * Gets the charset of the application. - * - * @return string The charset + * {@inheritdoc} * * @api */ diff --git a/KernelInterface.php b/KernelInterface.php index 4010a3020e..dd37b60e03 100644 --- a/KernelInterface.php +++ b/KernelInterface.php @@ -30,7 +30,7 @@ interface KernelInterface extends HttpKernelInterface, \Serializable /** * Returns an array of bundles to registers. * - * @return array An array of bundle instances. + * @return BundleInterface[] An array of bundle instances. * * @api */ @@ -64,7 +64,7 @@ public function shutdown(); /** * Gets the registered bundle instances. * - * @return array An array of registered bundle instances + * @return BundleInterface[] An array of registered bundle instances * * @api */ @@ -87,7 +87,7 @@ public function isClassInActiveBundle($class); * @param string $name Bundle name * @param Boolean $first Whether to return the first bundle only or together with its descendants * - * @return BundleInterface|Array A BundleInterface instance or an array of BundleInterface instances if $first is false + * @return BundleInterface|BundleInterface[] A BundleInterface instance or an array of BundleInterface instances if $first is false * * @throws \InvalidArgumentException when the bundle is not enabled * diff --git a/Profiler/MongoDbProfilerStorage.php b/Profiler/MongoDbProfilerStorage.php index 59a9282da4..90db3dfbb1 100644 --- a/Profiler/MongoDbProfilerStorage.php +++ b/Profiler/MongoDbProfilerStorage.php @@ -32,14 +32,7 @@ public function __construct($dsn, $username = '', $password = '', $lifetime = 86 } /** - * Finds profiler tokens for the given criteria. - * - * @param string $ip The IP - * @param string $url The URL - * @param string $limit The maximum number of tokens to return - * @param string $method The request method - * - * @return array An array of tokens + * {@inheritdoc} */ public function find($ip, $url, $limit, $method) { @@ -54,7 +47,7 @@ public function find($ip, $url, $limit, $method) } /** - * Purges all data from the database. + * {@inheritdoc} */ public function purge() { @@ -62,13 +55,7 @@ public function purge() } /** - * Reads data associated with the given token. - * - * The method returns false if the token does not exists in the storage. - * - * @param string $token A token - * - * @return Profile The profile associated with token + * {@inheritdoc} */ public function read($token) { @@ -82,11 +69,7 @@ public function read($token) } /** - * Saves a Profile. - * - * @param Profile $profile A Profile instance - * - * @return Boolean Write operation successful + * {@inheritdoc} */ public function write(Profile $profile) { @@ -128,6 +111,7 @@ protected function getMongo() /** * @param array $data + * * @return Profile */ protected function createProfileFromData(array $data) @@ -148,7 +132,8 @@ protected function createProfileFromData(array $data) /** * @param string $token - * @return array + * + * @return Profile[] An array of Profile instances */ protected function readChildren($token) { @@ -171,6 +156,7 @@ protected function cleanup() * @param string $ip * @param string $url * @param string $method + * * @return array */ private function buildQuery($ip, $url, $method) @@ -194,6 +180,7 @@ private function buildQuery($ip, $url, $method) /** * @param array $data + * * @return array */ private function getData(array $data) @@ -211,6 +198,7 @@ private function getData(array $data) /** * @param array $data + * * @return Profile */ private function getProfile(array $data) diff --git a/Profiler/PdoProfilerStorage.php b/Profiler/PdoProfilerStorage.php index b7bc617690..36dcab8ecc 100644 --- a/Profiler/PdoProfilerStorage.php +++ b/Profiler/PdoProfilerStorage.php @@ -216,7 +216,7 @@ protected function createProfileFromData($token, $data, $parent = null) * @param string $token The parent token * @param string $parent The parent instance * - * @return array An array of Profile instance + * @return Profile[] An array of Profile instance */ protected function readChildren($token, $parent) { diff --git a/Profiler/Profile.php b/Profiler/Profile.php index bed24f1d10..e00ba71d36 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -21,13 +21,26 @@ class Profile { private $token; - private $collectors; + + /** + * @var DataCollectorInterface[] + */ + private $collectors = array(); + private $ip; private $method; private $url; private $time; + + /** + * @var Profile + */ private $parent; - private $children; + + /** + * @var Profile[] + */ + private $children = array(); /** * Constructor. @@ -37,8 +50,6 @@ class Profile public function __construct($token) { $this->token = $token; - $this->collectors = array(); - $this->children = array(); } /** @@ -101,6 +112,11 @@ public function getIp() return $this->ip; } + /** + * Sets the IP. + * + * @param string $ip + */ public function setIp($ip) { $this->ip = $ip; @@ -154,13 +170,18 @@ public function setTime($time) /** * Finds children profilers. * - * @return array An array of Profile + * @return Profile[] An array of Profile */ public function getChildren() { return $this->children; } + /** + * Sets children profiler. + * + * @param Profile[] $children An array of Profile + */ public function setChildren(array $children) { $this->children = array(); @@ -180,6 +201,15 @@ public function addChild(Profile $child) $child->setParent($this); } + /** + * Gets a Collector by name. + * + * @param string $name A collector name + * + * @return DataCollectorInterface A DataCollectorInterface instance + * + * @throws \InvalidArgumentException if the collector does not exist + */ public function getCollector($name) { if (!isset($this->collectors[$name])) { @@ -189,11 +219,21 @@ public function getCollector($name) return $this->collectors[$name]; } + /** + * Gets the Collectors associated with this profile. + * + * @return DataCollectorInterface[] + */ public function getCollectors() { return $this->collectors; } + /** + * Sets the Collectors associated with this profile. + * + * @param DataCollectorInterface[] $collectors + */ public function setCollectors(array $collectors) { $this->collectors = array(); @@ -202,11 +242,23 @@ public function setCollectors(array $collectors) } } + /** + * Adds a Collector. + * + * @param DataCollectorInterface $collector A DataCollectorInterface instance + */ public function addCollector(DataCollectorInterface $collector) { $this->collectors[$collector->getName()] = $collector; } + /** + * Returns true if a Collector for the given name exists. + * + * @param string $name A collector name + * + * @return Boolean + */ public function hasCollector($name) { return isset($this->collectors[$name]); diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index 3e7cad6386..aa336a8b04 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -24,10 +24,25 @@ */ class Profiler { + /** + * @var ProfilerStorageInterface + */ private $storage; - private $collectors; + + /** + * @var DataCollectorInterface[] + */ + private $collectors = array(); + + /** + * @var LoggerInterface + */ private $logger; - private $enabled; + + /** + * @var Boolean + */ + private $enabled = true; /** * Constructor. @@ -39,8 +54,6 @@ public function __construct(ProfilerStorageInterface $storage, LoggerInterface $ { $this->storage = $storage; $this->logger = $logger; - $this->collectors = array(); - $this->enabled = true; } /** @@ -204,7 +217,7 @@ public function all() /** * Sets the Collectors associated with this profiler. * - * @param array $collectors An array of collectors + * @param DataCollectorInterface[] $collectors An array of collectors */ public function set(array $collectors = array()) {