Removing PHP5 and all its uses.

This commit is contained in:
mark_story 2010-07-05 22:19:22 -04:00
parent 4a32a39c22
commit b8085cddce
13 changed files with 25 additions and 98 deletions

View file

@ -19,9 +19,6 @@
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
if (!defined('PHP5')) {
define('PHP5', (PHP_VERSION >= 5));
}
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 8192);
}

View file

@ -153,7 +153,6 @@ class ShellDispatcher {
}
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('PHP5', (PHP_VERSION >= 5));
define('DS', DIRECTORY_SEPARATOR);
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))));
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);

View file

@ -157,15 +157,6 @@ class Shell extends Object {
ClassRegistry::addObject($this->name, $this);
ClassRegistry::map($this->name, $this->alias);
if (!PHP5 && isset($this->args[0])) {
if (strpos($this->name, strtolower(Inflector::camelize($this->args[0]))) !== false) {
$dispatch->shiftArgs();
}
if (strtolower($this->command) == strtolower(Inflector::variable($this->args[0])) && method_exists($this, $this->command)) {
$dispatch->shiftArgs();
}
}
$this->Dispatch =& $dispatch;
}
@ -248,11 +239,7 @@ class Shell extends Object {
foreach ($uses as $modelClass) {
list($plugin, $modelClass) = pluginSplit($modelClass, true);
if (PHP5) {
$this->{$modelClass} = ClassRegistry::init($plugin . $modelClass);
} else {
$this->{$modelClass} =& ClassRegistry::init($plugin . $modelClass);
}
}
return true;
}
@ -288,24 +275,13 @@ class Shell extends Object {
}
}
$taskClassCheck = $taskClass;
if (!PHP5) {
$taskClassCheck = strtolower($taskClass);
}
if (ClassRegistry::isKeySet($taskClassCheck)) {
$this->taskNames[] = $taskName;
if (!PHP5) {
$this->{$taskName} =& ClassRegistry::getObject($taskClassCheck);
} else {
$this->{$taskName} = ClassRegistry::getObject($taskClassCheck);
}
} else {
$this->taskNames[] = $taskName;
if (!PHP5) {
$this->{$taskName} =& new $taskClass($this->Dispatch);
} else {
$this->{$taskName} = new $taskClass($this->Dispatch);
}
}
if (!isset($this->{$taskName})) {
$this->err("Task `{$taskName}` could not be loaded");

View file

@ -804,11 +804,7 @@ class AuthComponent extends Object {
$name = $this->userModel;
}
if (PHP5) {
$model = ClassRegistry::init($name);
} else {
$model =& ClassRegistry::init($name);
}
if (empty($model)) {
trigger_error(__('Auth::getModel() - Model is not set or could not be found'), E_USER_WARNING);

View file

@ -53,11 +53,7 @@ class AclBehavior extends ModelBehavior {
if (!class_exists('AclNode')) {
require LIBS . 'model' . DS . 'db_acl.php';
}
if (PHP5) {
$model->{$type} = ClassRegistry::init($type);
} else {
$model->{$type} =& ClassRegistry::init($type);
}
if (!method_exists($model, 'parentNode')) {
trigger_error(sprintf(__('Callback parentNode() not defined in %s'), $model->alias), E_USER_WARNING);
}

View file

@ -374,11 +374,7 @@ class TranslateBehavior extends ModelBehavior {
$className = $model->translateModel;
}
if (PHP5) {
$this->runtime[$model->alias]['model'] = ClassRegistry::init($className, 'Model');
} else {
$this->runtime[$model->alias]['model'] =& ClassRegistry::init($className, 'Model');
}
}
if (!empty($model->translateTable) && $model->translateTable !== $this->runtime[$model->alias]['model']->useTable) {
$this->runtime[$model->alias]['model']->setSource($model->translateTable);

View file

@ -135,11 +135,7 @@ class AclNode extends AppModel {
} elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {
$name = key($ref);
if (PHP5) {
$model = ClassRegistry::init(array('class' => $name, 'alias' => $name));
} else {
$model =& ClassRegistry::init(array('class' => $name, 'alias' => $name));
}
if (empty($model)) {
trigger_error(sprintf(__("Model class '%s' not found in AclNode::node() when trying to bind %s object"), $type, $this->alias), E_USER_WARNING);

View file

@ -641,11 +641,7 @@ class Model extends Object {
if (!isset($this->{$assoc}) || $this->{$assoc}->name !== $className) {
$model = array('class' => $className, 'alias' => $assoc);
if (PHP5) {
$this->{$assoc} = ClassRegistry::init($model);
} else {
$this->{$assoc} =& ClassRegistry::init($model);
}
if (strpos($className, '.') !== false) {
ClassRegistry::addObject($className, $this->{$assoc});
}

View file

@ -298,17 +298,9 @@ class BehaviorCollection extends Object {
if (!isset($this->{$name})) {
if (ClassRegistry::isKeySet($class)) {
if (PHP5) {
$this->{$name} = ClassRegistry::getObject($class);
} else {
$this->{$name} =& ClassRegistry::getObject($class);
}
} else {
if (PHP5) {
$this->{$name} = new $class;
} else {
$this->{$name} =& new $class;
}
ClassRegistry::addObject($class, $this->{$name});
if (!empty($plugin)) {
ClassRegistry::addObject($plugin.'.'.$class, $this->{$name});

View file

@ -381,7 +381,7 @@ class Multibyte extends Object {
* @static
*/
function stripos($haystack, $needle, $offset = 0) {
if (!PHP5 || Multibyte::checkMultibyte($haystack)) {
if (Multibyte::checkMultibyte($haystack)) {
$haystack = Multibyte::strtoupper($haystack);
$needle = Multibyte::strtoupper($needle);
return Multibyte::strpos($haystack, $needle, $offset);
@ -651,7 +651,7 @@ class Multibyte extends Object {
* @static
*/
function strripos($haystack, $needle, $offset = 0) {
if (!PHP5 || Multibyte::checkMultibyte($haystack)) {
if (Multibyte::checkMultibyte($haystack)) {
$found = false;
$haystack = Multibyte::strtoupper($haystack);
$haystack = Multibyte::utf8($haystack);
@ -704,7 +704,7 @@ class Multibyte extends Object {
* @static
*/
function strrpos($haystack, $needle, $offset = 0) {
if (!PHP5 || Multibyte::checkMultibyte($haystack)) {
if (Multibyte::checkMultibyte($haystack)) {
$found = false;
$haystack = Multibyte::utf8($haystack);

View file

@ -153,11 +153,8 @@ class ClassRegistryTest extends CakeTestCase {
* @return void
*/
function testAddModel() {
if (PHP5) {
$Tag = ClassRegistry::init('RegisterArticleTag');
} else {
$Tag =& ClassRegistry::init('RegisterArticleTag');
}
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
$TagCopy = ClassRegistry::isKeySet('RegisterArticleTag');

View file

@ -542,13 +542,8 @@ class AppImportTest extends CakeTestCase {
if (!class_exists('AppController')) {
$classes = array_flip(get_declared_classes());
if (PHP5) {
$this->assertFalse(isset($classes['PagesController']));
$this->assertFalse(isset($classes['AppController']));
} else {
$this->assertFalse(isset($classes['pagescontroller']));
$this->assertFalse(isset($classes['appcontroller']));
}
$file = App::import('Controller', 'Pages');
$this->assertTrue($file);
@ -556,13 +551,8 @@ class AppImportTest extends CakeTestCase {
$classes = array_flip(get_declared_classes());
if (PHP5) {
$this->assertTrue(isset($classes['PagesController']));
$this->assertTrue(isset($classes['AppController']));
} else {
$this->assertTrue(isset($classes['pagescontroller']));
$this->assertTrue(isset($classes['appcontroller']));
}
$file = App::import('Behavior', 'Containable');
$this->assertTrue($file);
@ -736,11 +726,8 @@ class AppImportTest extends CakeTestCase {
$classes = array_flip(get_declared_classes());
if (PHP5) {
$this->assertTrue(isset($classes['I18n']));
} else {
$this->assertTrue(isset($classes['i18n']));
}
$load = App::import(array('I18n', 'SomeNotFoundClass', 'CakeSocket'));
$this->assertFalse($load);

View file

@ -2594,11 +2594,10 @@ class SetTest extends CakeTestCase {
$expected = 9;
$this->assertEqual($result, $expected);
if (PHP5) {
$result = Set::apply('/Movie/rating', $data, 'array_product');
$expected = 15;
$this->assertEqual($result, $expected);
}
$result = Set::apply('/Movie/title', $data, 'ucfirst', array('type' => 'map'));
$expected = array('Movie 3', 'Movie 1', 'Movie 2');