";
- if (!is_null($this->label)) {
+ if ($this->label !== null) {
$boolLength = (isset($this->validate['length'][0]) && $this->validate['length'][0] > 0);
$req = ($boolLength) ? "*" : "";
$out .= "
";
}
- if (!is_null($this->description)) {
+ if ($this->description !== null) {
$out .= "
";
}
$out .= $callback();
@@ -183,10 +183,10 @@ public function group()
$lastKey = $this->lastKey();
$out = "
attr}data-key=\"{$lastKey}\">";
- if (!is_null($this->label)) {
+ if ($this->label !== null) {
$out .= "
";
}
- if (!is_null($this->description)) {
+ if ($this->description !== null) {
$out .= "
{$this->description}
";
}
diff --git a/Arguments.php b/Arguments.php
index 68daa39..6699185 100755
--- a/Arguments.php
+++ b/Arguments.php
@@ -1,4 +1,5 @@
default = $default;
}
return $this;
@@ -149,7 +150,7 @@ public function name(string $name): self
$this->inst->setValidateData($this->identifier, [
"id" => ($this->rows['id'] ?? 0),
- "type" => (!is_null($this->fieldType) ? $this->fieldType : "text"),
+ "type" => ($this->fieldType !== null ? $this->fieldType : "text"),
"validate" => $this->validate,
"default" => $this->default,
"config" => $this->config
@@ -168,7 +169,7 @@ public function name(string $name): self
*/
public function value(?string $val = null): self
{
- if (!is_null($val)) {
+ if ($val !== null) {
$this->value = $val;
} elseif (is_array($this->nameExp) && count($this->nameExp) > 0) {
$this->valueShifting($this->nameExp, $val);
@@ -185,7 +186,7 @@ public function value(?string $val = null): self
protected function valueShifting(array $exp, ?string $fallback): void
{
$values = $this->inst->getValues();
- if (!is_null($values)) {
+ if ($values !== null) {
// Can convert obj to arr if needed
$values = (array)$values;
$first = array_shift($exp);
@@ -195,7 +196,7 @@ protected function valueShifting(array $exp, ?string $fallback): void
$this->value = $this->json($this->value);
foreach ($exp as $item) {
$item = htmlentities(trim($item));
- if (!is_null($this->value)) {
+ if ($this->value !== null) {
$this->value = (isset($this->value[$item]) && is_array($this->value[$item])) ? $this->value[$item] : $fallback;
}
}
diff --git a/Examples/TestFormFields.php b/Examples/TestFormFields.php
index 172ea02..88372f8 100755
--- a/Examples/TestFormFields.php
+++ b/Examples/TestFormFields.php
@@ -13,7 +13,6 @@
class TestFormFields extends AbstractFormFields
{
-
/**
* Input text (Take a look at AbstractFormFields)
* @return string
diff --git a/Fields.php b/Fields.php
index 0ced46b..16d8797 100755
--- a/Fields.php
+++ b/Fields.php
@@ -14,7 +14,7 @@
class Fields extends AbstractFields implements FieldInterface
{
private $buildArr;
- private $validateData = array();
+ private $validateData = [];
/**
* Get form name
@@ -41,7 +41,7 @@ public function getFormData(): array
*/
public function hasFormData(?string $name = null): bool
{
- if (is_null($name)) {
+ if ($name === null) {
$name = $this->name;
}
return (isset($this->inpArr[$name]));
@@ -81,7 +81,7 @@ public function getValues(): mixed
*/
public function add($fields, ?string $name = null): self
{
- if (is_null($name)) {
+ if ($name === null) {
$name = $this->name;
}
$this->inpArr[$name] = $fields;
@@ -171,7 +171,7 @@ public function getValidateDataRow(string $key): array
*/
public function build(): void
{
- $this->validateData = array();
+ $this->validateData = [];
foreach ($this->inpArr as $key => $array) {
$this->buildArr[$key] = $this->html($array);
}
@@ -195,7 +195,7 @@ public function withBuild(): static
*/
public function get(): string
{
- if (!is_null($this->type) && method_exists($this->fields, $this->type)) {
+ if ($this->type !== null && method_exists($this->fields, $this->type)) {
$get = call_user_func_array([$this->fields, $this->type], $this->args);
return $get;
}
@@ -209,7 +209,7 @@ public function get(): string
*/
public function hasForm(?string $name = null): bool
{
- if (is_null($name)) {
+ if ($name === null) {
$name = $this->name;
}
return (isset($this->buildArr[$name]));
@@ -222,7 +222,7 @@ public function hasForm(?string $name = null): bool
*/
public function getForm(?string $name = null): string
{
- if (is_null($name)) {
+ if ($name === null) {
$name = $this->name;
}
if (!$this->hasFormData($name)) {
diff --git a/Validate.php b/Validate.php
index 76e0fef..bbcf7f8 100755
--- a/Validate.php
+++ b/Validate.php
@@ -3,7 +3,7 @@
namespace MaplePHP\Form;
use MaplePHP\Form\Interfaces\FieldInterface;
-use MaplePHP\Validate\Inp;
+use MaplePHP\Validate\Validator;
use MaplePHP\DTO\Format\Local;
class Validate
@@ -14,8 +14,8 @@ class Validate
private $validArr;
private $fields;
private $post;
- private $request = array();
- private $files = array();
+ private $request = [];
+ private $files = [];
private $local;
private $value;
private $length = 0;
@@ -80,7 +80,7 @@ public function execute(): ?array
$this->fields->setValues($this->post);
$this->fields->build();
- $postArr = array();
+ $postArr = [];
$arr = $this->fields->getValidateData();
foreach ($arr as $name => $arr) {
$field = $this->fields->{$arr['type']}();
@@ -95,7 +95,7 @@ public function execute(): ?array
if (isset($arr['validate'])) {
$this->value = htmlspecialchars((string)$value);
$this->length = strlen($this->value);
- $this->validate = Inp::value($this->value);
+ $this->validate = Validator::value($this->value);
if ($error = $this->isInvalid($arr['validate'])) {
$this->validArr[$nameKey] = $error;
@@ -151,7 +151,7 @@ protected function isInvalid($arr): bool|array
private function validateWithMethod(string $method, ?array $args, bool $valFilledIn): bool
{
if (!is_array($args)) {
- $args = array();
+ $args = [];
}
$object = call_user_func_array([$this->validate, $method], $args);
return (($valFilledIn && $this->length > 0 && !$object) || (!$valFilledIn && !$object));
@@ -175,9 +175,9 @@ private function buildMessage(string $method, ?array $args, string $message): ar
* @param array $args sprint push possible values
* @return string
*/
- protected function message(string $key, array $args = array())
+ protected function message(string $key, array $args = [])
{
- if (!is_null($this->local)) {
+ if ($this->local !== null) {
return $this->local->get($key, $key, $args);
}
return $key;
diff --git a/composer.json b/composer.json
index d91976b..39fbc89 100755
--- a/composer.json
+++ b/composer.json
@@ -1,29 +1,34 @@
{
- "name": "maplephp/form",
- "type": "library",
- "description": "Develop advanced, consistent, and secure forms that are also very easy to validate.",
- "keywords": ["form builder", "form", "builder", "validate"],
- "homepage": "https://wazabii.se",
- "license": "Apache-2.0",
- "authors": [
- {
- "name": "Daniel Ronkainen",
- "email": "daniel.ronkainen@wazabii.se"
- },
- {
- "name": "MaplePHP",
- "homepage": "https://wazabii.se"
- }
- ],
- "require": {
- "php": ">=8.0",
- "maplephp/dto": "^1.0",
- "maplephp/validate": "^1.0"
+ "name": "maplephp/form",
+ "type": "library",
+ "description": "Develop advanced, consistent, and secure forms that are also very easy to validate.",
+ "keywords": [
+ "form builder",
+ "form",
+ "builder",
+ "validate"
+ ],
+ "homepage": "https://wazabii.se",
+ "license": "Apache-2.0",
+ "authors": [
+ {
+ "name": "Daniel Ronkainen",
+ "email": "daniel.ronkainen@wazabii.se"
},
- "autoload": {
- "psr-4": {
- "MaplePHP\\Form\\": ""
- }
- },
- "minimum-stability": "dev"
+ {
+ "name": "MaplePHP",
+ "homepage": "https://wazabii.se"
+ }
+ ],
+ "require": {
+ "php": ">=8.2",
+ "maplephp/dto": "^3.1",
+ "maplephp/validate": "^2.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "MaplePHP\\Form\\": ""
+ }
+ },
+ "minimum-stability": "dev"
}
\ No newline at end of file