Refactor Object to CakeObject for future PHP7 comp.

This commit is contained in:
mscherer 2016-04-08 14:33:26 +02:00
parent 96c9521802
commit dda9e83ab6
30 changed files with 58 additions and 53 deletions

View file

@ -532,7 +532,7 @@ class UpgradeShell extends AppShell {
/** /**
* Update components. * Update components.
* *
* - Make components that extend Object to extend Component. * - Make components that extend CakeObject to extend Component.
* *
* @return void * @return void
*/ */
@ -547,6 +547,11 @@ class UpgradeShell extends AppShell {
'/([a-zA-Z]*Component extends) Object/', '/([a-zA-Z]*Component extends) Object/',
'\1 Component' '\1 Component'
), ),
array(
'*Component extends CakeObject to *Component extends Component',
'/([a-zA-Z]*Component extends) CakeObject/',
'\1 Component'
),
); );
$this->_filesRegexpUpdate($patterns); $this->_filesRegexpUpdate($patterns);

View file

@ -28,7 +28,7 @@ App::uses('File', 'Utility');
* *
* @package Cake.Console * @package Cake.Console
*/ */
class Shell extends Object { class Shell extends CakeObject {
/** /**
* Default error code * Default error code
@ -369,7 +369,7 @@ class Shell extends Object {
} }
/** /**
* Dispatch a command to another Shell. Similar to Object::requestAction() * Dispatch a command to another Shell. Similar to CakeObject::requestAction()
* but intended for running shells from other shells. * but intended for running shells from other shells.
* *
* ### Usage: * ### Usage:

View file

@ -37,7 +37,7 @@ App::uses('ComponentCollection', 'Controller');
* @link http://book.cakephp.org/2.0/en/controllers/components.html * @link http://book.cakephp.org/2.0/en/controllers/components.html
* @see Controller::$components * @see Controller::$components
*/ */
class Component extends Object { class Component extends CakeObject {
/** /**
* Component collection class used to lazy load components. * Component collection class used to lazy load components.

View file

@ -37,7 +37,7 @@ App::uses('ClassRegistry', 'Utility');
* *
* @package Cake.Controller.Component.Acl * @package Cake.Controller.Component.Acl
*/ */
class DbAcl extends Object implements AclInterface { class DbAcl extends CakeObject implements AclInterface {
/** /**
* Constructor * Constructor

View file

@ -22,7 +22,7 @@ App::uses('AclInterface', 'Controller/Component/Acl');
* *
* @package Cake.Controller.Component.Acl * @package Cake.Controller.Component.Acl
*/ */
class IniAcl extends Object implements AclInterface { class IniAcl extends CakeObject implements AclInterface {
/** /**
* Array with configuration, parsed from ini file * Array with configuration, parsed from ini file

View file

@ -22,7 +22,7 @@
* *
* @package Cake.Controller.Component.Acl * @package Cake.Controller.Component.Acl
*/ */
class PhpAcl extends Object implements AclInterface { class PhpAcl extends CakeObject implements AclInterface {
/** /**
* Constant for deny * Constant for deny

View file

@ -55,7 +55,7 @@ App::uses('CakeEventManager', 'Event');
* @property FlashComponent $Flash * @property FlashComponent $Flash
* @link http://book.cakephp.org/2.0/en/controllers.html * @link http://book.cakephp.org/2.0/en/controllers.html
*/ */
class Controller extends Object implements CakeEventListener { class Controller extends CakeObject implements CakeEventListener {
/** /**
* The name of this controller. Controller names are plural, named after the model they manipulate. * The name of this controller. Controller names are plural, named after the model they manipulate.

View file

@ -20,14 +20,14 @@ App::uses('Router', 'Routing');
App::uses('Set', 'Utility'); App::uses('Set', 'Utility');
/** /**
* Object class provides a few generic methods used in several subclasses. * CakeObject class provides a few generic methods used in several subclasses.
* *
* Also includes methods for logging and the special method RequestAction, * Also includes methods for logging and the special method RequestAction,
* to call other Controllers' Actions from anywhere. * to call other Controllers' Actions from anywhere.
* *
* @package Cake.Core * @package Cake.Core
*/ */
class Object { class CakeObject {
/** /**
* Constructor, no-op * Constructor, no-op
@ -36,7 +36,7 @@ class Object {
} }
/** /**
* Object-to-string conversion. * CakeObject-to-string conversion.
* Each class can override this method as necessary. * Each class can override this method as necessary.
* *
* @return string The name of this class * @return string The name of this class

View file

@ -26,7 +26,7 @@ App::uses('File', 'Utility');
* *
* @package Cake.Model * @package Cake.Model
*/ */
class CakeSchema extends Object { class CakeSchema extends CakeObject {
/** /**
* Name of the schema. * Name of the schema.

View file

@ -24,7 +24,7 @@
* @link http://book.cakephp.org/2.0/en/models/datasources.html#basic-api-for-datasources * @link http://book.cakephp.org/2.0/en/models/datasources.html#basic-api-for-datasources
* @package Cake.Model.Datasource * @package Cake.Model.Datasource
*/ */
class DataSource extends Object { class DataSource extends CakeObject {
/** /**
* Are we connected to the DataSource? * Are we connected to the DataSource?

View file

@ -42,7 +42,7 @@ App::uses('CakeEventManager', 'Event');
* @package Cake.Model * @package Cake.Model
* @link http://book.cakephp.org/2.0/en/models.html * @link http://book.cakephp.org/2.0/en/models.html
*/ */
class Model extends Object implements CakeEventListener { class Model extends CakeObject implements CakeEventListener {
/** /**
* The name of the DataSource connection that this Model uses * The name of the DataSource connection that this Model uses

View file

@ -61,7 +61,7 @@
* @see Model::$actsAs * @see Model::$actsAs
* @see BehaviorCollection::load() * @see BehaviorCollection::load()
*/ */
class ModelBehavior extends Object { class ModelBehavior extends CakeObject {
/** /**
* Contains configuration settings for use with individual model objects. This * Contains configuration settings for use with individual model objects. This

View file

@ -28,7 +28,7 @@ App::uses('Validation', 'Utility');
class CakeSocket { class CakeSocket {
/** /**
* Object description * CakeSocket description
* *
* @var string * @var string
*/ */
@ -410,7 +410,7 @@ class CakeSocket {
} }
/** /**
* Resets the state of this Socket instance to it's initial state (before Object::__construct got executed) * Resets the state of this Socket instance to it's initial state (before CakeObject::__construct got executed)
* *
* @param array $state Array with key and values to reset * @param array $state Array with key and values to reset
* @return bool True on success * @return bool True on success

View file

@ -1023,7 +1023,7 @@ class HttpSocket extends CakeSocket {
} }
/** /**
* Resets the state of this HttpSocket instance to it's initial state (before Object::__construct got executed) or does * Resets the state of this HttpSocket instance to it's initial state (before CakeObject::__construct got executed) or does
* the same thing partially for the request and the response property only. * the same thing partially for the request and the response property only.
* *
* @param bool $full If set to false only HttpSocket::response and HttpSocket::request are reset * @param bool $full If set to false only HttpSocket::response and HttpSocket::request are reset

View file

@ -664,7 +664,7 @@ class Router {
* created later in the request. * created later in the request.
* *
* Nested requests will create a stack of requests. You can remove requests using * Nested requests will create a stack of requests. You can remove requests using
* Router::popRequest(). This is done automatically when using Object::requestAction(). * Router::popRequest(). This is done automatically when using CakeObject::requestAction().
* *
* Will accept either a CakeRequest object or an array of arrays. Support for * Will accept either a CakeRequest object or an array of arrays. Support for
* accepting arrays may be removed in the future. * accepting arrays may be removed in the future.

View file

@ -487,9 +487,9 @@ class ShellDispatcherTest extends CakeTestCase {
*/ */
public function testDispatchNotAShellWithMain() { public function testDispatchNotAShellWithMain() {
$Dispatcher = new TestShellDispatcher(); $Dispatcher = new TestShellDispatcher();
$methods = get_class_methods('Object'); $methods = get_class_methods('CakeObject');
array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret'); array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret');
$Shell = $this->getMock('Object', $methods); $Shell = $this->getMock('CakeObject', $methods);
$Shell->expects($this->never())->method('initialize'); $Shell->expects($this->never())->method('initialize');
$Shell->expects($this->once())->method('startup'); $Shell->expects($this->once())->method('startup');
@ -501,7 +501,7 @@ class ShellDispatcherTest extends CakeTestCase {
$this->assertTrue($result); $this->assertTrue($result);
$this->assertEquals(array(), $Dispatcher->args); $this->assertEquals(array(), $Dispatcher->args);
$Shell = $this->getMock('Object', $methods); $Shell = $this->getMock('CakeObject', $methods);
$Shell->expects($this->once())->method('initdb')->will($this->returnValue(true)); $Shell->expects($this->once())->method('initdb')->will($this->returnValue(true));
$Shell->expects($this->once())->method('startup'); $Shell->expects($this->once())->method('startup');
$Dispatcher->TestShell = $Shell; $Dispatcher->TestShell = $Shell;
@ -518,9 +518,9 @@ class ShellDispatcherTest extends CakeTestCase {
*/ */
public function testDispatchNotAShellWithoutMain() { public function testDispatchNotAShellWithoutMain() {
$Dispatcher = new TestShellDispatcher(); $Dispatcher = new TestShellDispatcher();
$methods = get_class_methods('Object'); $methods = get_class_methods('CakeObject');
array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret'); array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret');
$Shell = $this->getMock('Object', $methods); $Shell = $this->getMock('CakeObject', $methods);
$Shell->expects($this->never())->method('initialize'); $Shell->expects($this->never())->method('initialize');
$Shell->expects($this->once())->method('startup'); $Shell->expects($this->once())->method('startup');
@ -532,7 +532,7 @@ class ShellDispatcherTest extends CakeTestCase {
$this->assertTrue($result); $this->assertTrue($result);
$this->assertEquals(array(), $Dispatcher->args); $this->assertEquals(array(), $Dispatcher->args);
$Shell = $this->getMock('Object', $methods); $Shell = $this->getMock('CakeObject', $methods);
$Shell->expects($this->once())->method('initdb')->will($this->returnValue(true)); $Shell->expects($this->once())->method('initdb')->will($this->returnValue(true));
$Shell->expects($this->once())->method('startup'); $Shell->expects($this->once())->method('startup');
$Dispatcher->TestShell = $Shell; $Dispatcher->TestShell = $Shell;

View file

@ -108,7 +108,7 @@ class TestAuthComponent extends AuthComponent {
* Helper method to add/set an authorize object instance * Helper method to add/set an authorize object instance
* *
* @param int $index The index at which to add/set the object * @param int $index The index at which to add/set the object
* @param Object $object The object to add/set * @param object $object The object to add/set
* @return void * @return void
*/ */
public function setAuthorizeObject($index, $object) { public function setAuthorizeObject($index, $object) {

View file

@ -135,7 +135,7 @@ class SessionComponentTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testSessionIdConsistentAcrossRequestAction() { public function testSessionIdConsistentAcrossRequestAction() {
$Object = new Object(); $Object = new CakeObject();
$Session = new SessionComponent($this->ComponentCollection); $Session = new SessionComponent($this->ComponentCollection);
$expected = $Session->id(); $expected = $Session->id();

View file

@ -47,7 +47,7 @@ class MergeVarsAppController extends Controller {
* *
* @package Cake.Test.Case.Controller * @package Cake.Test.Case.Controller
*/ */
class MergeVarComponent extends Object { class MergeVarComponent extends CakeObject {
} }

View file

@ -284,7 +284,7 @@ class TestController extends ControllerTestAppController {
* *
* @package Cake.Test.Case.Controller * @package Cake.Test.Case.Controller
*/ */
class TestComponent extends Object { class TestComponent extends CakeObject {
/** /**
* beforeRedirect method * beforeRedirect method

View file

@ -16,7 +16,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
App::uses('Object', 'Core'); App::uses('CakeObject', 'Core');
App::uses('Router', 'Routing'); App::uses('Router', 'Routing');
App::uses('Controller', 'Controller'); App::uses('Controller', 'Controller');
App::uses('Model', 'Model'); App::uses('Model', 'Model');
@ -128,11 +128,11 @@ class RequestActionController extends Controller {
} }
/** /**
* TestObject class * TestCakeObject class
* *
* @package Cake.Test.Case.Core * @package Cake.Test.Case.Core
*/ */
class TestObject extends Object { class TestCakeObject extends CakeObject {
/** /**
* firstName property * firstName property
@ -274,7 +274,7 @@ class ObjectTestModel extends CakeTestModel {
} }
/** /**
* Object Test class * CakeObject Test class
* *
* @package Cake.Test.Case.Core * @package Cake.Test.Case.Core
*/ */
@ -294,7 +294,7 @@ class ObjectTest extends CakeTestCase {
*/ */
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->object = new TestObject(); $this->object = new TestCakeObject();
} }
/** /**
@ -394,7 +394,7 @@ class ObjectTest extends CakeTestCase {
$expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7)); $expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7));
$this->assertSame($expected, $this->object->methodCalls); $this->assertSame($expected, $this->object->methodCalls);
$this->object = new TestObject(); $this->object = new TestCakeObject();
$this->assertSame($this->object->methodCalls, array()); $this->assertSame($this->object->methodCalls, array());
$this->object->dispatchMethod('emptyMethod'); $this->object->dispatchMethod('emptyMethod');

View file

@ -41,7 +41,7 @@ class TestAuthor extends Author {
/** /**
* Helper method to set a datasource object * Helper method to set a datasource object
* *
* @param Object $object The datasource object * @param object $object The datasource object
* @return void * @return void
*/ */
public function setDataSourceObject($object) { public function setDataSourceObject($object) {
@ -81,7 +81,7 @@ class TestPost extends Post {
/** /**
* Helper method to set a datasource object * Helper method to set a datasource object
* *
* @param Object $object The datasource object * @param object $object The datasource object
* @return void * @return void
*/ */
public function setDataSourceObject($object) { public function setDataSourceObject($object) {

View file

@ -1779,7 +1779,7 @@ class HttpSocketTest extends CakeTestCase {
} }
/** /**
* This tests asserts HttpSocket::reset() resets a HttpSocket instance to it's initial state (before Object::__construct * This tests asserts HttpSocket::reset() resets a HttpSocket instance to it's initial state (before CakeObject::__construct
* got executed) * got executed)
* *
* @return void * @return void
@ -1803,7 +1803,7 @@ class HttpSocketTest extends CakeTestCase {
/** /**
* This tests asserts HttpSocket::reset(false) resets certain HttpSocket properties to their initial state (before * This tests asserts HttpSocket::reset(false) resets certain HttpSocket properties to their initial state (before
* Object::__construct got executed). * CakeObject::__construct got executed).
* *
* @return void * @return void
*/ */

View file

@ -2454,7 +2454,7 @@ class RouterTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testCustomRouteException() { public function testCustomRouteException() {
Router::connect('/:controller', array(), array('routeClass' => 'Object')); Router::connect('/:controller', array(), array('routeClass' => 'CakeObject'));
} }
/** /**
@ -2801,7 +2801,7 @@ class RouterTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testSettingInvalidDefaultRouteException() { public function testSettingInvalidDefaultRouteException() {
Router::defaultRouteClass('Object'); Router::defaultRouteClass('CakeObject');
} }
/** /**

View file

@ -545,7 +545,7 @@ class CakeTimeTest extends CakeTestCase {
$expected = date('l jS \of F Y h:i:s A', $time); $expected = date('l jS \of F Y h:i:s A', $time);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$this->assertFalse($this->Time->toServer(time(), new Object())); $this->assertFalse($this->Time->toServer(time(), new CakeObject()));
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');

View file

@ -38,7 +38,7 @@ class GenericObject {
} }
/** /**
* First Extension of Generic Object * First Extension of Generic CakeObject
*/ */
class FirstGenericObject extends GenericObject { class FirstGenericObject extends GenericObject {
@ -53,7 +53,7 @@ class FirstGenericObject extends GenericObject {
} }
/** /**
* Second Extension of Generic Object * Second Extension of Generic CakeObject
*/ */
class SecondGenericObject extends GenericObject { class SecondGenericObject extends GenericObject {
@ -66,7 +66,7 @@ class SecondGenericObject extends GenericObject {
} }
/** /**
* Third Extension of Generic Object * Third Extension of Generic CakeObject
*/ */
class ThirdGenericObject extends GenericObject { class ThirdGenericObject extends GenericObject {
@ -86,7 +86,7 @@ class GenericObjectCollection extends ObjectCollection {
/** /**
* Loads a generic object * Loads a generic object
* *
* @param string $object Object name * @param string $object CakeObject name
* @param array $settings Settings array * @param array $settings Settings array
* @return array List of loaded objects * @return array List of loaded objects
*/ */
@ -109,7 +109,7 @@ class GenericObjectCollection extends ObjectCollection {
* settings * settings
* *
* @param string $name Name of the object * @param string $name Name of the object
* @param Object $object The object to use * @param CakeObject $object The object to use
* @param array $settings Settings to apply for the object * @param array $settings Settings to apply for the object
* @return array Loaded objects * @return array Loaded objects
*/ */
@ -542,7 +542,7 @@ class ObjectCollectionTest extends CakeTestCase {
$this->Objects->setObject('TriggerMockFirst', $this->FirstGenericObject); $this->Objects->setObject('TriggerMockFirst', $this->FirstGenericObject);
$this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject); $this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject);
$subjectClass = new Object(); $subjectClass = new CakeObject();
$this->Objects->TriggerMockFirst->expects($this->once()) $this->Objects->TriggerMockFirst->expects($this->once())
->method('callback') ->method('callback')
->with($subjectClass, 'first argument') ->with($subjectClass, 'first argument')
@ -568,7 +568,7 @@ class ObjectCollectionTest extends CakeTestCase {
$this->Objects->setObject('TriggerMockFirst', $this->FirstGenericObject); $this->Objects->setObject('TriggerMockFirst', $this->FirstGenericObject);
$this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject); $this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject);
$subjectClass = new Object(); $subjectClass = new CakeObject();
$this->Objects->TriggerMockFirst->expects($this->once()) $this->Objects->TriggerMockFirst->expects($this->once())
->method('callback') ->method('callback')
->with('first argument') ->with('first argument')

View file

@ -308,7 +308,7 @@ abstract class ObjectCollection {
* Adds or overwrites an instantiated object to the collection * Adds or overwrites an instantiated object to the collection
* *
* @param string $name Name of the object * @param string $name Name of the object
* @param Object $object The object to use * @param CakeObject $object The object to use
* @return array Loaded objects * @return array Loaded objects
*/ */
public function set($name = null, $object = null) { public function set($name = null, $object = null) {

View file

@ -24,7 +24,7 @@ App::uses('Inflector', 'Utility');
* *
* @package Cake.View * @package Cake.View
*/ */
class Helper extends Object { class Helper extends CakeObject {
/** /**
* Settings for this helper. * Settings for this helper.

View file

@ -53,7 +53,7 @@ App::uses('CakeResponse', 'Network');
* @property TimeHelper $Time * @property TimeHelper $Time
* @property ViewBlock $Blocks * @property ViewBlock $Blocks
*/ */
class View extends Object { class View extends CakeObject {
/** /**
* Helpers collection * Helpers collection

View file

@ -145,7 +145,7 @@ App::uses('ErrorHandler', 'Error');
App::uses('Configure', 'Core'); App::uses('Configure', 'Core');
App::uses('CakePlugin', 'Core'); App::uses('CakePlugin', 'Core');
App::uses('Cache', 'Cache'); App::uses('Cache', 'Cache');
App::uses('Object', 'Core'); App::uses('CakeObject', 'Core');
App::uses('Multibyte', 'I18n'); App::uses('Multibyte', 'I18n');
App::$bootstrapping = true; App::$bootstrapping = true;