Skip to content

Commit

Permalink
simplify constant usage. FILEINFO_MIME_TYPE is available since PHP 5.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sasezaki committed Mar 23, 2013
1 parent e00aefc commit 5045219
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions library/Zend/File/Transfer/Adapter/AbstractAdapter.php
Expand Up @@ -1224,10 +1224,9 @@ protected function detectMimeType($value)
} }


if (class_exists('finfo', false)) { if (class_exists('finfo', false)) {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
if (!empty($value['options']['magicFile'])) { if (!empty($value['options']['magicFile'])) {
ErrorHandler::start(); ErrorHandler::start();
$mime = finfo_open($const, $value['options']['magicFile']); $mime = finfo_open(FILEINFO_MIME_TYPE, $value['options']['magicFile']);
ErrorHandler::stop(); ErrorHandler::stop();
} }


Expand Down
3 changes: 1 addition & 2 deletions library/Zend/Validator/File/ExcludeMimeType.php
Expand Up @@ -61,9 +61,8 @@ public function isValid($value, $file = null)


$mimefile = $this->getMagicFile(); $mimefile = $this->getMagicFile();
if (class_exists('finfo', false)) { if (class_exists('finfo', false)) {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) { if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) {
$this->finfo = finfo_open($const, $mimefile); $this->finfo = finfo_open(FILEINFO_MIME_TYPE, $mimefile);
} }


if (empty($this->finfo)) { if (empty($this->finfo)) {
Expand Down
6 changes: 2 additions & 4 deletions library/Zend/Validator/File/MimeType.php
Expand Up @@ -201,9 +201,8 @@ public function setMagicFile($file)
$file $file
)); ));
} else { } else {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
ErrorHandler::start(E_NOTICE|E_WARNING); ErrorHandler::start(E_NOTICE|E_WARNING);
$this->finfo = finfo_open($const, $file); $this->finfo = finfo_open(FILEINFO_MIME_TYPE, $file);
$error = ErrorHandler::stop(); $error = ErrorHandler::stop();
if (empty($this->finfo)) { if (empty($this->finfo)) {
$this->finfo = null; $this->finfo = null;
Expand Down Expand Up @@ -376,10 +375,9 @@ public function isValid($value, $file = null)


$mimefile = $this->getMagicFile(); $mimefile = $this->getMagicFile();
if (class_exists('finfo', false)) { if (class_exists('finfo', false)) {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) { if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) {
ErrorHandler::start(E_NOTICE|E_WARNING); ErrorHandler::start(E_NOTICE|E_WARNING);
$this->finfo = finfo_open($const, $mimefile); $this->finfo = finfo_open(FILEINFO_MIME_TYPE, $mimefile);
ErrorHandler::stop(); ErrorHandler::stop();
} }


Expand Down

0 comments on commit 5045219

Please sign in to comment.