Skip to content

Commit

Permalink
Always import classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ndm2 committed Sep 23, 2015
1 parent 3ac3154 commit c8d3974
Show file tree
Hide file tree
Showing 68 changed files with 227 additions and 139 deletions.
22 changes: 13 additions & 9 deletions src/Cache/Engine/FileEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
use Cake\Utility\Inflector;
use Exception;
use LogicException;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use SplFileInfo;
use SplFileObject;

/**
* File Storage engine for cache. Filestorage is the slowest cache storage
Expand Down Expand Up @@ -264,10 +268,10 @@ public function clear($check)

$this->_clearDirectory($this->_config['path'], $now, $threshold);

$directory = new \RecursiveDirectoryIterator($this->_config['path']);
$contents = new \RecursiveIteratorIterator(
$directory = new RecursiveDirectoryIterator($this->_config['path']);
$contents = new RecursiveIteratorIterator(
$directory,
\RecursiveIteratorIterator::SELF_FIRST
RecursiveIteratorIterator::SELF_FIRST
);
$cleared = [];
foreach ($contents as $path) {
Expand Down Expand Up @@ -306,7 +310,7 @@ protected function _clearDirectory($path, $now, $threshold)
}

try {
$file = new \SplFileObject($path . $entry, 'r');
$file = new SplFileObject($path . $entry, 'r');
} catch (Exception $e) {
continue;
}
Expand Down Expand Up @@ -378,7 +382,7 @@ protected function _setKey($key, $createKey = false)
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
$path = new \SplFileInfo($dir . $key);
$path = new SplFileInfo($dir . $key);

if (!$createKey && !$path->isFile()) {
return false;
Expand Down Expand Up @@ -411,7 +415,7 @@ protected function _setKey($key, $createKey = false)
*/
protected function _active()
{
$dir = new \SplFileInfo($this->_config['path']);
$dir = new SplFileInfo($this->_config['path']);
$path = $dir->getPathname();
if (!is_dir($path)) {
mkdir($path, 0775, true);
Expand Down Expand Up @@ -457,10 +461,10 @@ public function key($key)
public function clearGroup($group)
{
$this->_File = null;
$directoryIterator = new \RecursiveDirectoryIterator($this->_config['path']);
$contents = new \RecursiveIteratorIterator(
$directoryIterator = new RecursiveDirectoryIterator($this->_config['path']);
$contents = new RecursiveIteratorIterator(
$directoryIterator,
\RecursiveIteratorIterator::CHILD_FIRST
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($contents as $object) {
$containsGroup = strpos($object->getPathname(), DS . $group . DS) !== false;
Expand Down
3 changes: 2 additions & 1 deletion src/Collection/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use InvalidArgumentException;
use IteratorIterator;
use Serializable;
use Traversable;

/**
* A collection is an immutable list of elements with a handful of functions to
Expand All @@ -40,7 +41,7 @@ public function __construct($items)
$items = new ArrayIterator($items);
}

if (!($items instanceof \Traversable)) {
if (!($items instanceof Traversable)) {
$msg = 'Only an array or \Traversable is allowed for Collection';
throw new InvalidArgumentException($msg);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Collection/CollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Countable;
use LimitIterator;
use RecursiveIteratorIterator;
use Traversable;

/**
* Offers a handful of method to manipulate iterators
Expand Down Expand Up @@ -164,7 +165,7 @@ public function extract($matcher)
if (is_string($matcher) && strpos($matcher, '{*}') !== false) {
$extractor = $extractor
->filter(function ($data) {
return $data !== null && ($data instanceof \Traversable || is_array($data));
return $data !== null && ($data instanceof Traversable || is_array($data));
})
->unfold();
}
Expand Down
3 changes: 2 additions & 1 deletion src/Collection/ExtractTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Collection;
use Traversable;

/**
* Provides utility protected methods for extracting a property or column
Expand Down Expand Up @@ -70,7 +71,7 @@ protected function _extract($data, $path)
}

if ($collectionTransform &&
!($data instanceof \Traversable || is_array($data))) {
!($data instanceof Traversable || is_array($data))) {
return null;
}

Expand Down
6 changes: 4 additions & 2 deletions src/Collection/Iterator/MapReduce.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

use ArrayIterator;
use IteratorAggregate;
use LogicException;
use Traversable;

/**
* Implements a simplistic version of the popular Map-Reduce algorithm. Acts
Expand Down Expand Up @@ -111,7 +113,7 @@ class MapReduce implements IteratorAggregate
* of the bucket that was created during the mapping phase and third one is an
* instance of this class.
*/
public function __construct(\Traversable $data, callable $mapper, callable $reducer = null)
public function __construct(Traversable $data, callable $mapper, callable $reducer = null)
{
$this->_data = $data;
$this->_mapper = $mapper;
Expand Down Expand Up @@ -177,7 +179,7 @@ protected function _execute()
$this->_data = null;

if (!empty($this->_intermediate) && empty($this->_reducer)) {
throw new \LogicException('No reducer function was provided');
throw new LogicException('No reducer function was provided');
}

$reducer = $this->_reducer;
Expand Down
3 changes: 2 additions & 1 deletion src/Collection/Iterator/NestIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Cake\Collection\Collection;
use RecursiveIterator;
use Traversable;

/**
* A type of collection that is aware of nested items and exposes methods to
Expand Down Expand Up @@ -71,6 +72,6 @@ public function hasChildren()
return !empty($children);
}

return $children instanceof \Traversable;
return $children instanceof Traversable;
}
}
3 changes: 2 additions & 1 deletion src/Collection/Iterator/SortIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Cake\Collection\Iterator;

use Cake\Collection\Collection;
use DateTime;

/**
* An iterator that will return the passed items in order. The order is given by
Expand Down Expand Up @@ -67,7 +68,7 @@ public function __construct($items, $callback, $dir = SORT_DESC, $type = SORT_NU
$results = [];
foreach ($items as $key => $value) {
$value = $callback($value);
if ($value instanceof \DateTime && $type === SORT_NUMERIC) {
if ($value instanceof DateTime && $type === SORT_NUMERIC) {
$value = $value->format('U');
}
$results[$key] = $value;
Expand Down
3 changes: 2 additions & 1 deletion src/Console/ConsoleInputArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Cake\Console;

use Cake\Console\Exception\ConsoleException;
use SimpleXmlElement;

/**
* An object to represent a single argument used in the command line.
Expand Down Expand Up @@ -177,7 +178,7 @@ public function validChoice($value)
* @param \SimpleXmlElement $parent The parent element.
* @return \SimpleXmlElement The parent with this argument appended.
*/
public function xml(\SimpleXmlElement $parent)
public function xml(SimpleXmlElement $parent)
{
$option = $parent->addChild('argument');
$option->addAttribute('name', $this->_name);
Expand Down
3 changes: 2 additions & 1 deletion src/Console/ConsoleInputOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Cake\Console;

use Cake\Console\Exception\ConsoleException;
use SimpleXmlElement;

/**
* An object to represent a single option used in the command line.
Expand Down Expand Up @@ -213,7 +214,7 @@ public function validChoice($value)
* @param \SimpleXmlElement $parent The parent element.
* @return \SimpleXmlElement The parent with this option appended.
*/
public function xml(\SimpleXmlElement $parent)
public function xml(SimpleXmlElement $parent)
{
$option = $parent->addChild('option');
$option->addAttribute('name', '--' . $this->_name);
Expand Down
3 changes: 2 additions & 1 deletion src/Console/ConsoleInputSubcommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console;
use SimpleXmlElement;

/**
* An object to represent a single subcommand used in the command line.
Expand Down Expand Up @@ -115,7 +116,7 @@ public function parser()
* @param \SimpleXmlElement $parent The parent element.
* @return \SimpleXmlElement The parent with this subcommand appended.
*/
public function xml(\SimpleXmlElement $parent)
public function xml(SimpleXmlElement $parent)
{
$command = $parent->addChild('command');
$command->addAttribute('name', $this->_name);
Expand Down
3 changes: 2 additions & 1 deletion src/Console/HelpFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Cake\Console;

use Cake\Utility\Text;
use SimpleXmlElement;

/**
* HelpFormatter formats help for console shells. Can format to either
Expand Down Expand Up @@ -188,7 +189,7 @@ protected function _getMaxLength($collection)
public function xml($string = true)
{
$parser = $this->_parser;
$xml = new \SimpleXmlElement('<shell></shell>');
$xml = new SimpleXmlElement('<shell></shell>');
$xml->addChild('command', $parser->command());
$xml->addChild('description', $parser->description());

Expand Down
6 changes: 4 additions & 2 deletions src/Console/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use Cake\Utility\Inflector;
use Cake\Utility\MergeVariablesTrait;
use Cake\Utility\Text;
use ReflectionException;
use ReflectionMethod;

/**
* Base class for command-line utilities for automating programmer chores.
Expand Down Expand Up @@ -271,12 +273,12 @@ public function hasTask($task)
public function hasMethod($name)
{
try {
$method = new \ReflectionMethod($this, $name);
$method = new ReflectionMethod($this, $name);
if (!$method->isPublic()) {
return false;
}
return $method->getDeclaringClass()->name !== 'Cake\Console\Shell';
} catch (\ReflectionException $e) {
} catch (ReflectionException $e) {
return false;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Component/FlashComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Cake\Controller\ComponentRegistry;
use Cake\Network\Exception\InternalErrorException;
use Cake\Utility\Inflector;
use Exception;

/**
* The CakePHP FlashComponent provides a way for you to write a flash variable
Expand Down Expand Up @@ -82,7 +83,7 @@ public function set($message, array $options = [])
{
$options += $this->config();

if ($message instanceof \Exception) {
if ($message instanceof Exception) {
$options['params'] += ['code' => $message->getCode()];
$message = $message->getMessage();
}
Expand Down
7 changes: 4 additions & 3 deletions src/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Cake\Database\Schema\Collection as SchemaCollection;
use Cake\Database\ValueBinder;
use Cake\Datasource\ConnectionInterface;
use Exception;

/**
* Represents a connection with a database server.
Expand Down Expand Up @@ -180,7 +181,7 @@ public function connect()
try {
$this->_driver->connect();
return true;
} catch (\Exception $e) {
} catch (Exception $e) {
throw new MissingConnectionException(['reason' => $e->getMessage()]);
}
}
Expand Down Expand Up @@ -544,7 +545,7 @@ public function transactional(callable $callback)

try {
$result = $callback($this);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->rollback();
throw $e;
}
Expand Down Expand Up @@ -575,7 +576,7 @@ public function disableConstraints(callable $callback)

try {
$result = $callback($this);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->enableForeignKeys();
throw $e;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Dialect/MysqlDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Database\Dialect;

use Cake\Database\Schema\MysqlSchema;
use Cake\Database\SqlDialectTrait;

/**
Expand Down Expand Up @@ -59,7 +60,7 @@ trait MysqlDialectTrait
public function schemaDialect()
{
if (!$this->_schemaDialect) {
$this->_schemaDialect = new \Cake\Database\Schema\MysqlSchema($this);
$this->_schemaDialect = new MysqlSchema($this);
}
return $this->_schemaDialect;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Dialect/PostgresDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Cake\Database\Dialect;

use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Schema\PostgresSchema;
use Cake\Database\SqlDialectTrait;

/**
Expand Down Expand Up @@ -161,7 +162,7 @@ protected function _transformFunctionExpression(FunctionExpression $expression)
public function schemaDialect()
{
if (!$this->_schemaDialect) {
$this->_schemaDialect = new \Cake\Database\Schema\PostgresSchema($this);
$this->_schemaDialect = new PostgresSchema($this);
}
return $this->_schemaDialect;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Dialect/SqliteDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Cake\Database\ExpressionInterface;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Schema\SqliteSchema;
use Cake\Database\SqlDialectTrait;
use Cake\Database\SqliteCompiler;

Expand Down Expand Up @@ -212,7 +213,7 @@ protected function _insertQueryTranslator($query)
public function schemaDialect()
{
if (!$this->_schemaDialect) {
$this->_schemaDialect = new \Cake\Database\Schema\SqliteSchema($this);
$this->_schemaDialect = new SqliteSchema($this);
}
return $this->_schemaDialect;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Dialect/SqlserverDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Cake\Database\Expression\OrderByExpression;
use Cake\Database\Expression\UnaryExpression;
use Cake\Database\Query;
use Cake\Database\Schema\SqlserverSchema;
use Cake\Database\SqlDialectTrait;
use Cake\Database\SqlserverCompiler;
use PDO;
Expand Down Expand Up @@ -281,7 +282,7 @@ protected function _transformFunctionExpression(FunctionExpression $expression)
*/
public function schemaDialect()
{
return new \Cake\Database\Schema\SqlserverSchema($this);
return new SqlserverSchema($this);
}

/**
Expand Down
Loading

0 comments on commit c8d3974

Please sign in to comment.