From bf6313e50bb7b0209e60fe68e2962f4388eef1f1 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 17 Feb 2012 14:02:53 -0600 Subject: [PATCH] cleaning up code. --- laravel/file.php | 3 +-- laravel/helpers.php | 12 ------------ laravel/ioc.php | 6 +----- laravel/laravel.php | 7 ++++--- laravel/validator.php | 23 ++++++++++++++--------- 5 files changed, 20 insertions(+), 31 deletions(-) diff --git a/laravel/file.php b/laravel/file.php index 4bb02930..6571a94c 100644 --- a/laravel/file.php +++ b/laravel/file.php @@ -161,8 +161,7 @@ public static function is($extensions, $path) // The MIME configuration file contains an array of file extensions and // their associated MIME types. We will spin through each extension the - // developer wants to check to determine if the file's MIME type is in - // the list of MIMEs we have for that extension. + // developer wants to check and look for the MIME type. foreach ((array) $extensions as $extension) { if (isset($mimes[$extension]) and in_array($mime, (array) $mimes[$extension])) diff --git a/laravel/helpers.php b/laravel/helpers.php index e76c247a..ef4e83ff 100644 --- a/laravel/helpers.php +++ b/laravel/helpers.php @@ -177,18 +177,6 @@ function array_first($array, $callback, $default = null) return value($default); } -/** - * Spin through the array, executing a callback with each key and element. - * - * @param array $array - * @param mixed $callback - * @return array - */ -function array_spin($array, $callback) -{ - return array_map($callback, array_keys($array), array_values($array)); -} - /** * Recursively remove slashes from array keys and values. * diff --git a/laravel/ioc.php b/laravel/ioc.php index 2c596468..de8e2939 100644 --- a/laravel/ioc.php +++ b/laravel/ioc.php @@ -129,11 +129,7 @@ public static function resolve($name, $parameters = array()) // If the resolver is registering as a singleton resolver, we will cache // the instance of the object in the container so we can resolve it next - // time without having to instantiate a new instance of the object. - // - // This allows the developer to reuse objects that do not need to be - // instantiated each time they are needed, such as a SwiftMailer or - // Twig object that can be shared. + // time without having to instantiate a brand new instance. if (isset(static::$registry[$name]['singleton'])) { return static::$singletons[$name] = $object; diff --git a/laravel/laravel.php b/laravel/laravel.php index e6c23ce3..45749691 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -53,9 +53,10 @@ ini_set('display_errors', Config::get('error.display')); /** - * Determine if we need to set the application key to a random - * string for the developer. This provides the developer with - * a zero configuration install process. + * Determine if we need to set the application key to a very random + * string so we can provide a zero configuration installation but + * still ensure that the key is set to something random. It is + * possible to disable this feature. */ $auto_key = Config::get('application.auto_key'); diff --git a/laravel/validator.php b/laravel/validator.php index 1be15934..0c84e8e1 100644 --- a/laravel/validator.php +++ b/laravel/validator.php @@ -697,14 +697,15 @@ protected function message($attribute, $rule) protected function size_message($bundle, $attribute, $rule) { // There are three different types of size validations. The attribute - // may be either a number, file, or a string. If the attribute has a - // numeric rule attached to it, we can assume it is a number. If the - // attribute is in the file array, it is a file, otherwise we can - // assume the attribute is simply a string. + // may be either a number, file, or a string, so we'll check a few + // things to figure out which one it is. if ($this->has_rule($attribute, $this->numeric_rules)) { $line = 'numeric'; } + // We assume that attributes present in the $_FILES array are files, + // which makes sense. If the attribute doesn't have numeric rules + // and isn't as file, it's a string. elseif (array_key_exists($attribute, Input::file())) { $line = 'file'; @@ -877,15 +878,19 @@ protected function attribute($attribute) // More reader friendly versions of the attribute names may be stored // in the validation language file, allowing a more readable version // of the attribute name to be used in the message. - // - // If no language line has been specified for the attribute, all of - // the underscores will be removed from the attribute name and that - // will be used as the attribtue name. $line = "{$bundle}validation.attributes.{$attribute}"; $display = Lang::line($line)->get($this->language); - return (is_null($display)) ? str_replace('_', ' ', $attribute) : $display; + // If no language line has been specified for the attribute, all of + // the underscores are removed from the attribute name and that + // will be used as the attribtue name. + if (is_null($display)) + { + return str_replace('_', ' ', $attribute); + } + + return $display; } /**