Skip to content

Commit

Permalink
Refactor Object to CakeObject for future PHP7 comp.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Apr 8, 2016
1 parent 96c9521 commit dda9e83
Show file tree
Hide file tree
Showing 30 changed files with 58 additions and 53 deletions.
7 changes: 6 additions & 1 deletion lib/Cake/Console/Command/UpgradeShell.php
Expand Up @@ -532,7 +532,7 @@ public function controller_redirects() {
/**
* Update components.
*
* - Make components that extend Object to extend Component.
* - Make components that extend CakeObject to extend Component.
*
* @return void
*/
Expand All @@ -547,6 +547,11 @@ public function components() {
'/([a-zA-Z]*Component extends) Object/',
'\1 Component'
),
array(
'*Component extends CakeObject to *Component extends Component',
'/([a-zA-Z]*Component extends) CakeObject/',
'\1 Component'
),
);

$this->_filesRegexpUpdate($patterns);
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Shell.php
Expand Up @@ -28,7 +28,7 @@
*
* @package Cake.Console
*/
class Shell extends Object {
class Shell extends CakeObject {

/**
* Default error code
Expand Down Expand Up @@ -369,7 +369,7 @@ public function hasMethod($name) {
}

/**
* 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.
*
* ### Usage:
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component.php
Expand Up @@ -37,7 +37,7 @@
* @link http://book.cakephp.org/2.0/en/controllers/components.html
* @see Controller::$components
*/
class Component extends Object {
class Component extends CakeObject {

/**
* Component collection class used to lazy load components.
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/Acl/DbAcl.php
Expand Up @@ -37,7 +37,7 @@
*
* @package Cake.Controller.Component.Acl
*/
class DbAcl extends Object implements AclInterface {
class DbAcl extends CakeObject implements AclInterface {

/**
* Constructor
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/Acl/IniAcl.php
Expand Up @@ -22,7 +22,7 @@
*
* @package Cake.Controller.Component.Acl
*/
class IniAcl extends Object implements AclInterface {
class IniAcl extends CakeObject implements AclInterface {

/**
* Array with configuration, parsed from ini file
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/Acl/PhpAcl.php
Expand Up @@ -22,7 +22,7 @@
*
* @package Cake.Controller.Component.Acl
*/
class PhpAcl extends Object implements AclInterface {
class PhpAcl extends CakeObject implements AclInterface {

/**
* Constant for deny
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Controller.php
Expand Up @@ -55,7 +55,7 @@
* @property FlashComponent $Flash
* @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.
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Core/Object.php → lib/Cake/Core/CakeObject.php
Expand Up @@ -20,14 +20,14 @@
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,
* to call other Controllers' Actions from anywhere.
*
* @package Cake.Core
*/
class Object {
class CakeObject {

/**
* Constructor, no-op
Expand All @@ -36,7 +36,7 @@ public function __construct() {
}

/**
* Object-to-string conversion.
* CakeObject-to-string conversion.
* Each class can override this method as necessary.
*
* @return string The name of this class
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/CakeSchema.php
Expand Up @@ -26,7 +26,7 @@
*
* @package Cake.Model
*/
class CakeSchema extends Object {
class CakeSchema extends CakeObject {

/**
* Name of the schema.
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/DataSource.php
Expand Up @@ -24,7 +24,7 @@
* @link http://book.cakephp.org/2.0/en/models/datasources.html#basic-api-for-datasources
* @package Cake.Model.Datasource
*/
class DataSource extends Object {
class DataSource extends CakeObject {

/**
* Are we connected to the DataSource?
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Model.php
Expand Up @@ -42,7 +42,7 @@
* @package Cake.Model
* @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
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/ModelBehavior.php
Expand Up @@ -61,7 +61,7 @@
* @see Model::$actsAs
* @see BehaviorCollection::load()
*/
class ModelBehavior extends Object {
class ModelBehavior extends CakeObject {

/**
* Contains configuration settings for use with individual model objects. This
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Network/CakeSocket.php
Expand Up @@ -28,7 +28,7 @@
class CakeSocket {

/**
* Object description
* CakeSocket description
*
* @var string
*/
Expand Down Expand Up @@ -410,7 +410,7 @@ public function __destruct() {
}

/**
* 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
* @return bool True on success
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/Http/HttpSocket.php
Expand Up @@ -1023,7 +1023,7 @@ protected function _tokenEscapeChars($hex = true, $chars = null) {
}

/**
* 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.
*
* @param bool $full If set to false only HttpSocket::response and HttpSocket::request are reset
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Routing/Router.php
Expand Up @@ -664,7 +664,7 @@ protected static function _parseExtension($url) {
* created later in the request.
*
* 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
* accepting arrays may be removed in the future.
Expand Down
12 changes: 6 additions & 6 deletions lib/Cake/Test/Case/Console/ShellDispatcherTest.php
Expand Up @@ -487,9 +487,9 @@ public function testDispatchShellWithoutMain() {
*/
public function testDispatchNotAShellWithMain() {
$Dispatcher = new TestShellDispatcher();
$methods = get_class_methods('Object');
$methods = get_class_methods('CakeObject');
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->once())->method('startup');
Expand All @@ -501,7 +501,7 @@ public function testDispatchNotAShellWithMain() {
$this->assertTrue($result);
$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('startup');
$Dispatcher->TestShell = $Shell;
Expand All @@ -518,9 +518,9 @@ public function testDispatchNotAShellWithMain() {
*/
public function testDispatchNotAShellWithoutMain() {
$Dispatcher = new TestShellDispatcher();
$methods = get_class_methods('Object');
$methods = get_class_methods('CakeObject');
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->once())->method('startup');
Expand All @@ -532,7 +532,7 @@ public function testDispatchNotAShellWithoutMain() {
$this->assertTrue($result);
$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('startup');
$Dispatcher->TestShell = $Shell;
Expand Down
Expand Up @@ -108,7 +108,7 @@ public function getAuthenticateObject($index) {
* Helper method to add/set an authorize object instance
*
* @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

This comment has been minimized.

Copy link
@garethellis36

garethellis36 Apr 8, 2016

Contributor

Should this type-hint be for CakeObject?

This comment has been minimized.

Copy link
@ravage84

ravage84 Apr 11, 2016

Member

Not, if you look at the related getter method:

This comment has been minimized.

Copy link
@dereuromark

dereuromark Apr 11, 2016

Author Member

@ravage84 I changed both of them to CakeObject, but you are right, those need to say just object or of type https://github.com/cakephp/cakephp/blob/2.x/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php#L24 even.

* @return void
*/
public function setAuthorizeObject($index, $object) {
Expand Down
Expand Up @@ -135,7 +135,7 @@ public function tearDown() {
* @return void
*/
public function testSessionIdConsistentAcrossRequestAction() {
$Object = new Object();
$Object = new CakeObject();
$Session = new SessionComponent($this->ComponentCollection);
$expected = $Session->id();

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Controller/ControllerMergeVarsTest.php
Expand Up @@ -47,7 +47,7 @@ class MergeVarsAppController extends Controller {
*
* @package Cake.Test.Case.Controller
*/
class MergeVarComponent extends Object {
class MergeVarComponent extends CakeObject {

}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Controller/ControllerTest.php
Expand Up @@ -284,7 +284,7 @@ public function admin_add() {
*
* @package Cake.Test.Case.Controller
*/
class TestComponent extends Object {
class TestComponent extends CakeObject {

/**
* beforeRedirect method
Expand Down
12 changes: 6 additions & 6 deletions lib/Cake/Test/Case/Core/ObjectTest.php
Expand Up @@ -16,7 +16,7 @@
* @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('Controller', 'Controller');
App::uses('Model', 'Model');
Expand Down Expand Up @@ -128,11 +128,11 @@ public function param_check() {
}

/**
* TestObject class
* TestCakeObject class
*
* @package Cake.Test.Case.Core
*/
class TestObject extends Object {
class TestCakeObject extends CakeObject {

/**
* firstName property
Expand Down Expand Up @@ -274,7 +274,7 @@ class ObjectTestModel extends CakeTestModel {
}

/**
* Object Test class
* CakeObject Test class
*
* @package Cake.Test.Case.Core
*/
Expand All @@ -294,7 +294,7 @@ class ObjectTest extends CakeTestCase {
*/
public function setUp() {
parent::setUp();
$this->object = new TestObject();
$this->object = new TestCakeObject();
}

/**
Expand Down Expand Up @@ -394,7 +394,7 @@ public function testMethodDispatching() {
$expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7));
$this->assertSame($expected, $this->object->methodCalls);

$this->object = new TestObject();
$this->object = new TestCakeObject();
$this->assertSame($this->object->methodCalls, array());

$this->object->dispatchMethod('emptyMethod');
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Model/ModelWriteTest.php
Expand Up @@ -41,7 +41,7 @@ class TestAuthor extends Author {
/**
* Helper method to set a datasource object
*
* @param Object $object The datasource object
* @param object $object The datasource object
* @return void
*/
public function setDataSourceObject($object) {
Expand Down Expand Up @@ -81,7 +81,7 @@ class TestPost extends Post {
/**
* Helper method to set a datasource object
*
* @param Object $object The datasource object
* @param object $object The datasource object
* @return void
*/
public function setDataSourceObject($object) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
Expand Up @@ -1779,7 +1779,7 @@ public function testEscapeToken() {
}

/**
* 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)
*
* @return void
Expand All @@ -1803,7 +1803,7 @@ public function testReset() {

/**
* 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
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Routing/RouterTest.php
Expand Up @@ -2454,7 +2454,7 @@ public function testUsingCustomRouteClassPluginDotSyntax() {
* @return void
*/
public function testCustomRouteException() {
Router::connect('/:controller', array(), array('routeClass' => 'Object'));
Router::connect('/:controller', array(), array('routeClass' => 'CakeObject'));
}

/**
Expand Down Expand Up @@ -2801,7 +2801,7 @@ public function testDefaultRouteException() {
* @return void
*/
public function testSettingInvalidDefaultRouteException() {
Router::defaultRouteClass('Object');
Router::defaultRouteClass('CakeObject');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Utility/CakeTimeTest.php
Expand Up @@ -545,7 +545,7 @@ public function testToServer() {
$expected = date('l jS \of F Y h:i:s A', $time);
$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');

Expand Down

0 comments on commit dda9e83

Please sign in to comment.