Skip to content

Commit

Permalink
Removing all uses of uses() global method & replacing with require or…
Browse files Browse the repository at this point in the history
… App::import.
  • Loading branch information
jperras committed Jul 24, 2009
1 parent d70900c commit e404288
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion cake/console/libs/shell.php
Expand Up @@ -436,7 +436,7 @@ function createFile ($path, $contents) {
}
}
if (!class_exists('File')) {
uses('file');
require LIBS . 'file.php';
}

if ($File = new File($path, true)) {
Expand Down
2 changes: 1 addition & 1 deletion cake/console/libs/tasks/project.php
Expand Up @@ -194,7 +194,7 @@ function securitySalt($path) {
$contents = $File->read();
if (preg_match('/([\\t\\x20]*Configure::write\\(\\\'Security.salt\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
if (!class_exists('Security')) {
uses('Security');
require LIBS . 'security.php';
}
$string = Security::generateAuthKey();
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \''.$string.'\');', $contents);
Expand Down
6 changes: 4 additions & 2 deletions cake/console/libs/templates/default/views/home.ctp
Expand Up @@ -52,7 +52,9 @@ endif;
</p>
<?php
if (!empty(\$filePresent)):
uses('model' . DS . 'connection_manager');
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
\$db = ConnectionManager::getInstance();
\$connected = \$db->getDataSource('default');
?>
Expand All @@ -79,4 +81,4 @@ $output .= "\t\tYou can also add some CSS styles for your pages at: %s', true),\
$output .= "\t\tAPP . 'views' . DS . 'pages' . DS . 'home.ctp.<br />', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.<br />', APP . 'webroot' . DS . 'css');\n";
$output .= "?>\n";
$output .= "</p>\n";
?>
?>
2 changes: 1 addition & 1 deletion cake/console/libs/templates/skel/webroot/css.php
Expand Up @@ -32,7 +32,7 @@
* Enter description here...
*/
if (!class_exists('File')) {
uses('file');
require LIBS . 'file.php';
}
/**
* Enter description here...
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/controller/components/acl.php
Expand Up @@ -201,7 +201,7 @@ class DbAcl extends AclBase {
function __construct() {
parent::__construct();
if (!class_exists('AclNode')) {
uses('model' . DS . 'db_acl');
require LIBS . 'model' . DS . 'db_acl.php';
}
$this->Aro =& ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro'));
$this->Aco =& ClassRegistry::init(array('class' => 'Aco', 'alias' => 'Aco'));
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/file.php
Expand Up @@ -27,7 +27,7 @@
*
*/
if (!class_exists('Object')) {
uses('object');
require LIBS . 'object.php';
}
if (!class_exists('Folder')) {
require LIBS . 'folder.php';
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/folder.php
Expand Up @@ -27,7 +27,7 @@
*
*/
if (!class_exists('Object')) {
uses('object');
require LIBS . 'object.php';
}
/**
* Folder structure browser, lists folders and files.
Expand Down
5 changes: 4 additions & 1 deletion cake/libs/magic_db.php
Expand Up @@ -22,8 +22,11 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
if (!class_exists('Object')) {
require LIBS . 'object.php';
}
if (!class_exists('File')) {
uses('object', 'file');
require LIBS . 'file.php';
}
/**
* A class to parse and use the MagicDb for file type analysis
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/model/behaviors/acl.php
Expand Up @@ -55,7 +55,7 @@ function setup(&$model, $config = array()) {

$type = $this->__typeMaps[$this->settings[$model->name]['type']];
if (!class_exists('AclNode')) {
uses('model' . DS . 'db_acl');
require LIBS . 'model' . DS . 'db_acl.php';
}
$model->{$type} =& ClassRegistry::init($type);
if (!method_exists($model, 'parentNode')) {
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/object.php
Expand Up @@ -148,7 +148,7 @@ function _stop($status = 0) {
*/
function log($msg, $type = LOG_ERROR) {
if (!class_exists('CakeLog')) {
uses('cake_log');
require LIBS . 'cake_log.php';
}
if (is_null($this->_log)) {
$this->_log = new CakeLog();
Expand Down
4 changes: 3 additions & 1 deletion cake/libs/view/pages/home.ctp
Expand Up @@ -78,7 +78,9 @@ endif;
</p>
<?php
if (isset($filePresent)):
uses('model' . DS . 'connection_manager');
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
$db = ConnectionManager::getInstance();
@$connected = $db->getDataSource('default');
?>
Expand Down
1 change: 1 addition & 0 deletions cake/tests/cases/basics.test.php
Expand Up @@ -147,6 +147,7 @@ function testEnv() {
*
* @access public
* @return void
* @deprecated
*/
function testUses() {
$this->skipIf(class_exists('Security') || class_exists('Sanitize'), '%s Security and/or Sanitize class already loaded');
Expand Down
4 changes: 3 additions & 1 deletion cake/tests/cases/libs/magic_db.test.php
Expand Up @@ -22,7 +22,9 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
uses('magic_db', 'object');
if (!class_exists('MagicDb')) {
require LIBS . 'magic_db.php';
}
/**
* The test class for the MagicDb class
*
Expand Down
1 change: 0 additions & 1 deletion cake/tests/cases/libs/set.test.php
Expand Up @@ -1755,7 +1755,6 @@ function testMapReverse() {
$result = Set::reverse($class);
$this->assertIdentical($result, $expected);

uses('model'.DS.'model');
$model = new Model(array('id' => false, 'name' => 'Model', 'table' => false));
$expected = array(
'Behaviors' => array('modelName' => 'Model', '_attached' => array(), '_disabled' => array(), '__methods' => array(), '__mappedMethods' => array(), '_log' => null),
Expand Down
11 changes: 1 addition & 10 deletions cake/tests/cases/libs/view/helpers/ajax.test.php
Expand Up @@ -27,16 +27,7 @@
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
uses(
'view' . DS . 'helpers' . DS . 'app_helper',
'controller' . DS . 'controller',
'model' . DS . 'model',
'view' . DS . 'helper',
'view' . DS . 'helpers'.DS.'ajax',
'view' . DS . 'helpers' . DS . 'html',
'view' . DS . 'helpers' . DS . 'form',
'view' . DS . 'helpers' . DS . 'javascript'
);
App::import('Helper', array('Html', 'Form', 'Javascript', 'Ajax'));
/**
* AjaxTestController class
*
Expand Down
7 changes: 0 additions & 7 deletions cake/tests/cases/libs/view/helpers/js.test.php
Expand Up @@ -27,13 +27,6 @@
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
uses(
'view' . DS . 'helpers' . DS . 'app_helper',
'controller' . DS . 'controller',
'model' . DS . 'model',
'view' . DS . 'helper',
'view' . DS . 'helpers' . DS . 'js'
);
/**
* JsHelperTest class
*
Expand Down
6 changes: 4 additions & 2 deletions cake/tests/test_app/views/pages/home.ctp
Expand Up @@ -51,7 +51,9 @@ endif;
</p>
<?php
if (!empty($filePresent)):
uses('model' . DS . 'connection_manager');
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
$db = ConnectionManager::getInstance();
$connected = $db->getDataSource('default');
?>
Expand All @@ -77,4 +79,4 @@ if (!empty($filePresent)):
You can also add some CSS styles for your pages at: %s', true),
APP . 'views' . DS . 'pages' . DS . 'home.ctp.<br />', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.<br />', APP . 'webroot' . DS . 'css');
?>
</p>
</p>
4 changes: 3 additions & 1 deletion cake/tests/test_app/views/posts/test_nocache_tags.ctp
Expand Up @@ -81,7 +81,9 @@
</p>
<?php
if (!empty($filePresent)):
uses('model' . DS . 'connection_manager');
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
$db = ConnectionManager::getInstance();
$connected = $db->getDataSource('default');
?>
Expand Down

0 comments on commit e404288

Please sign in to comment.