@@ -61,29 +61,26 @@ public function __construct($value)
6161
6262 /**
6363 * Returns the file name.
64- * @return string
6564 */
66- public function getName ()
65+ public function getName (): string
6766 {
6867 return $ this ->name ;
6968 }
7069
7170
7271 /**
7372 * Returns the sanitized file name.
74- * @return string
7573 */
76- public function getSanitizedName ()
74+ public function getSanitizedName (): string
7775 {
7876 return trim (Nette \Utils \Strings::webalize ($ this ->name , '. ' , FALSE ), '.- ' );
7977 }
8078
8179
8280 /**
8381 * Returns the MIME content type of an uploaded file.
84- * @return string|NULL
8582 */
86- public function getContentType ()
83+ public function getContentType (): ? string
8784 {
8885 if ($ this ->isOk () && $ this ->type === NULL ) {
8986 $ this ->type = finfo_file (finfo_open (FILEINFO_MIME_TYPE ), $ this ->tmpName );
@@ -94,69 +91,60 @@ public function getContentType()
9491
9592 /**
9693 * Returns the size of an uploaded file.
97- * @return int
9894 */
99- public function getSize ()
95+ public function getSize (): int
10096 {
10197 return $ this ->size ;
10298 }
10399
104100
105101 /**
106102 * Returns the path to an uploaded file.
107- * @return string
108103 */
109- public function getTemporaryFile ()
104+ public function getTemporaryFile (): string
110105 {
111106 return $ this ->tmpName ;
112107 }
113108
114109
115110 /**
116111 * Returns the path to an uploaded file.
117- * @return string
118112 */
119- public function __toString ()
113+ public function __toString (): string
120114 {
121115 return (string ) $ this ->tmpName ;
122116 }
123117
124118
125119 /**
126120 * Returns the error code. {@link http://php.net/manual/en/features.file-upload.errors.php}
127- * @return int
128121 */
129- public function getError ()
122+ public function getError (): int
130123 {
131124 return $ this ->error ;
132125 }
133126
134127
135128 /**
136129 * Is there any error?
137- * @return bool
138130 */
139- public function isOk ()
131+ public function isOk (): bool
140132 {
141133 return $ this ->error === UPLOAD_ERR_OK ;
142134 }
143135
144136
145- /**
146- * @return bool
147- */
148- public function hasFile ()
137+ public function hasFile (): bool
149138 {
150139 return $ this ->error !== UPLOAD_ERR_NO_FILE ;
151140 }
152141
153142
154143 /**
155144 * Move uploaded file to new location.
156- * @param string
157145 * @return static
158146 */
159- public function move ($ dest )
147+ public function move (string $ dest )
160148 {
161149 $ dir = dirname ($ dest );
162150 @mkdir ($ dir , 0777 , TRUE ); // @ - dir may already exist
@@ -179,40 +167,36 @@ function ($message) use ($dest) {
179167
180168 /**
181169 * Is uploaded file GIF, PNG or JPEG?
182- * @return bool
183170 */
184- public function isImage ()
171+ public function isImage (): bool
185172 {
186173 return in_array ($ this ->getContentType (), ['image/gif ' , 'image/png ' , 'image/jpeg ' ], TRUE );
187174 }
188175
189176
190177 /**
191178 * Returns the image.
192- * @return Nette\Utils\Image
193179 * @throws Nette\Utils\ImageException
194180 */
195- public function toImage ()
181+ public function toImage (): Nette \ Utils \ Image
196182 {
197183 return Nette \Utils \Image::fromFile ($ this ->tmpName );
198184 }
199185
200186
201187 /**
202188 * Returns the dimensions of an uploaded image as array.
203- * @return array|NULL
204189 */
205- public function getImageSize ()
190+ public function getImageSize (): ? array
206191 {
207192 return $ this ->isOk () ? @getimagesize ($ this ->tmpName ) : NULL ; // @ - files smaller than 12 bytes causes read error
208193 }
209194
210195
211196 /**
212197 * Get file contents.
213- * @return string|NULL
214198 */
215- public function getContents ()
199+ public function getContents (): ? string
216200 {
217201 // future implementation can try to work around safe_mode and open_basedir limitations
218202 return $ this ->isOk () ? file_get_contents ($ this ->tmpName ) : NULL ;
0 commit comments