Skip to content

Commit 6895e33

Browse files
committed
Issues [#1, #2] fixed
1 parent 2f51d96 commit 6895e33

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1+
# yii console command
2+
/yii
3+
4+
# phpstorm project files
5+
.idea
6+
7+
# netbeans project files
18
nbproject
9+
10+
# zend studio for eclipse project files
11+
.buildpath
12+
.project
13+
.settings
14+
15+
# windows thumbnail cache
16+
Thumbs.db
17+
18+
# composer vendor dir
19+
/vendor
20+
21+
# composer itself is not needed
22+
composer.phar
23+
24+
# Mac DS_Store Files
25+
.DS_Store
26+
.AppleDouble
27+
28+
# phpunit itself is not needed
29+
phpunit.phar
30+
31+
# local phpunit config
32+
/phpunit.xml
33+
34+
# composer lock
35+
composer.lock

src/ActiveRecordInheritanceTrait.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use yii\base\Exception as BaseException;
1616
use Yii;
1717
use Exception;
18+
use yii\db\ActiveRecord;
1819

1920
/**
2021
* Trait to simulate inheritance between two ActiveRecordInterface classes.
@@ -199,7 +200,10 @@ public function attributeLabels() {
199200
* @return array attribute values (name => value).
200201
*/
201202
public function getAttributes($names = null, $except = array()) {
202-
return array_merge($this->_parent()->getAttributes($names, $except), parent::getAttributes($names, $except));
203+
if ($names === null) {
204+
$names = array_merge($this->_parent()->attributes(), $this->attributes());
205+
}
206+
return parent::getAttributes($names, $except);
203207
}
204208

205209
/**
@@ -366,7 +370,7 @@ public function getFirstErrors() {
366370
*/
367371
public function getFirstError($attribute) {
368372
$errors = $this->getErrors($attribute);
369-
return empty($errors[$attribute]) ? null : $errors[0];
373+
return count($errors) ? $errors[0] : null;
370374
}
371375

372376
/**

0 commit comments

Comments
 (0)