diff --git a/src/Controls/AjaxUploadInput.php b/src/Controls/AjaxUploadInput.php
index f3ceccf..b333f8b 100644
--- a/src/Controls/AjaxUploadInput.php
+++ b/src/Controls/AjaxUploadInput.php
@@ -36,7 +36,7 @@ class AjaxUploadInput extends BaseControl
public function __construct($label = null, bool $multiple = false, array $settings = null)
{
parent::__construct($label);
- $this->control->multiple = (bool)$multiple;
+ $this->control->multiple = $multiple;
$this->control->type = 'text';
$this->settings = (array)$settings;
@@ -187,7 +187,7 @@ public function getHtmlName(): string
*
* @return $this
*/
- public function setUrl($url): static {
+ public function setUrl($url) {
$this->url = $url;
return $this;
diff --git a/src/Controls/AutoCompleteInput.php b/src/Controls/AutoCompleteInput.php
index 71761ed..014be64 100644
--- a/src/Controls/AutoCompleteInput.php
+++ b/src/Controls/AutoCompleteInput.php
@@ -12,7 +12,7 @@ class AutoCompleteInput extends TextInput {
private array $settings = [];
- public string|array $source = '';
+ public $source = '';
/**
* @param null $label
@@ -54,7 +54,7 @@ public function getControl(): Html {
/**
* 设置输入提示源
*/
- public function setSource( $source ): static {
+ public function setSource( $source ) {
$this->source = $source;
return $this;
diff --git a/src/Controls/CaptchaInput.php b/src/Controls/CaptchaInput.php
index b667efa..b3dfc14 100644
--- a/src/Controls/CaptchaInput.php
+++ b/src/Controls/CaptchaInput.php
@@ -70,7 +70,7 @@ public function getControl(): Html {
*
* @return $this
*/
- public function setUrl( $url ): static {
+ public function setUrl( $url ) {
$this->url = $url;
return $this;
diff --git a/src/Controls/CheckboxTreeInput.php b/src/Controls/CheckboxTreeInput.php
index 653c59e..287064e 100644
--- a/src/Controls/CheckboxTreeInput.php
+++ b/src/Controls/CheckboxTreeInput.php
@@ -3,7 +3,9 @@
namespace Wenprise\Forms\Controls;
use Nette\Forms\Controls\MultiChoiceControl;
+use Nette\InvalidArgumentException;
use Nette\Utils\Html;
+use Nette\Utils\Strings;
/**
* 克隆输入
@@ -46,16 +48,16 @@ private function recursiveRender($list): Html {
return $html;
}
- public function setValue($values): CheckboxTreeInput|static {
+ public function setValue($values) {
if (is_scalar($values) || $values === null) {
$values = (array)$values;
} elseif ( ! is_array($values)) {
- throw new \Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name));
+ throw new InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name));
}
$flip = [];
foreach ($values as $value) {
if ( ! is_scalar($value) && ! method_exists($value, '__toString')) {
- throw new \Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name));
+ throw new InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name));
}
$flip[ (string)$value ] = true;
}
@@ -67,16 +69,16 @@ public function setValue($values): CheckboxTreeInput|static {
$nestedKeys[] = $key;
});
if ($diff = array_diff($values, $nestedKeys)) {
- $range = \Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) { return var_export($s, true); }, $nestedKeys)), 70, '...');
+ $range = Strings::truncate(implode(', ', array_map(function ($s) { return var_export($s, true); }, $nestedKeys)), 70, '...');
$vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'";
- throw new \Nette\InvalidArgumentException("Value$vals are out of allowed range [$range] in field '{$this->name}'.");
+ throw new InvalidArgumentException("Value$vals are out of allowed range [$range] in field '$this->name'.");
}
$this->value = $values;
return $this;
}
- public function getLabel($caption = null): Html|string|null {
+ public function getLabel($caption = null) {
return parent::getLabel($caption)->for(null);
}
diff --git a/src/Controls/CsrfInput.php b/src/Controls/CsrfInput.php
index c078c36..96f07e9 100644
--- a/src/Controls/CsrfInput.php
+++ b/src/Controls/CsrfInput.php
@@ -14,7 +14,7 @@ class CsrfInput extends HiddenField
/**
- * @param string|object
+ * @param string|object $errorMessage
*/
public function __construct($errorMessage)
{
diff --git a/src/Controls/GroupInput.php b/src/Controls/GroupInput.php
index d558d5d..5184d60 100644
--- a/src/Controls/GroupInput.php
+++ b/src/Controls/GroupInput.php
@@ -13,12 +13,12 @@ class GroupInput extends TextInput {
/**
* @var string|null
*/
- public string|null $prefix;
+ public $prefix;
/**
* @var string|null
*/
- public string|null $suffix;
+ public $suffix;
/**
@@ -46,7 +46,7 @@ public function __construct( $label = null, $maxLength = null, string $prefix =
*
* @return $this
*/
- public function setPrefix( string $prefix ): static {
+ public function setPrefix( string $prefix ) {
$this->prefix = $prefix;
return $this;
@@ -60,7 +60,7 @@ public function setPrefix( string $prefix ): static {
*
* @return $this
*/
- public function setSuffix( string $suffix ): static {
+ public function setSuffix( string $suffix ) {
$this->suffix = $suffix;
return $this;
diff --git a/src/Controls/HtmlContent.php b/src/Controls/HtmlContent.php
index 77ae33c..c034df2 100644
--- a/src/Controls/HtmlContent.php
+++ b/src/Controls/HtmlContent.php
@@ -36,7 +36,7 @@ public function getLabel( $caption = null ): void {
*
* @return string
*/
- public function getControl(object|string $caption = null ): string {
+ public function getControl( $caption = null ): string {
$this->setOption( 'rendered', true );
return $this->getCaption();
diff --git a/src/Controls/InquiryInput.php b/src/Controls/InquiryInput.php
index edc0541..dbba66a 100644
--- a/src/Controls/InquiryInput.php
+++ b/src/Controls/InquiryInput.php
@@ -140,7 +140,7 @@ public function getControl(): string
@@ -151,7 +151,7 @@ public function getControl(): string
@@ -192,7 +192,7 @@ public function getControl(): string
@@ -207,7 +207,7 @@ public function getControl(): string
diff --git a/src/Controls/SmsInput.php b/src/Controls/SmsInput.php
index 94895c0..e4c7740 100644
--- a/src/Controls/SmsInput.php
+++ b/src/Controls/SmsInput.php
@@ -79,7 +79,7 @@ public function getControl(): Html
*
* @return $this
*/
- public function setUrl($url): static
+ public function setUrl($url)
{
$this->url = $url;
diff --git a/src/Controls/WpUploaderInput.php b/src/Controls/WpUploaderInput.php
index eb41862..ef3a915 100644
--- a/src/Controls/WpUploaderInput.php
+++ b/src/Controls/WpUploaderInput.php
@@ -27,12 +27,12 @@ class WpUploaderInput extends BaseControl {
/**
* @param null $label
- * @param bool
- * @param array|null $settings Chosen 设置
+ * @param bool $multiple
+ * @param array|null $settings Chosen 设置
*/
- public function __construct( $label = null, $multiple = false, array $settings = null ) {
+ public function __construct($label = null, bool $multiple = false, array $settings = null ) {
parent::__construct( $label );
- $this->control->multiple = (bool) $multiple;
+ $this->control->multiple = $multiple;
$this->control->type = 'text';
$this->settings = (array) $settings;
diff --git a/src/Form.php b/src/Form.php
index c983e7e..c112b33 100644
--- a/src/Form.php
+++ b/src/Form.php
@@ -10,7 +10,7 @@
class Form extends \Nette\Forms\Form implements HtmlStringable
{
- public IDatastore|null $datastore = null;
+ public $datastore = null;
/**
* @param \Wenprise\Forms\Datastores\IDatastore $datastore
diff --git a/src/Helpers.php b/src/Helpers.php
index 71f298d..3759762 100755
--- a/src/Helpers.php
+++ b/src/Helpers.php
@@ -2,6 +2,8 @@
namespace Wenprise\Forms;
+use Closure;
+
class Helpers
{
@@ -12,7 +14,7 @@ class Helpers
*
* @return false|string
*/
- public static function get_grandparent_class($object): bool|string
+ public static function get_grandparent_class($object)
{
if (is_object($object)) {
$object = get_class($object);
@@ -29,9 +31,9 @@ public static function get_grandparent_class($object): bool|string
*
* @return mixed
*/
- public static function value(mixed $value): mixed
+ public static function value($value)
{
- return $value instanceof \Closure ? $value() : $value;
+ return $value instanceof Closure ? $value() : $value;
}
@@ -44,7 +46,7 @@ public static function value(mixed $value): mixed
*
* @return mixed
*/
- public static function data_get(array $array, string $key, mixed $default = null): mixed
+ public static function data_get(array $array, string $key, $default = null)
{
if (isset($array[ $key ])) {
@@ -71,7 +73,7 @@ public static function data_get(array $array, string $key, mixed $default = null
*
* @return mixed|null
*/
- public static function http_get($key = null, $default = null): mixed
+ public static function input_get($key = null, $default = null)
{
return static::data_get($_REQUEST, $key, $default);
}
@@ -116,7 +118,7 @@ public static function dir_to_url($directory): string
*
* @return mixed
*/
- public static function get_manifest(): mixed
+ public static function get_manifest()
{
static $manifest;
static $manifest_path;
diff --git a/src/Init.php b/src/Init.php
index 0c39c6e..65e674f 100755
--- a/src/Init.php
+++ b/src/Init.php
@@ -105,7 +105,7 @@ function register_assets(): void
*
* @return void
*/
- #[NoReturn] function save_form_data(): void
+ function save_form_data(): void
{
$data = $_POST;
diff --git a/src/Renders/AdminFormRender.php b/src/Renders/AdminFormRender.php
index fbd07ba..f534fbc 100644
--- a/src/Renders/AdminFormRender.php
+++ b/src/Renders/AdminFormRender.php
@@ -11,7 +11,7 @@ class AdminFormRender extends BaseFormRender
{
use Nette\SmartObject;
- var mixed $type = 'post_meta';
+ var $type = 'post_meta';
public function __construct($type = 'post_meta')
{
diff --git a/src/Renders/BaseFormRender.php b/src/Renders/BaseFormRender.php
index 3266c21..4bf2f43 100644
--- a/src/Renders/BaseFormRender.php
+++ b/src/Renders/BaseFormRender.php
@@ -3,6 +3,7 @@
namespace Wenprise\Forms\Renders;
use Nette;
+use Nette\InvalidArgumentException;
use Nette\Utils\Html;
use Nette\HtmlStringable;
@@ -43,14 +44,14 @@ public function __construct($type = 'horizontal')
/**
* 渲染控件组,主要添加 Html render
*
- * @param Nette\Forms\Container|Nette\Forms\ControlGroup
+ * @param Nette\Forms\Container|Nette\Forms\ControlGroup $parent
*
* @return string
*/
public function renderControls($parent): string
{
if ( ! ($parent instanceof Nette\Forms\Container || $parent instanceof Nette\Forms\ControlGroup)) {
- throw new \Nette\InvalidArgumentException('Argument must be Nette\Forms\Container or Nette\Forms\ControlGroup instance.');
+ throw new InvalidArgumentException('Argument must be Nette\Forms\Container or Nette\Forms\ControlGroup instance.');
}
$container = $this->getWrapper('controls container');
@@ -89,7 +90,7 @@ public function renderControls($parent): string
/**
* 在一行中渲染多个控件,主要添加 wrapper class
*
- * @param Nette\Forms\IControl[]
+ * @param Nette\Forms\IControl[] $controls
*
* @return string
*/
@@ -98,7 +99,7 @@ public function renderPairMulti(array $controls): string
$s = [];
foreach ($controls as $control) {
if ( ! $control instanceof Nette\Forms\Control) {
- throw new Nette\InvalidArgumentException('Argument must be array of Nette\Forms\IControl instances.');
+ throw new InvalidArgumentException('Argument must be array of Nette\Forms\IControl instances.');
}
$description = $control->getOption('description');
@@ -161,7 +162,7 @@ public function renderPairMulti(array $controls): string
*
* @return \Nette\Utils\Html|string
*/
- public function renderControlGroup($control): Html|string
+ public function renderControlGroup($control)
{
$html = '';
diff --git a/src/Renders/FormRender.php b/src/Renders/FormRender.php
index c02167e..5434111 100644
--- a/src/Renders/FormRender.php
+++ b/src/Renders/FormRender.php
@@ -115,7 +115,7 @@ class FormRender extends Nette\Forms\Rendering\DefaultFormRenderer
/**
* 渲染控件组
*
- * @param Nette\Forms\Container|Nette\Forms\ControlGroup
+ * @param Nette\Forms\Container|Nette\Forms\ControlGroup $parent
*
* @return string
*/
@@ -206,7 +206,7 @@ public function renderPair(Nette\Forms\Control $control): string
}
// 中间
- $group->addHtml($this->renderControl($control->setAttribute('class', 'rs-form-control'))
+ $group->addHtml($this->renderControl($control->setHtmlAttribute('class', 'rs-form-control'))
->getChildren()[ 0 ]);
// 后缀
@@ -245,7 +245,7 @@ public function renderPair(Nette\Forms\Control $control): string
/**
* 在一行中渲染多个控件
*
- * @param Nette\Forms\IControl[]
+ * @param Nette\Forms\IControl[] $controls
*
* @return string
*/
@@ -253,7 +253,7 @@ public function renderPairMulti(array $controls): string
{
$s = [];
foreach ($controls as $control) {
- if ( ! $control instanceof Nette\Forms\IControl) {
+ if ( ! $control instanceof Nette\Forms\Control) {
throw new Nette\InvalidArgumentException('Argument must be array of Nette\Forms\IControl instances.');
}
|