diff --git a/wire/.editorconfig b/wire/.editorconfig index 6b46728e..51743efe 100644 --- a/wire/.editorconfig +++ b/wire/.editorconfig @@ -18,11 +18,11 @@ insert_final_newline = true [*.js] indent_style = tab -trim_trailing_whitespace = true +trim_trailing_whitespace = false insert_final_newline = true [*.{css,less,scss}] indent_style = tab -trim_trailing_whitespace = true +trim_trailing_whitespace = false insert_final_newline = true diff --git a/wire/core/Inputfield.php b/wire/core/Inputfield.php index ac7d31f7..db7c48e3 100644 --- a/wire/core/Inputfield.php +++ b/wire/core/Inputfield.php @@ -368,7 +368,7 @@ abstract class Inputfield extends WireData implements Module { protected $defaultID = ''; /** - * Whether or not this Inputfield is editable + * Whether this Inputfield is editable * * When false, its processInput method won't be called by InputfieldWrapper's processInput * @@ -415,6 +415,8 @@ abstract class Inputfield extends WireData implements Module { $value = $this instanceof InputfieldHasArrayValue ? array() : null; $this->setAttribute('value', $value); + + parent::__construct(); } /** @@ -496,7 +498,7 @@ abstract class Inputfield extends WireData implements Module { * * - This can also be accessed directly, i.e. `$value = $inputfield->property;`. * - * - For getting attribute values, this will work but it is preferable to use the `Inputfield::attr()` method. + * - For getting attribute values, this will work, but it is preferable to use the `Inputfield::attr()` method. * * - For getting non-attribute values that have potential name conflicts with attributes (or just as a * reliable alternative), use the `Inputfield::getSetting()` method instead, which excludes the possibility @@ -675,7 +677,7 @@ abstract class Inputfield extends WireData implements Module { /** * Set an attribute * - * - For most public API use, you might consider using the the shorter `Inputfield::attr()` method instead. + * - For most public API use, you might consider using the shorter `Inputfield::attr()` method instead. * * - When setting the `class` attribute it is preferable to use the `Inputfield::addClass()` method. * @@ -1464,16 +1466,16 @@ abstract class Inputfield extends WireData implements Module { public function ___getConfigInputfields() { $conditionsText = $this->_('Conditions are expressed with a "field=value" selector containing fields and values to match. Multiple conditions should be separated by a comma.'); - $conditionsNote = $this->_('Read more about [how to use this](http://processwire.com/api/selectors/inputfield-dependencies/).'); + $conditionsNote = $this->_('Read more about [how to use this](https://processwire.com/api/selectors/inputfield-dependencies/).'); - /** @var InputfieldWrapper $fields */ + /** @var InputfieldWrapper $inputfields */ $inputfields = $this->wire(new InputfieldWrapper()); $fieldset = $inputfields->InputfieldFieldset; $fieldset->label = $this->_('Visibility'); $fieldset->attr('name', 'visibility'); $fieldset->icon = 'eye'; - + $field = $inputfields->InputfieldSelect; $field->attr('name', 'collapsed'); $field->label = $this->_('Presentation'); @@ -1657,6 +1659,7 @@ abstract class Inputfield extends WireData implements Module { $inputfields = $this->getConfigInputfields(); if(!$inputfields || !count($inputfields)) return $data; foreach($inputfields->getAll() as $inputfield) { + /** @var Inputfield $inputfield */ $value = $inputfield->isEmpty() ? '' : $inputfield->value; if(is_object($value)) $value = (string) $value; $data[$inputfield->name] = $value; @@ -1703,7 +1706,7 @@ abstract class Inputfield extends WireData implements Module { * * @param string $text Text of error message * @param int $flags Optional flags - * @return mixed + * @return $this * */ public function error($text, $flags = 0) { @@ -1876,7 +1879,7 @@ abstract class Inputfield extends WireData implements Module { * */ public function editable($setEditable = null) { - if(!is_null($setEditable)) $this->editable = $setEditable ? true : false; + if(!is_null($setEditable)) $this->editable = (bool) $setEditable; return $this->editable; } diff --git a/wire/modules/Fieldtype/FieldtypeComments/CommentArray.php b/wire/modules/Fieldtype/FieldtypeComments/CommentArray.php index 0667b464..baf98f29 100644 --- a/wire/modules/Fieldtype/FieldtypeComments/CommentArray.php +++ b/wire/modules/Fieldtype/FieldtypeComments/CommentArray.php @@ -25,7 +25,7 @@ class CommentArray extends PaginatedArray implements WirePaginatable { /** * Field object associated with this CommentArray * - * @var Field|null + * @var Field|CommentField|null * */ protected $field = null; @@ -240,7 +240,6 @@ class CommentArray extends PaginatedArray implements WirePaginatable { public function isIdentical(WireArray $items, $strict = true) { $isIdentical = parent::isIdentical($items, $strict); if($isIdentical && $strict && $items instanceof CommentArray) { - /** @var CommentArray $items */ if(((string) $this->getPage()) != ((string) $items->getPage())) return false; if(((string) $this->getField()) != ((string) $items->getField())) return false; } @@ -333,6 +332,7 @@ class CommentArray extends PaginatedArray implements WirePaginatable { $commentID = $comment instanceof Comment ? $comment->id : (int) $comment; $has = false; foreach($this as $item) { + /** @var Comment $item */ if($item->id !== $commentID) continue; $has = true; break; diff --git a/wire/modules/Fieldtype/FieldtypeComments/CommentField.php b/wire/modules/Fieldtype/FieldtypeComments/CommentField.php index 0a589128..681f03da 100644 --- a/wire/modules/Fieldtype/FieldtypeComments/CommentField.php +++ b/wire/modules/Fieldtype/FieldtypeComments/CommentField.php @@ -146,7 +146,7 @@ class CommentField extends Field { * @param Page $page * @param Comment $comment * @param array $properties Associative array of properties to update - * @return mixed + * @return bool * */ public function updateComment(Page $page, Comment $comment, array $properties) { @@ -311,4 +311,4 @@ class CommentField extends Field { public function getFieldtype() { return parent::getFieldtype(); } -} \ No newline at end of file +} diff --git a/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module b/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module index 38f55223..fde8c1a2 100644 --- a/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module +++ b/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module @@ -160,14 +160,13 @@ class FieldtypeComments extends FieldtypeMulti { $editable = $page->editable(); if(!is_array($value)) $value = array($value); - foreach($value as $sort => $item) { + foreach($value as $item) { if(!is_array($item)) continue; // don't load non-approved comments if the user can't edit them if(!$editable && $item['status'] < Comment::statusApproved) continue; - /** @var Comment $comment */ $comment = $this->makeComment($page, $field, $item); $commentArray->add($comment); $comment->setIsLoaded(true); @@ -184,7 +183,7 @@ class FieldtypeComments extends FieldtypeMulti { * * @param Page $page * @param Field $field - * @param string|int|array|object $value + * @param string|int|array|object|CommentArray $value * @return array * */ @@ -192,11 +191,13 @@ class FieldtypeComments extends FieldtypeMulti { $sleepValue = array(); if(!$value instanceof CommentArray) return $sleepValue; + $schemaVersion = $field->get('schemaVersion'); - $sanitizer = $this->wire('sanitizer'); /** @var Sanitizer $sanitizer */ - $maxIdxLen = $this->wire('database')->getMaxIndexLength(); + $sanitizer = $this->wire()->sanitizer; + $maxIdxLen = $this->wire()->database->getMaxIndexLength(); foreach($value as $comment) { + /** @var Comment $comment */ if($comment->id) { $this->checkExistingComment($page, $field, $comment); @@ -626,6 +627,7 @@ class FieldtypeComments extends FieldtypeMulti { $itemsRemoved = $allItems->getItemsRemoved(); if(count($itemsRemoved)) { foreach($itemsRemoved as $item) { + /** @var Comment $item */ if(!$item->id) continue; $this->deleteComment($page, $field, $item, 'deleted from savePageField()'); } @@ -634,6 +636,7 @@ class FieldtypeComments extends FieldtypeMulti { $maxSort = 0; $items = $allItems->makeNew(); foreach($allItems as $item) { + /** @var Comment $item */ if($item->isChanged() || !$item->id) $items->add($item); if($item->sort > $maxSort) $maxSort = $item->sort; } @@ -645,7 +648,7 @@ class FieldtypeComments extends FieldtypeMulti { $keys = is_array($value) ? array_keys($value) : array('data'); // cycle through the values, executing an update query for each - foreach($values as $commentKey => $value) { + foreach($values as $value) { $binds = array(); $sql = $value['id'] ? "UPDATE " : "INSERT INTO "; @@ -688,6 +691,7 @@ class FieldtypeComments extends FieldtypeMulti { // populate newly added comment ID to Comment object $value['id'] = $database->lastInsertId(); foreach($allItems as $item) { + /** @var Comment $item */ if(!$item->id && $item->code === $value['code']) { $item->id = $value['id']; $this->commentAdded($page, $field, $item); @@ -1569,7 +1573,7 @@ class FieldtypeComments extends FieldtypeMulti { * @param Field $field * @param Comment $comment * @param array $properties Associative array of properties to update - * @return mixed + * @return bool * @throws WireException * */ @@ -1734,7 +1738,7 @@ class FieldtypeComments extends FieldtypeMulti { // the $page->data() call used so load not triggered, only returns comments if already loaded $comments = $page->data($field->name); // add to loaded CommentArray for page, but only if it is already loaded in memory - if($comments && $comments instanceof CommentArray) $comments->add($comment); + if($comments instanceof CommentArray) $comments->add($comment); $this->commentAdded($page, $field, $comment); if($approved) $this->triggerPageFieldSaved($page, $field); } else { diff --git a/wire/modules/Fieldtype/FieldtypeOptions/SelectableOption.php b/wire/modules/Fieldtype/FieldtypeOptions/SelectableOption.php index f6fabebe..96b1e26e 100644 --- a/wire/modules/Fieldtype/FieldtypeOptions/SelectableOption.php +++ b/wire/modules/Fieldtype/FieldtypeOptions/SelectableOption.php @@ -105,7 +105,7 @@ class SelectableOption extends WireData { // implements LanguagesValueInterface */ public function getProperty($property) { if($this->wire('languages')) { - $language = $this->wire('user')->language; + $language = $this->wire()->user->language; if($language->isDefault()) { $value = parent::get($property); } else {