1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spatie\Html\Elements; |
4
|
|
|
|
5
|
|
|
use Spatie\Html\BaseElement; |
6
|
|
|
|
7
|
|
|
class File extends BaseElement |
8
|
|
|
{ |
9
|
|
|
protected $tag = 'input'; |
10
|
|
|
|
11
|
|
|
const ACCEPT_AUDIO = 'audio/*'; |
12
|
|
|
const ACCEPT_VIDEO = 'video/*'; |
13
|
|
|
const ACCEPT_IMAGE = 'image/*'; |
14
|
|
|
|
15
|
|
|
public function __construct() |
16
|
|
|
{ |
17
|
|
|
parent::__construct(); |
18
|
|
|
|
19
|
|
|
$this->attributes->setAttribute('type', 'file'); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param string|null $name |
24
|
|
|
* |
25
|
|
|
* @return static |
26
|
|
|
*/ |
27
|
|
|
public function name($name) |
28
|
|
|
{ |
29
|
|
|
return $this->attribute('name', $name); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return static |
34
|
|
|
*/ |
35
|
|
|
public function required() |
36
|
|
|
{ |
37
|
|
|
return $this->attribute('required'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return static |
42
|
|
|
*/ |
43
|
|
|
public function autofocus() |
44
|
|
|
{ |
45
|
|
|
return $this->attribute('autofocus'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param string|null $name |
|
|
|
|
50
|
|
|
* |
51
|
|
|
* @return static |
52
|
|
|
*/ |
53
|
|
|
public function accept($type) |
54
|
|
|
{ |
55
|
|
|
return $this->attribute('accept', $type); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return static |
60
|
|
|
*/ |
61
|
|
|
public function acceptAudio() |
62
|
|
|
{ |
63
|
|
|
return $this->attribute('accept', self::ACCEPT_AUDIO); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return static |
68
|
|
|
*/ |
69
|
|
|
public function acceptVideo() |
70
|
|
|
{ |
71
|
|
|
return $this->attribute('accept', self::ACCEPT_VIDEO); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return static |
76
|
|
|
*/ |
77
|
|
|
public function acceptImage() |
78
|
|
|
{ |
79
|
|
|
return $this->attribute('accept', self::ACCEPT_IMAGE); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return static |
84
|
|
|
*/ |
85
|
|
|
public function multiple() |
86
|
|
|
{ |
87
|
|
|
return $this->attribute('multiple'); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.