diff --git a/Swat/SwatActionItem.php b/Swat/SwatActionItem.php
index 536279ec..e2346a7f 100644
--- a/Swat/SwatActionItem.php
+++ b/Swat/SwatActionItem.php
@@ -143,7 +143,7 @@ public function getHtmlHeadEntrySet()
*/
public function getAvailableHtmlHeadEntrySet()
{
- $set = parent::geAvailabletHtmlHeadEntrySet();
+ $set = parent::getAvailableHtmlHeadEntrySet();
if ($this->widget !== null) {
$set->addEntrySet($this->widget->getAvailableHtmlHeadEntrySet());
diff --git a/Swat/SwatButton.php b/Swat/SwatButton.php
index 398d5e97..be29848a 100644
--- a/Swat/SwatButton.php
+++ b/Swat/SwatButton.php
@@ -324,7 +324,7 @@ protected function getJavaScriptClass()
/**
* Gets the inline JavaScript required for this control.
*
- * @return stirng the inline JavaScript required for this control
+ * @return string the inline JavaScript required for this control
*/
protected function getInlineJavaScript()
{
diff --git a/Swat/SwatChangeOrder.php b/Swat/SwatChangeOrder.php
index 2cf9b4f2..eb513412 100644
--- a/Swat/SwatChangeOrder.php
+++ b/Swat/SwatChangeOrder.php
@@ -84,7 +84,7 @@ public function display()
$list_div->class = 'swat-change-order-list';
$list_div->open();
- $option_div = new SwatHtmltag('div');
+ $option_div = new SwatHtmlTag('div');
$option_div->class = 'swat-change-order-item';
foreach ($ordered_options as $option) {
diff --git a/Swat/SwatFieldset.php b/Swat/SwatFieldset.php
index 3f13a422..d095b463 100644
--- a/Swat/SwatFieldset.php
+++ b/Swat/SwatFieldset.php
@@ -61,7 +61,7 @@ public function __construct($id = null)
*
* Implements the {SwatTitleable::getTitle()} interface.
*
- * @return the title of this fieldset
+ * @return string the title of this fieldset
*/
public function getTitle()
{
diff --git a/Swat/SwatForm.php b/Swat/SwatForm.php
index 7b94940a..8b866601 100644
--- a/Swat/SwatForm.php
+++ b/Swat/SwatForm.php
@@ -319,8 +319,6 @@ public function display()
*
* This form is only marked as processed if it was submitted by the user.
*
- * @return true if this form was actually submitted, false otherwise
- *
* @see SwatContainer::process()
*/
public function process()
diff --git a/Swat/SwatHtmlHeadEntry.php b/Swat/SwatHtmlHeadEntry.php
index 419dea32..77b0594c 100644
--- a/Swat/SwatHtmlHeadEntry.php
+++ b/Swat/SwatHtmlHeadEntry.php
@@ -103,7 +103,7 @@ public function getType()
*/
public function getIECondition()
{
- return $this->ie_conditional;
+ return $this->ie_condition;
}
/**
diff --git a/Swat/SwatInputCell.php b/Swat/SwatInputCell.php
index 5cf3e597..7d3a429f 100644
--- a/Swat/SwatInputCell.php
+++ b/Swat/SwatInputCell.php
@@ -428,8 +428,8 @@ public function copy($id_suffix = '')
$copy_clone = $clone->copy($id_suffix);
$copy_clone->parent = $copy;
$copy->clones[$replicator_id] = $copy_clone;
- if ($copy_child->id !== null) {
- $copy->children_by_id[$copy_child->id] = $copy_child;
+ if ($copy_clone->id !== null) {
+ $copy->children_by_id[$copy_clone->id] = $copy_clone;
}
$clone->widgets[$replicator_id] = [];
diff --git a/Swat/SwatListEntry.php b/Swat/SwatListEntry.php
index e1e53e53..a13dbd90 100644
--- a/Swat/SwatListEntry.php
+++ b/Swat/SwatListEntry.php
@@ -256,7 +256,7 @@ public function setState($values)
* For list entry, this is a delimiter separated string containing the
* elements of {@link SwatListEntry::$values}.
*
- * @param array $value the value to format for display
+ * @param string $value the value to format for display
*
* @return string the values displayed in the XHTML input
*/
diff --git a/Swat/SwatRadioNoteBook.php b/Swat/SwatRadioNoteBook.php
index bc2deb53..d7804ac5 100644
--- a/Swat/SwatRadioNoteBook.php
+++ b/Swat/SwatRadioNoteBook.php
@@ -219,10 +219,9 @@ public function printWidgetTree()
{
echo get_class($this), ' ', $this->id;
- $children = $this->getChildren();
- if (count($children) > 0) {
+ if (count($this->children) > 0) {
echo '
';
- foreach ($children as $child) {
+ foreach ($this->children as $child) {
echo '- ';
$child->printWidgetTree();
echo '
';
diff --git a/Swat/SwatTableView.php b/Swat/SwatTableView.php
index 60935135..ca6ad208 100644
--- a/Swat/SwatTableView.php
+++ b/Swat/SwatTableView.php
@@ -10,7 +10,7 @@
* @copyright 2004-2016 silverorange
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
*/
-class SwatTableView extends SwatView implements SwatUIParent
+class SwatTableView extends SwatView
{
/**
* The column of this table-view that data in the model is currently being
diff --git a/Swat/SwatTileView.php b/Swat/SwatTileView.php
index 7622f4cb..20722ba8 100644
--- a/Swat/SwatTileView.php
+++ b/Swat/SwatTileView.php
@@ -13,7 +13,7 @@
*
* @see SwatTile
*/
-class SwatTileView extends SwatView implements SwatUIParent
+class SwatTileView extends SwatView
{
/**
* Whether to show a "check all" widget.
diff --git a/Swat/SwatTreeNode.php b/Swat/SwatTreeNode.php
index 197e96c7..1f374ea6 100644
--- a/Swat/SwatTreeNode.php
+++ b/Swat/SwatTreeNode.php
@@ -111,7 +111,7 @@ public function getParent()
*/
public function getChildren(): ?RecursiveIterator
{
- return $this->children;
+ return new RecursiveArrayIterator($this->children);
}
/**
diff --git a/Swat/SwatUIObject.php b/Swat/SwatUIObject.php
index 81019f63..fcf65954 100644
--- a/Swat/SwatUIObject.php
+++ b/Swat/SwatUIObject.php
@@ -157,11 +157,6 @@ public function addComment($comment)
);
}
- public function addInlineScript($script)
- {
- $this->inline_scripts->add($script);
- }
-
/**
* Gets the first ancestor object of a specific class.
*
diff --git a/Swat/SwatUIParent.php b/Swat/SwatUIParent.php
index 64fd18fd..e02cd3a8 100644
--- a/Swat/SwatUIParent.php
+++ b/Swat/SwatUIParent.php
@@ -26,9 +26,9 @@ public function addChild(SwatObject $child);
* this object. Widgets are ordered in the array as they are found in
* a breadth-first traversal of the subtree.
*
- * @param string $class_name optional class name. If set, only UI-objects
- * that are instances of $class_name are
- * returned.
+ * @param ?class-string $class_name optional class name. If set, only UI-objects
+ * that are instances of $class_name are
+ * returned.
*
* @return array the descendant UI-objects of this object. If descendant
* objects have identifiers, the identifier is used as the
diff --git a/Swat/SwatView.php b/Swat/SwatView.php
index 2d233f00..dfafb500 100644
--- a/Swat/SwatView.php
+++ b/Swat/SwatView.php
@@ -6,7 +6,7 @@
* @copyright 2004-2016 silverorange
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
*/
-abstract class SwatView extends SwatControl
+abstract class SwatView extends SwatControl implements SwatUIParent
{
/**
* A data structure that holds the data to display in this view.
diff --git a/Swat/SwatYUIComponent.php b/Swat/SwatYUIComponent.php
index fc1e6f33..657c08b6 100644
--- a/Swat/SwatYUIComponent.php
+++ b/Swat/SwatYUIComponent.php
@@ -15,7 +15,7 @@ class SwatYUIComponent extends SwatObject
{
private $id;
private $dependencies = [];
- private $html_head_entries = [];
+ private $html_head_entry_set = [];
private $beta = false;
/**
diff --git a/Swat/exceptions/SwatIntegerOverflowException.php b/Swat/exceptions/SwatIntegerOverflowException.php
index a50fbc48..d0f827f2 100644
--- a/Swat/exceptions/SwatIntegerOverflowException.php
+++ b/Swat/exceptions/SwatIntegerOverflowException.php
@@ -12,10 +12,8 @@ class SwatIntegerOverflowException extends OverflowException
* Sign.
*
* The sign of the integer, either positive or negative
- *
- * @var int
*/
- protected $sign;
+ protected int $sign;
/**
* Creates a new invalid type exception.
@@ -25,7 +23,7 @@ class SwatIntegerOverflowException extends OverflowException
* @param int $sign the sign of the integer, either positive or
* negative
*/
- public function __construct($message = null, $code = 0, $sign = 1)
+ public function __construct(string $message = '', int $code = 0, int $sign = 1)
{
parent::__construct($message, $code);
@@ -37,7 +35,7 @@ public function __construct($message = null, $code = 0, $sign = 1)
*
* @return int the sign of the integer, either positive or negative
*/
- public function getSign()
+ public function getSign(): int
{
return $this->sign;
}
diff --git a/SwatI18N/SwatI18NLocale.php b/SwatI18N/SwatI18NLocale.php
index bf08f15f..a629134e 100644
--- a/SwatI18N/SwatI18NLocale.php
+++ b/SwatI18N/SwatI18NLocale.php
@@ -687,7 +687,7 @@ public function parseInteger($string)
if ($string > (float) PHP_INT_MAX) {
throw new SwatIntegerOverflowException(
'Floating point value is too big to be an integer',
- null,
+ 0,
1,
);
}
@@ -695,7 +695,7 @@ public function parseInteger($string)
if ($string < (float) (-PHP_INT_MAX - 1)) {
throw new SwatIntegerOverflowException(
'Floating point value is too small to be an integer',
- null,
+ 0,
-1,
);
}
@@ -1002,7 +1002,7 @@ protected function formatIntegerGroupings(
$grouping_total = floor($grouping_total / pow(10, $grouping));
if ($grouping_total > 0) {
$grouping_value = str_pad(
- $grouping_value,
+ (string) $grouping_value,
$grouping,
'0',
STR_PAD_LEFT,
@@ -1039,7 +1039,7 @@ protected function formatIntegerGroupings(
if ($grouping_total > 0) {
$grouping_value = str_pad(
- $grouping_value,
+ (string) $grouping_value,
$grouping,
'0',
STR_PAD_LEFT,
@@ -1086,7 +1086,7 @@ protected function formatFractionalPart(
$frac_part = abs(fmod($value, 1));
$frac_part = round($frac_part * pow(10, $fractional_digits));
$frac_part = str_pad(
- $frac_part,
+ (string) $frac_part,
$fractional_digits,
'0',
STR_PAD_LEFT,
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index d1848e61..364905f7 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -1,55 +1,2 @@
parameters:
ignoreErrors:
- -
- message: '#^Call to an undefined static method SwatControl\:\:geAvailabletHtmlHeadEntrySet\(\)\.$#'
- identifier: staticMethod.notFound
- count: 1
- path: Swat/SwatActionItem.php
-
- -
- message: '#^Class SwatHtmlTag referenced with incorrect case\: SwatHtmltag\.$#'
- identifier: class.nameCase
- count: 1
- path: Swat/SwatChangeOrder.php
-
- -
- message: '#^Method SwatForm\:\:process\(\) should return true but return statement is missing\.$#'
- identifier: return.missing
- count: 2
- path: Swat/SwatForm.php
-
- -
- message: '#^Access to an undefined property SwatHtmlHeadEntry\:\:\$ie_conditional\.$#'
- identifier: property.notFound
- count: 1
- path: Swat/SwatHtmlHeadEntry.php
-
- -
- message: '#^Undefined variable\: \$copy_child$#'
- identifier: variable.undefined
- count: 3
- path: Swat/SwatInputCell.php
-
- -
- message: '#^Call to an undefined method SwatRadioNoteBook\:\:getChildren\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: Swat/SwatRadioNoteBook.php
-
- -
- message: '#^Access to an undefined property SwatUIObject\:\:\$inline_scripts\.$#'
- identifier: property.notFound
- count: 1
- path: Swat/SwatUIObject.php
-
- -
- message: '#^Call to an undefined method SwatView\:\:getDescendants\(\)\.$#'
- identifier: method.notFound
- count: 1
- path: Swat/SwatView.php
-
- -
- message: '#^Access to an undefined property SwatYUIComponent\:\:\$html_head_entry_set\.$#'
- identifier: property.notFound
- count: 3
- path: Swat/SwatYUIComponent.php
diff --git a/phpstan.dist.neon b/phpstan.dist.neon
index 41524c6b..50993529 100644
--- a/phpstan.dist.neon
+++ b/phpstan.dist.neon
@@ -9,3 +9,12 @@ parameters:
- SwatI18N
editorUrl: '%%relFile%%:%%line%%'
editorUrlTitle: '%%relFile%%:%%line%%'
+# Checks from higher levels that we want to include here
+# Level 2
+ checkClassCaseSensitivity: true
+ checkPhpDocMissingReturn: true
+# checkThisOnly: false
+# Level 3
+ checkPhpDocMethodSignatures: true
+# Level 5
+# checkFunctionArgumentTypes: true