1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spatie\Html\Elements; |
4
|
|
|
|
5
|
|
|
use Spatie\Html\BaseElement; |
6
|
|
|
use Illuminate\Support\Traits\Macroable; |
7
|
|
|
|
8
|
|
|
class File extends BaseElement |
9
|
|
|
{ |
10
|
|
|
use Macroable; |
11
|
|
|
|
12
|
|
|
protected $tag = 'input'; |
13
|
|
|
|
14
|
|
|
const ACCEPT_AUDIO = 'audio/*'; |
15
|
|
|
const ACCEPT_VIDEO = 'video/*'; |
16
|
|
|
const ACCEPT_IMAGE = 'image/*'; |
17
|
|
|
|
18
|
|
|
public function __construct() |
19
|
|
|
{ |
20
|
|
|
parent::__construct(); |
21
|
|
|
|
22
|
|
|
$this->attributes->setAttribute('type', 'file'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param string|null $name |
27
|
|
|
* |
28
|
|
|
* @return static |
29
|
|
|
*/ |
30
|
|
|
public function name($name) |
31
|
|
|
{ |
32
|
|
|
return $this->attribute('name', $name); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @return static |
37
|
|
|
*/ |
38
|
|
|
public function required() |
39
|
|
|
{ |
40
|
|
|
return $this->attribute('required'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return static |
45
|
|
|
*/ |
46
|
|
|
public function autofocus() |
47
|
|
|
{ |
48
|
|
|
return $this->attribute('autofocus'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string|null $name |
|
|
|
|
53
|
|
|
* |
54
|
|
|
* @return static |
55
|
|
|
*/ |
56
|
|
|
public function accept($type) |
57
|
|
|
{ |
58
|
|
|
return $this->attribute('accept', $type); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return static |
63
|
|
|
*/ |
64
|
|
|
public function acceptAudio() |
65
|
|
|
{ |
66
|
|
|
return $this->attribute('accept', self::ACCEPT_AUDIO); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return static |
71
|
|
|
*/ |
72
|
|
|
public function acceptVideo() |
73
|
|
|
{ |
74
|
|
|
return $this->attribute('accept', self::ACCEPT_VIDEO); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return static |
79
|
|
|
*/ |
80
|
|
|
public function acceptImage() |
81
|
|
|
{ |
82
|
|
|
return $this->attribute('accept', self::ACCEPT_IMAGE); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return static |
87
|
|
|
*/ |
88
|
|
|
public function multiple() |
89
|
|
|
{ |
90
|
|
|
return $this->attribute('multiple'); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
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.