From 9aa006e5eaaba18aae8ca32e54e0442b356bc1b3 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 21 Jan 2014 16:44:28 -0500 Subject: [PATCH] Removed implementation of `Arrayable` from `yii\Object` --- framework/CHANGELOG.md | 1 + framework/base/Model.php | 2 +- framework/base/Object.php | 12 +----------- framework/web/CookieCollection.php | 3 ++- framework/web/HeaderCollection.php | 3 ++- framework/web/Session.php | 3 ++- .../unit/framework/validators/FileValidatorTest.php | 4 ---- 7 files changed, 9 insertions(+), 19 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 50b7b0fb85..5365de3f86 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -113,6 +113,7 @@ Yii Framework 2 Change Log `index-test.php` and `yii` files to point to the new location of `Yii.php` (qiangxue, cebe) - Chg: Advanced app template: moved database connection DSN, login and password to `-local` config not to expose it to VCS (samdark) - Chg: Renamed `yii\web\Request::acceptedLanguages` to `acceptableLanguages` (qiangxue) +- Chg: Removed implementation of `Arrayable` from `yii\Object` (qiangxue) - New #66: [Auth client library](https://github.com/yiisoft/yii2-authclient) OpenId, OAuth1, OAuth2 clients (klimov-paul) - New #1393: [Codeception testing framework integration](https://github.com/yiisoft/yii2-codeception) (Ragazzo) - New #1438: [MongoDB integration](https://github.com/yiisoft/yii2-mongodb) ActiveRecord and Query (klimov-paul) diff --git a/framework/base/Model.php b/framework/base/Model.php index ba51ec792d..d4a476ad1d 100644 --- a/framework/base/Model.php +++ b/framework/base/Model.php @@ -52,7 +52,7 @@ use yii\validators\Validator; * @author Qiang Xue * @since 2.0 */ -class Model extends Component implements IteratorAggregate, ArrayAccess +class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayable { /** * The name of the default scenario. diff --git a/framework/base/Object.php b/framework/base/Object.php index 06fca50f80..4b1b95212e 100644 --- a/framework/base/Object.php +++ b/framework/base/Object.php @@ -17,7 +17,7 @@ use Yii; * @author Qiang Xue * @since 2.0 */ -class Object implements Arrayable +class Object { /** * @return string the fully qualified name of this class. @@ -227,14 +227,4 @@ class Object implements Arrayable { return method_exists($this, $name); } - - /** - * Converts the object into an array. - * The default implementation will return all public property values as an array. - * @return array the array representation of the object - */ - public function toArray() - { - return Yii::getObjectVars($this); - } } diff --git a/framework/web/CookieCollection.php b/framework/web/CookieCollection.php index 3cf80ffabb..503741d90d 100644 --- a/framework/web/CookieCollection.php +++ b/framework/web/CookieCollection.php @@ -9,6 +9,7 @@ namespace yii\web; use Yii; use ArrayIterator; +use yii\base\Arrayable; use yii\base\InvalidCallException; use yii\base\Object; @@ -22,7 +23,7 @@ use yii\base\Object; * @author Qiang Xue * @since 2.0 */ -class CookieCollection extends Object implements \IteratorAggregate, \ArrayAccess, \Countable +class CookieCollection extends Object implements \IteratorAggregate, \ArrayAccess, \Countable, Arrayable { /** * @var boolean whether this collection is read only. diff --git a/framework/web/HeaderCollection.php b/framework/web/HeaderCollection.php index e8e4f9c471..5ad1c62c81 100644 --- a/framework/web/HeaderCollection.php +++ b/framework/web/HeaderCollection.php @@ -8,6 +8,7 @@ namespace yii\web; use Yii; +use yii\base\Arrayable; use yii\base\Object; use ArrayIterator; @@ -21,7 +22,7 @@ use ArrayIterator; * @author Qiang Xue * @since 2.0 */ -class HeaderCollection extends Object implements \IteratorAggregate, \ArrayAccess, \Countable +class HeaderCollection extends Object implements \IteratorAggregate, \ArrayAccess, \Countable, Arrayable { /** * @var array the headers in this collection (indexed by the header names) diff --git a/framework/web/Session.php b/framework/web/Session.php index 664596da89..0ea60ed411 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -8,6 +8,7 @@ namespace yii\web; use Yii; +use yii\base\Arrayable; use yii\base\Component; use yii\base\InvalidConfigException; use yii\base\InvalidParamException; @@ -71,7 +72,7 @@ use yii\base\InvalidParamException; * @author Qiang Xue * @since 2.0 */ -class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Countable +class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Countable, Arrayable { /** * @var boolean whether the session should be automatically started when the session component is initialized. diff --git a/tests/unit/framework/validators/FileValidatorTest.php b/tests/unit/framework/validators/FileValidatorTest.php index 5926d7ad20..b93429ab68 100644 --- a/tests/unit/framework/validators/FileValidatorTest.php +++ b/tests/unit/framework/validators/FileValidatorTest.php @@ -239,7 +239,6 @@ class FileValidatorTest extends TestCase $val->validateAttribute($m, 'attr_err_part'); $this->assertTrue($m->hasErrors('attr_err_part')); $this->assertSame(Yii::t('yii', 'File upload failed.'), current($m->getErrors('attr_err_part'))); - $log = Yii::$app->getLog()->toArray(); } public function testValidateAttributeErrCantWrite() @@ -249,7 +248,6 @@ class FileValidatorTest extends TestCase $val->validateAttribute($m, 'attr_err_write'); $this->assertTrue($m->hasErrors('attr_err_write')); $this->assertSame(Yii::t('yii', 'File upload failed.'), current($m->getErrors('attr_err_write'))); - $log = Yii::$app->getLog()->toArray(); } public function testValidateAttributeErrExtension() @@ -259,7 +257,6 @@ class FileValidatorTest extends TestCase $val->validateAttribute($m, 'attr_err_ext'); $this->assertTrue($m->hasErrors('attr_err_ext')); $this->assertSame(Yii::t('yii', 'File upload failed.'), current($m->getErrors('attr_err_ext'))); - $log = Yii::$app->getLog()->toArray(); } public function testValidateAttributeErrNoTmpDir() @@ -269,6 +266,5 @@ class FileValidatorTest extends TestCase $val->validateAttribute($m, 'attr_err_tmp'); $this->assertTrue($m->hasErrors('attr_err_tmp')); $this->assertSame(Yii::t('yii', 'File upload failed.'), current($m->getErrors('attr_err_tmp'))); - $log = Yii::$app->getLog()->toArray(); } }