Skip to content

Commit c92c654

Browse files
authored
Merge pull request #1 from slpcode/analysis-XaMNgW
Apply fixes from StyleCI
2 parents 14bfcd7 + 25af59c commit c92c654

15 files changed

Lines changed: 348 additions & 194 deletions

examples/request/TestRequest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
<?php
22

3+
/*
4+
* This file is part of the slpcode/form-request-validation.
5+
*
6+
* (c) slpcode <1370808424@qq.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
use Slpcode\FormRequestValidation\FormRequest;
413

514
class TestRequest extends FormRequest
615
{
716
/**
8-
* 设置验证规则
17+
* 设置验证规则.
918
*
1019
* @return array
1120
*/
1221
protected function rules()
1322
{
1423
return [
1524
'name' => 'required|max:20',
16-
'age' => 'required|min:6'
25+
'age' => 'required|min:6',
1726
];
1827
}
1928

2029
/**
21-
* 设置验证错误信息
30+
* 设置验证错误信息.
2231
*
2332
* @return array
2433
*/
@@ -28,12 +37,12 @@ protected function messages()
2837
}
2938

3039
/**
31-
* 自定义字段名称
40+
* 自定义字段名称.
3241
*
3342
* @return array
3443
*/
3544
protected function attributes()
3645
{
3746
return [];
3847
}
39-
}
48+
}

examples/run.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
<?php
2+
3+
/*
4+
* This file is part of the slpcode/form-request-validation.
5+
*
6+
* (c) slpcode <1370808424@qq.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
212
require_once '../vendor/autoload.php';
313

414
require_once 'request/TestRequest.php';
@@ -10,8 +20,8 @@
1020

1121
//dd($validator);
1222

13-
$request = new TestRequest;
23+
$request = new TestRequest();
1424

1525
$result = $request->make();
1626

17-
dd($result->errors());
27+
dd($result->errors());
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
<?php
22

3-
namespace Slpcode\FormRequestValidation\Exceptions;
3+
/*
4+
* This file is part of the slpcode/form-request-validation.
5+
*
6+
* (c) slpcode <1370808424@qq.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
411

12+
namespace Slpcode\FormRequestValidation\Exceptions;
513

614
class ValidationException extends \Exception
715
{
8-
}
16+
}

src/FormRequest.php

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
11
<?php
22

3+
/*
4+
* This file is part of the slpcode/form-request-validation.
5+
*
6+
* (c) slpcode <1370808424@qq.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
312
namespace Slpcode\FormRequestValidation;
413

514
use Slpcode\FormRequestValidation\Exceptions\ValidationException;
615
use Symfony\Component\HttpFoundation\ParameterBag;
716

817
class FormRequest extends Request
918
{
10-
protected $translation_path = __DIR__ . '/lang';
19+
protected $translation_path = __DIR__.'/lang';
20+
1121
protected $translation_locale = 'zh-CN';
1222

1323
/**
14-
* 构造初始化
24+
* 构造初始化.
1525
*
1626
* FormRequest constructor.
27+
*
1728
* @param array $attributeData
1829
*/
1930
public function __construct($attributeData = [])
2031
{
2132
parent::__construct($_GET, $_POST, $attributeData, $_COOKIE, $_FILES, $_SERVER);
2233

2334
/**
24-
* 判断是否符合传递body数据,例如json形式数据,如果符合则重新赋值$this->request
35+
* 判断是否符合传递body数据,例如json形式数据,如果符合则重新赋值$this->request.
2536
*/
2637
if (0 === strpos($this->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
2738
&& \in_array(strtoupper($this->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])
@@ -35,10 +46,11 @@ public function __construct($attributeData = [])
3546
}
3647

3748
/**
38-
* 设置语言和路径
49+
* 设置语言和路径.
3950
*
4051
* @param string $locale
4152
* @param string $path
53+
*
4254
* @return FormRequest
4355
*/
4456
public function setLang($locale = 'zh-CN', $path = '')
@@ -54,7 +66,7 @@ public function setLang($locale = 'zh-CN', $path = '')
5466
}
5567

5668
/**
57-
* 获取验证实例
69+
* 获取验证实例.
5870
*/
5971
public function getValidator()
6072
{
@@ -63,6 +75,7 @@ public function getValidator()
6375

6476
/**
6577
* @return FormRequest
78+
*
6679
* @throws \Exception
6780
*/
6881
public function check()
@@ -112,7 +125,7 @@ protected function validationData()
112125
}
113126

114127
/**
115-
* 设置验证规则
128+
* 设置验证规则.
116129
*
117130
* @return array
118131
*/
@@ -122,7 +135,7 @@ protected function rules()
122135
}
123136

124137
/**
125-
* 设置验证错误信息
138+
* 设置验证错误信息.
126139
*
127140
* @return array
128141
*/
@@ -132,7 +145,7 @@ protected function messages()
132145
}
133146

134147
/**
135-
* 自定义字段名称
148+
* 自定义字段名称.
136149
*
137150
* @return array
138151
*/
@@ -148,4 +161,4 @@ protected function extend()
148161
{
149162
return $this;
150163
}
151-
}
164+
}

0 commit comments

Comments
 (0)