Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Update to PHP5.4 #6

Merged
merged 2 commits into from Sep 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 5 additions & 9 deletions Exception/Exception.php
Expand Up @@ -34,7 +34,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\Mime\Exception {
namespace Hoa\Mime\Exception;

use Hoa\Core;

/**
* Class \Hoa\Mime\Exception.
Expand All @@ -46,15 +48,9 @@
* @license New BSD License
*/

class Exception extends \Hoa\Core\Exception { }

}

namespace {
class Exception extends Core\Exception { }

/**
* Flex entity.
*/
Hoa\Core\Consistency::flexEntity('Hoa\Mime\Exception\Exception');

}
Core\Consistency::flexEntity('Hoa\Mime\Exception\Exception');
15 changes: 1 addition & 14 deletions Exception/MimeIsNotFound.php
Expand Up @@ -34,18 +34,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace {

from('Hoa')

/**
* \Hoa\Mime\Exception
*/
-> import('Mime.Exception.~');

}

namespace Hoa\Mime\Exception {
namespace Hoa\Mime\Exception;

/**
* Class \Hoa\Mime\MimeIsNotFound.
Expand All @@ -58,5 +47,3 @@
*/

class MimeIsNotFound extends Exception { }

}
61 changes: 21 additions & 40 deletions Mime.php
Expand Up @@ -34,23 +34,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace {
namespace Hoa\Mime;

from('Hoa')

/**
* \Hoa\Mime\Exception
*/
-> import('Mime.Exception.~')

/**
* \Hoa\Mime\Exception\MimeIsNotFound
*/
-> import('Mime.Exception.MimeIsNotFound');

}

namespace Hoa\Mime {
use Hoa\Core;
use Hoa\Stream;

/**
* Class \Hoa\Mime.
Expand All @@ -63,7 +50,7 @@
* @license New BSD License
*/

class Mime implements \Hoa\Core\Parameter\Parameterizable {
class Mime implements Core\Parameter\Parameterizable {

/**
* Structure: media/type part.
Expand Down Expand Up @@ -155,17 +142,17 @@ class Mime implements \Hoa\Core\Parameter\Parameterizable {
* @param \Hoa\Stream $stream Stream to study.
* @param array $parameters Parameters.
* @return void
* @throw \Hoa\Controller\Exception
* @throw \Hoa\Mime\Exception
*/
public function __construct ( \Hoa\Stream $stream,
Array $parameters = array() ) {
public function __construct ( Stream $stream,
Array $parameters = [] ) {

$this->_parameters = new \Hoa\Core\Parameter(
$this->_parameters = new Core\Parameter(
$this,
array(),
array(
[],
[
'magic' => null
)
]
);
$this->_parameters->setParameters($parameters);
$magic = $this->_parameters->getParameter('magic');
Expand Down Expand Up @@ -215,10 +202,10 @@ public static function compute ( $magic = null ) {
throw new Exception(
'Magic file %s does not exist.', 0, $magic);

static::$_computed = array(
self::STRUCTURE_MEDIA_TYPE => array(),
self::STRUCTURE_EXTENSION => array()
);
static::$_computed = [
self::STRUCTURE_MEDIA_TYPE => [],
self::STRUCTURE_EXTENSION => []
];
$s_media_type = &static::$_computed[self::STRUCTURE_MEDIA_TYPE];
$s_extension = &static::$_computed[self::STRUCTURE_EXTENSION];
$splashed = file($magic);
Expand Down Expand Up @@ -267,11 +254,11 @@ public static function compute ( $magic = null ) {
'Magic file %s seems to be corrupted (at line %d). ' .
'You should take a look at this piece of code:' .
$message,
1, array($magic, $i), $exception);
1, [$magic, $i], $exception);
}

if(!isset($s_media_type[$media]))
$s_media_type[$media] = array();
$s_media_type[$media] = [];

if(null == $extensions) {

Expand Down Expand Up @@ -368,11 +355,11 @@ public static function parseMime ( $mime ) {
* @return void
* @throw \Hoa\Mime\Exception\MimeIsNotFound
*/
protected function _find ( \Hoa\Stream $stream ) {
protected function _find ( Stream $stream ) {

$name = $stream->getStreamName();

if($stream instanceof \Hoa\Stream\IStream\Pathable)
if($stream instanceof Stream\IStream\Pathable)
$based = $stream->getBasename();
else
$based = basename($name);
Expand Down Expand Up @@ -414,7 +401,7 @@ public function getExtension ( ) {
*/
public function getOtherExtensions ( ) {

$out = array();
$out = [];
$current = $this->getExtension();
$others = self::$_computed[self::STRUCTURE_MEDIA_TYPE]
[$this->getMedia()]
Expand Down Expand Up @@ -483,13 +470,7 @@ public function isVendor ( ) {
}
}

}

namespace {

/**
* Flex entity.
*/
Hoa\Core\Consistency::flexEntity('Hoa\Mime\Mime');

}
Core\Consistency::flexEntity('Hoa\Mime\Mime');