Update ely/php-code-style and run updated CS fixer

This commit is contained in:
ErickSkrauch
2019-02-26 02:26:02 +03:00
parent ea4ebd19ef
commit b20825a051
67 changed files with 250 additions and 252 deletions

View File

@@ -18,7 +18,7 @@ class PrimaryKeyValueBehavior extends Behavior {
*/
public $value;
public function events() {
public function events(): array {
return [
ActiveRecord::EVENT_BEFORE_INSERT => 'setPrimaryKeyValue',
];
@@ -32,7 +32,7 @@ class PrimaryKeyValueBehavior extends Behavior {
return true;
}
public function refreshPrimaryKeyValue() {
public function refreshPrimaryKeyValue(): void {
do {
$key = $this->generateValue();
} while ($this->isValueExists($key));
@@ -45,15 +45,18 @@ class PrimaryKeyValueBehavior extends Behavior {
}
protected function isValueExists(string $key): bool {
return $this->owner->find()->andWhere([$this->getPrimaryKeyName() => $key])->exists();
$owner = $this->owner;
return $owner::find()->andWhere([$this->getPrimaryKeyName() => $key])->exists();
}
protected function getPrimaryKeyName(): string {
$owner = $this->owner;
$primaryKeys = $owner->primaryKey();
$primaryKeys = $owner::primaryKey();
if (!isset($primaryKeys[0])) {
throw new InvalidConfigException('"' . get_class($owner) . '" must have a primary key.');
} elseif (count($primaryKeys) > 1) {
}
if (count($primaryKeys) > 1) {
throw new InvalidConfigException('Current behavior don\'t support models with more then one primary key.');
}