Skip to content

Commit 74063ea

Browse files
committed
Add #[\ReturnTypeWillChange] for 8.1 depreciation warning
1 parent b61b0d2 commit 74063ea

File tree

1 file changed

+44
-31
lines changed

1 file changed

+44
-31
lines changed
Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,56 @@
11
<?php
22
namespace Ajax\semantic\components\validation;
3+
34
use Ajax\JsUtils;
45
use Ajax\service\JArray;
56

67
/**
8+
*
79
* @author jc
810
* @version 1.001
9-
* Generates a JSON field validator
11+
* Generates a JSON field validator
1012
*/
11-
class FieldValidation implements \JsonSerializable{
13+
class FieldValidation implements \JsonSerializable {
14+
1215
/**
16+
*
1317
* @var string
1418
*/
15-
protected $identifier;
19+
protected $identifier;
20+
1621
/**
22+
*
1723
* @var array array of Rules
1824
*/
1925
protected $rules;
26+
2027
/**
28+
*
2129
* @var array array of custom rules
2230
*/
2331
protected $customRules;
2432

25-
protected $hasCustomRules=false;
33+
protected $hasCustomRules = false;
2634

2735
/**
36+
*
2837
* @var string
2938
*/
3039
protected $depends;
3140

3241
protected $optional;
3342

34-
public function __construct($identifier){
35-
$this->identifier=$identifier;
36-
$this->rules=[];
43+
public function __construct($identifier) {
44+
$this->identifier = $identifier;
45+
$this->rules = [];
3746
}
3847

3948
public function getIdentifier() {
4049
return $this->identifier;
4150
}
4251

4352
public function setIdentifier($identifier) {
44-
$this->identifier=$identifier;
53+
$this->identifier = $identifier;
4554
return $this;
4655
}
4756

@@ -50,57 +59,61 @@ public function getRules() {
5059
}
5160

5261
/**
62+
*
5363
* @param string|Rule|array $type
5464
* @param string $prompt
5565
* @param string $value
5666
* @return Rule
5767
*/
58-
public function addRule($type,$prompt=NULL,$value=NULL){
59-
if($type instanceof Rule) {
68+
public function addRule($type, $prompt = NULL, $value = NULL) {
69+
if ($type instanceof Rule) {
6070
$rule = $type;
61-
if($type instanceof CustomRule){
62-
$this->customRules[]=$type;
63-
$this->hasCustomRules=true;
71+
if ($type instanceof CustomRule) {
72+
$this->customRules[] = $type;
73+
$this->hasCustomRules = true;
6474
}
65-
}elseif(\is_array($type)){
66-
$value=JArray::getValue($type, "value", 2);
67-
$prompt=JArray::getValue($type, "prompt", 1);
68-
$type=JArray::getValue($type, "type", 0);
69-
$rule=new Rule($type,$prompt,$value);
70-
}else {
75+
} elseif (\is_array($type)) {
76+
$value = JArray::getValue($type, "value", 2);
77+
$prompt = JArray::getValue($type, "prompt", 1);
78+
$type = JArray::getValue($type, "type", 0);
79+
$rule = new Rule($type, $prompt, $value);
80+
} else {
7181
$rule = new Rule($type, $prompt, $value);
7282
}
73-
$this->rules[]=$rule;
83+
$this->rules[] = $rule;
7484
return $rule;
7585
}
7686

77-
public function jsonSerialize(){
78-
$result=["identifier"=>$this->identifier,"rules"=>$this->rules];
79-
if($this->optional){
80-
$result["optional"]=true;
87+
# [\ReturnTypeWillChange]
88+
public function jsonSerialize() {
89+
$result = [
90+
"identifier" => $this->identifier,
91+
"rules" => $this->rules
92+
];
93+
if ($this->optional) {
94+
$result["optional"] = true;
8195
}
82-
if(isset($this->depends)){
83-
$result["depends"]=$this->depends;
96+
if (isset($this->depends)) {
97+
$result["depends"] = $this->depends;
8498
}
8599
return $result;
86100
}
87101

88102
public function setDepends($depends) {
89-
$this->depends=$depends;
103+
$this->depends = $depends;
90104
return $this;
91105
}
92106

93107
public function setOptional($optional) {
94-
$this->optional=$optional;
108+
$this->optional = $optional;
95109
return $this;
96110
}
97111

98-
public function compile(JsUtils $js){
99-
if($this->hasCustomRules) {
112+
public function compile(JsUtils $js) {
113+
if ($this->hasCustomRules) {
100114
foreach ($this->customRules as $rule) {
101115
$rule->compile($js);
102116
}
103117
}
104118
}
105-
106119
}

0 commit comments

Comments
 (0)