Browse Source

Removing Object class.

Renan Gonçalves 12 years ago
parent
commit
18d7edb1b3

+ 1 - 2
src/Console/Shell.php

@@ -17,7 +17,6 @@ namespace Cake\Console;
 use Cake\Console\ConsoleIo;
 use Cake\Core\App;
 use Cake\Core\Configure;
-use Cake\Core\Object;
 use Cake\Core\Plugin;
 use Cake\Model\ModelAwareTrait;
 use Cake\Utility\ConventionsTrait;
@@ -31,7 +30,7 @@ use Cake\Utility\String;
  *
  * Is the equivalent of Cake\Controller\Controller on the command line.
  */
-class Shell extends Object {
+class Shell {
 
 	use MergeVariablesTrait;
 	use ModelAwareTrait;

+ 1 - 2
src/Controller/Component.php

@@ -15,7 +15,6 @@
 namespace Cake\Controller;
 
 use Cake\Core\InstanceConfigTrait;
-use Cake\Core\Object;
 use Cake\Event\Event;
 use Cake\Event\EventListener;
 
@@ -62,7 +61,7 @@ use Cake\Event\EventListener;
  * @link http://book.cakephp.org/2.0/en/controllers/components.html
  * @see Controller::$components
  */
-class Component extends Object implements EventListener {
+class Component implements EventListener {
 
 	use InstanceConfigTrait;
 

+ 1 - 2
src/Controller/Component/Acl/IniAcl.php

@@ -17,7 +17,6 @@ namespace Cake\Controller\Component\Acl;
 use Cake\Configure\Engine\IniConfig;
 use Cake\Controller\Component;
 use Cake\Core\InstanceConfigTrait;
-use Cake\Core\Object;
 use Cake\Utility\Hash;
 
 /**
@@ -25,7 +24,7 @@ use Cake\Utility\Hash;
  * of the ini file used can be found in /config/acl.ini.php.
  *
  */
-class IniAcl extends Object implements AclInterface {
+class IniAcl implements AclInterface {
 
 	use InstanceConfigTrait {
 		config as protected _traitConfig;

+ 1 - 2
src/Controller/Component/Acl/PhpAcl.php

@@ -18,7 +18,6 @@ namespace Cake\Controller\Component\Acl;
 
 use Cake\Configure\Engine\PhpConfig;
 use Cake\Controller\Component;
-use Cake\Core\Object;
 use Cake\Error;
 use Cake\Utility\Hash;
 use Cake\Utility\Inflector;
@@ -28,7 +27,7 @@ use Cake\Utility\Inflector;
  * An example file can be found in app/Config/acl.php
  *
  */
-class PhpAcl extends Object implements AclInterface {
+class PhpAcl implements AclInterface {
 
 /**
  * Constant for deny

+ 0 - 1
src/Controller/Component/AclComponent.php

@@ -20,7 +20,6 @@ use Cake\Controller\ComponentRegistry;
 use Cake\Controller\Component\Acl\AclInterface;
 use Cake\Core\App;
 use Cake\Core\Configure;
-use Cake\Core\Object;
 use Cake\Error;
 use Cake\Utility\ClassRegistry;
 use Cake\Utility\Inflector;

+ 1 - 2
src/Controller/Controller.php

@@ -16,7 +16,6 @@ namespace Cake\Controller;
 
 use Cake\Core\App;
 use Cake\Core\Configure;
-use Cake\Core\Object;
 use Cake\Core\Plugin;
 use Cake\Error\Exception;
 use Cake\Event\Event;
@@ -77,7 +76,7 @@ use Cake\View\ViewVarsTrait;
  * @property      \Cake\Controller\Component\SessionComponent $Session
  * @link          http://book.cakephp.org/2.0/en/controllers.html
  */
-class Controller extends Object implements EventListener {
+class Controller implements EventListener {
 
 	use CellTrait;
 	use MergeVariablesTrait;

+ 0 - 52
src/Core/Object.php

@@ -1,52 +0,0 @@
-<?php
-/**
- * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
- * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
- *
- * Licensed under The MIT License
- * For full copyright and license information, please see the LICENSE.txt
- * Redistributions of files must retain the above copyright notice.
- *
- * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
- * @link          http://cakephp.org CakePHP(tm) Project
- * @since         0.2.9
- * @license       http://www.opensource.org/licenses/mit-license.php MIT License
- */
-namespace Cake\Core;
-
-use Cake\Log\LogTrait;
-use Cake\Utility\Hash;
-
-/**
- * Object 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.
- *
- */
-class Object {
-
-	use LogTrait;
-
-/**
- * Object-to-string conversion.
- * Each class can override this method as necessary.
- *
- * @return string The name of this class
- */
-	public function toString() {
-		return get_class($this);
-	}
-
-/**
- * Stop execution of the current script. Wraps exit() making
- * testing easier.
- *
- * @param int|string $status see http://php.net/exit for values
- * @return void
- */
-	protected function _stop($status = 0) {
-		exit($status);
-	}
-
-}

+ 1 - 2
src/View/Helper.php

@@ -17,7 +17,6 @@ namespace Cake\View;
 use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\InstanceConfigTrait;
-use Cake\Core\Object;
 use Cake\Core\Plugin;
 use Cake\Event\EventListener;
 use Cake\Routing\Router;
@@ -46,7 +45,7 @@ use Cake\Utility\Inflector;
  *   If a listener returns a non-null value, the output of the rendered file will be set to that.
  *
  */
-class Helper extends Object implements EventListener {
+class Helper implements EventListener {
 
 	use InstanceConfigTrait;
 

+ 3 - 2
src/View/View.php

@@ -18,11 +18,11 @@ use Cake\Cache\Cache;
 use Cake\Controller\Controller;
 use Cake\Core\App;
 use Cake\Core\Configure;
-use Cake\Core\Object;
 use Cake\Core\Plugin;
 use Cake\Error\Exception;
 use Cake\Event\Event;
 use Cake\Event\EventManager;
+use Cake\Log\LogTrait;
 use Cake\Network\Request;
 use Cake\Network\Response;
 use Cake\Routing\RequestActionTrait;
@@ -58,9 +58,10 @@ use Cake\View\ViewVarsTrait;
  * @property      \Cake\View\Helper\TimeHelper $Time
  * @property      \Cake\View\ViewBlock $Blocks
  */
-class View extends Object {
+class View {
 
 	use CellTrait;
+	use LogTrait;
 	use RequestActionTrait;
 	use ViewVarsTrait;
 

+ 6 - 8
tests/TestCase/Console/ShellDispatcherTest.php

@@ -464,9 +464,8 @@ class ShellDispatcherTest extends TestCase {
  */
 	public function testDispatchNotAShellWithMain() {
 		$Dispatcher = new TestShellDispatcher();
-		$methods = get_class_methods('Cake\Core\Object');
-		array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret');
-		$Shell = $this->getMock('Cake\Core\Object', $methods);
+		$methods = ['main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret'];
+		$Shell = $this->getMock('stdClass', $methods);
 
 		$Shell->expects($this->never())->method('initialize');
 		$Shell->expects($this->once())->method('startup');
@@ -478,7 +477,7 @@ class ShellDispatcherTest extends TestCase {
 		$this->assertEquals(0, $result);
 		$this->assertEquals(array(), $Dispatcher->args);
 
-		$Shell = $this->getMock('Cake\Core\Object', $methods);
+		$Shell = $this->getMock('stdClass', $methods);
 		$Shell->expects($this->once())->method('initdb')->will($this->returnValue(true));
 		$Shell->expects($this->once())->method('startup');
 		$Dispatcher->TestShell = $Shell;
@@ -495,9 +494,8 @@ class ShellDispatcherTest extends TestCase {
  */
 	public function testDispatchNotAShellWithoutMain() {
 		$Dispatcher = new TestShellDispatcher();
-		$methods = get_class_methods('Cake\Core\Object');
-		array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret');
-		$Shell = $this->getMock('Cake\Core\Object', $methods);
+		$methods = ['main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret'];
+		$Shell = $this->getMock('stdClass', $methods);
 
 		$Shell->expects($this->never())->method('initialize');
 		$Shell->expects($this->once())->method('startup');
@@ -509,7 +507,7 @@ class ShellDispatcherTest extends TestCase {
 		$this->assertEquals(0, $result);
 		$this->assertEquals(array(), $Dispatcher->args);
 
-		$Shell = $this->getMock('Cake\Core\Object', $methods);
+		$Shell = $this->getMock('stdClass', $methods);
 		$Shell->expects($this->once())->method('initdb')->will($this->returnValue(true));
 		$Shell->expects($this->once())->method('startup');
 		$Dispatcher->TestShell = $Shell;

+ 0 - 1
tests/TestCase/Controller/Component/SessionComponentTest.php

@@ -20,7 +20,6 @@ use Cake\Controller\ComponentRegistry;
 use Cake\Controller\Component\SessionComponent;
 use Cake\Controller\Controller;
 use Cake\Core\Configure;
-use Cake\Core\Object;
 use Cake\Network\Session;
 use Cake\Routing\Router;
 use Cake\TestSuite\TestCase;

+ 0 - 1
tests/TestCase/Controller/ControllerTest.php

@@ -18,7 +18,6 @@ use Cake\Controller\Component;
 use Cake\Controller\Controller;
 use Cake\Core\App;
 use Cake\Core\Configure;
-use Cake\Core\Object;
 use Cake\Core\Plugin;
 use Cake\Event\Event;
 use Cake\Network\Request;

+ 0 - 231
tests/TestCase/Core/ObjectTest.php

@@ -1,231 +0,0 @@
-<?php
-/**
- * ObjectTest file
- *
- * PHP 5
- *
- * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
- * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
- *
- * Licensed under The MIT License
- * Redistributions of files must retain the above copyright notice
- *
- * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
- * @link          http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
- * @since         1.2.0
- * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
- */
-namespace Cake\Test\TestCase\Core;
-
-use Cake\Core\App;
-use Cake\Core\Configure;
-use Cake\Core\Object;
-use Cake\Core\Plugin;
-use Cake\Log\Log;
-use Cake\Routing\Router;
-use Cake\TestSuite\TestCase;
-
-/**
- * TestObject class
- *
- */
-class TestObject extends Object {
-
-/**
- * firstName property
- *
- * @var string
- */
-	public $firstName = 'Joel';
-
-/**
- * lastName property
- *
- * @var string
- */
-	public $lastName = 'Moss';
-
-/**
- * methodCalls property
- *
- * @var array
- */
-	public $methodCalls = array();
-
-/**
- * emptyMethod method
- *
- * @return void
- */
-	public function emptyMethod() {
-		$this->methodCalls[] = 'emptyMethod';
-	}
-
-/**
- * oneParamMethod method
- *
- * @param mixed $param
- * @return void
- */
-	public function oneParamMethod($param) {
-		$this->methodCalls[] = array('oneParamMethod' => array($param));
-	}
-
-/**
- * twoParamMethod method
- *
- * @param mixed $param
- * @param mixed $paramTwo
- * @return void
- */
-	public function twoParamMethod($param, $paramTwo) {
-		$this->methodCalls[] = array('twoParamMethod' => array($param, $paramTwo));
-	}
-
-/**
- * threeParamMethod method
- *
- * @param mixed $param
- * @param mixed $paramTwo
- * @param mixed $paramThree
- * @return void
- */
-	public function threeParamMethod($param, $paramTwo, $paramThree) {
-		$this->methodCalls[] = array('threeParamMethod' => array($param, $paramTwo, $paramThree));
-	}
-
-/**
- * fourParamMethod method
- *
- * @param mixed $param
- * @param mixed $paramTwo
- * @param mixed $paramThree
- * @param mixed $paramFour
- * @return void
- */
-	public function fourParamMethod($param, $paramTwo, $paramThree, $paramFour) {
-		$this->methodCalls[] = array('fourParamMethod' => array($param, $paramTwo, $paramThree, $paramFour));
-	}
-
-/**
- * fiveParamMethod method
- *
- * @param mixed $param
- * @param mixed $paramTwo
- * @param mixed $paramThree
- * @param mixed $paramFour
- * @param mixed $paramFive
- * @return void
- */
-	public function fiveParamMethod($param, $paramTwo, $paramThree, $paramFour, $paramFive) {
-		$this->methodCalls[] = array('fiveParamMethod' => array($param, $paramTwo, $paramThree, $paramFour, $paramFive));
-	}
-
-/**
- * crazyMethod method
- *
- * @param mixed $param
- * @param mixed $paramTwo
- * @param mixed $paramThree
- * @param mixed $paramFour
- * @param mixed $paramFive
- * @param mixed $paramSix
- * @param mixed $paramSeven
- * @return void
- */
-	public function crazyMethod($param, $paramTwo, $paramThree, $paramFour, $paramFive, $paramSix, $paramSeven = null) {
-		$this->methodCalls[] = array('crazyMethod' => array($param, $paramTwo, $paramThree, $paramFour, $paramFive, $paramSix, $paramSeven));
-	}
-
-/**
- * methodWithOptionalParam method
- *
- * @param mixed $param
- * @return void
- */
-	public function methodWithOptionalParam($param = null) {
-		$this->methodCalls[] = array('methodWithOptionalParam' => array($param));
-	}
-
-}
-
-/**
- * Object Test class
- *
- */
-class ObjectTest extends TestCase {
-
-/**
- * fixtures
- *
- * @var string
- */
-	public $fixtures = array('core.post', 'core.test_plugin_comment', 'core.comment');
-
-/**
- * setUp method
- *
- * @return void
- */
-	public function setUp() {
-		parent::setUp();
-		$this->object = new TestObject();
-		Configure::write('App.namespace', 'TestApp');
-		Configure::write('Security.salt', 'not-the-default');
-		Log::drop('stdout');
-		Log::drop('stderr');
-	}
-
-/**
- * tearDown method
- *
- * @return void
- */
-	public function tearDown() {
-		parent::tearDown();
-		Plugin::unload();
-		Log::reset();
-		unset($this->object);
-	}
-
-/**
- * testLog method
- *
- * @return void
- */
-	public function testLog() {
-		if (file_exists(LOGS . 'error.log')) {
-			unlink(LOGS . 'error.log');
-		}
-		$this->assertTrue($this->object->log('Test warning 1'));
-		$this->assertTrue($this->object->log(array('Test' => 'warning 2')));
-		$result = file(LOGS . 'error.log');
-		$this->assertRegExp('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Test warning 1$/', $result[0]);
-		$this->assertRegExp('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Array$/', $result[1]);
-		$this->assertRegExp('/^\($/', $result[2]);
-		$this->assertRegExp('/\[Test\] => warning 2$/', $result[3]);
-		$this->assertRegExp('/^\)$/', $result[4]);
-		unlink(LOGS . 'error.log');
-
-		$this->assertTrue($this->object->log('Test warning 1', LOG_WARNING));
-		$this->assertTrue($this->object->log(array('Test' => 'warning 2'), LOG_WARNING));
-		$result = file(LOGS . 'error.log');
-		$this->assertRegExp('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 1$/', $result[0]);
-		$this->assertRegExp('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Array$/', $result[1]);
-		$this->assertRegExp('/^\($/', $result[2]);
-		$this->assertRegExp('/\[Test\] => warning 2$/', $result[3]);
-		$this->assertRegExp('/^\)$/', $result[4]);
-		unlink(LOGS . 'error.log');
-	}
-
-/**
- * testToString method
- *
- * @return void
- */
-	public function testToString() {
-		$result = strtolower($this->object->toString());
-		$this->assertEquals(strtolower(__NAMESPACE__) . '\testobject', $result);
-	}
-
-}

+ 1 - 2
tests/TestCase/Utility/TimeTest.php

@@ -18,7 +18,6 @@ namespace Cake\Test\TestCase\Utility;
 
 use Cake\Core\App;
 use Cake\Core\Configure;
-use Cake\Core\Object;
 use Cake\TestSuite\TestCase;
 use Cake\Utility\Time;
 
@@ -495,7 +494,7 @@ class TimeTest extends TestCase {
 		$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 \stdClass()));
 
 		date_default_timezone_set('UTC');
 

+ 0 - 1
tests/test_app/Plugin/TestPlugin/Controller/Component/OtherComponent.php

@@ -19,7 +19,6 @@
 namespace TestPlugin\Controller\Component;
 
 use Cake\Controller\Component;
-use Cake\Core\Object;
 
 class OtherComponent extends Component {
 }