diff --git a/AbstractEmbeddedBehavior.php b/AbstractEmbeddedBehavior.php index ed9bcf0..b2aa730 100644 --- a/AbstractEmbeddedBehavior.php +++ b/AbstractEmbeddedBehavior.php @@ -91,9 +91,9 @@ public function __get($name) { if ($this->checkName($name)) { return $this->storage; - } else { - return parent::__get($name); } + + return parent::__get($name); } public function __set($name, $value) diff --git a/EmbeddedDocument.php b/EmbeddedDocument.php index 3895a47..203692c 100644 --- a/EmbeddedDocument.php +++ b/EmbeddedDocument.php @@ -33,6 +33,7 @@ class EmbeddedDocument extends Model /** * @inheritdoc */ + #[\ReturnTypeWillChange] public function formName() { if (!empty($this->_formName)) { @@ -45,6 +46,7 @@ public function formName() /** * @param $formName */ + #[\ReturnTypeWillChange] public function setFormName($formName) { if (!empty($formName)) { @@ -56,6 +58,7 @@ public function setFormName($formName) * set link to primary model * @param ActiveRecord $model */ + #[\ReturnTypeWillChange] public function setPrimaryModel(ActiveRecord $model) { $this->_primaryModel = $model; @@ -66,6 +69,7 @@ public function setPrimaryModel(ActiveRecord $model) * @return ActiveRecord * @throws UnknownPropertyException */ + #[\ReturnTypeWillChange] public function getPrimaryModel() { if (!isset($this->_primaryModel)) { @@ -79,6 +83,7 @@ public function getPrimaryModel() * set link to primary model attribute * @param $value */ + #[\ReturnTypeWillChange] public function setSource($value) { $this->_source = $value; @@ -88,6 +93,7 @@ public function setSource($value) * Save embedded model as attribute on primary model * @throws UnknownPropertyException */ + #[\ReturnTypeWillChange] public function save() { if (!isset($this->_source) || !$this->primaryModel->hasAttribute($this->_source)) { @@ -96,6 +102,7 @@ public function save() $this->primaryModel->save(false, [$this->_source]); } + #[\ReturnTypeWillChange] public function setScenario($scenario) { if (array_key_exists($scenario, $this->scenarios())) { @@ -111,6 +118,7 @@ public function setScenario($scenario) * Пустым считается объект все атрибуты которого пусты (empty($value)) или равны значениям по-умолчанию. Не учитывает параметры "when" и "isEmpty" валидаторов "по-умолчанию". * @return bool */ + #[\ReturnTypeWillChange] public function isEmpty() { $notEmptyAttributes = []; diff --git a/EmbedsManyBehavior.php b/EmbedsManyBehavior.php index d46f629..e596b70 100644 --- a/EmbedsManyBehavior.php +++ b/EmbedsManyBehavior.php @@ -15,18 +15,20 @@ class EmbedsManyBehavior extends AbstractEmbeddedBehavior { public $initEmptyScenarios = []; + #[\ReturnTypeWillChange] public function getFormName($index) { if ($this->setFormName) { return Html::getInputName($this->owner, $this->fakeAttribute."[{$index}]"); - } else { - return null; } + + return null; } /** * @inheritdoc */ + #[\ReturnTypeWillChange] protected function setAttributes($attributes, $safeOnly = true) { $this->storage->removeAll(); @@ -51,6 +53,7 @@ protected function setAttributes($attributes, $safeOnly = true) /** * @inheritdoc */ + #[\ReturnTypeWillChange] protected function getAttributes() { return $this->storage->attributes; @@ -59,6 +62,7 @@ protected function getAttributes() /** * @return Storage */ + #[\ReturnTypeWillChange] public function getStorage() { if (empty($this->_storage)) { diff --git a/EmbedsOneBehavior.php b/EmbedsOneBehavior.php index 9c33bbf..fde29e0 100644 --- a/EmbedsOneBehavior.php +++ b/EmbedsOneBehavior.php @@ -11,6 +11,7 @@ */ class EmbedsOneBehavior extends AbstractEmbeddedBehavior { + #[\ReturnTypeWillChange] protected function setAttributes($attributes, $safeOnly = true) { $this->storage->scenario = $this->owner->scenario; @@ -20,18 +21,20 @@ protected function setAttributes($attributes, $safeOnly = true) /** * @inheritdoc */ + #[\ReturnTypeWillChange] protected function getAttributes() { if ($this->saveEmpty || !$this->storage->isEmpty()) { return $this->storage->attributes; - } else { - return null; } + + return null; } /** * @return EmbeddedDocument */ + #[\ReturnTypeWillChange] public function getStorage() { if (empty($this->_storage)) { diff --git a/Storage.php b/Storage.php index 0293e0a..27954a9 100644 --- a/Storage.php +++ b/Storage.php @@ -17,6 +17,7 @@ class Storage extends Component implements StorageInterface, \Countable, \Iterat private $_cursor = 0; + #[\ReturnTypeWillChange] public function removeAll() { $this->_container = []; @@ -27,6 +28,7 @@ public function removeAll() * @param string $name * @param Event $event */ + #[\ReturnTypeWillChange] public function trigger($name, Event $event = null) { parent::trigger($name, $event); @@ -39,6 +41,7 @@ public function trigger($name, Event $event = null) /** * @inheritdoc */ + #[\ReturnTypeWillChange] public function validate() { $hasError = false; @@ -54,6 +57,7 @@ public function validate() /** * @inheritdoc */ + #[\ReturnTypeWillChange] public function getAttributes() { $attributes = []; @@ -69,6 +73,7 @@ public function getAttributes() * @param $condition * @return null| EmbeddedDocument */ + #[\ReturnTypeWillChange] public function get($condition) { list($attribute, $value) = $condition; @@ -87,6 +92,7 @@ public function get($condition) * @param $object * @return bool */ + #[\ReturnTypeWillChange] public function set($condition, $object) { list($attribute, $value) = $condition; @@ -100,6 +106,7 @@ public function set($condition, $object) return false; } + #[\ReturnTypeWillChange] public function sort($field) { $attributes = $this->attributes; @@ -111,6 +118,7 @@ public function sort($field) }); } + #[\ReturnTypeWillChange] public function offsetSet($offset, $model) { if (is_null($offset)) { @@ -120,6 +128,7 @@ public function offsetSet($offset, $model) $this->_container[$offset] = $model; } + #[\ReturnTypeWillChange] public function current() { if ($this->valid($this->_cursor)) { @@ -129,47 +138,56 @@ public function current() } } + #[\ReturnTypeWillChange] public function key() { return $this->_cursor; } + #[\ReturnTypeWillChange] public function next() { ++$this->_cursor; } + #[\ReturnTypeWillChange] public function rewind() { $this->_cursor = 0; } + #[\ReturnTypeWillChange] public function valid() { return $this->offsetExists($this->_cursor); } + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->_container[$offset]); } + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->_container[$offset]); $this->_container = array_values($this->_container); } + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->_container[$offset]) ? $this->_container[$offset] : null; } + #[\ReturnTypeWillChange] public function count() { return count($this->_container); } + #[\ReturnTypeWillChange] public function getNextIndex() { $count = count($this->_container); @@ -181,6 +199,7 @@ public function getNextIndex() * @param string $scenario * @return void */ + #[\ReturnTypeWillChange] public function setScenario($scenario) { foreach ($this->_container as $model) { @@ -189,6 +208,7 @@ public function setScenario($scenario) } } + #[\ReturnTypeWillChange] public function __toString() { return ''; diff --git a/StorageInterface.php b/StorageInterface.php index 36ed562..bdbc0e3 100644 --- a/StorageInterface.php +++ b/StorageInterface.php @@ -14,7 +14,7 @@ interface StorageInterface extends \ArrayAccess /** * Triggers an event * @param string $name the event name - * @param Event $event the event parameter. If not set, a default [[Event]] object will be created. + * @param Event|null $event the event parameter. If not set, a default [[Event]] object will be created. */ public function trigger($name, Event $event = null); diff --git a/composer.json b/composer.json index fcac85b..2a51017 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,15 @@ "yiisoft/yii2-codeception": "*", "codeception/codeception": "*" }, + "config": { + "allow-plugins": { + "yiisoft/yii2-composer" : true + }, + "process-timeout": 1800, + "fxp-asset": { + "enabled": false + } + }, "autoload": { "psr-4": { "consultnn\\embedded\\": "." @@ -30,5 +39,11 @@ "branch-alias": { "dev-master": "1.0.x-dev" } - } + }, + "repositories": [ + { + "type": "composer", + "url": "https://asset-packagist.org" + } + ] }