Skip to content
Permalink
Browse files

used PHP 7.1 features

  • Loading branch information...
dg committed Aug 5, 2019
1 parent 904b1d7 commit 86fa4d8ea5dd99e5f7e77bd96d7d3ed368d7d96e
Showing with 8 additions and 19 deletions.
  1. +3 −5 src/Iterators/Filter.php
  2. +1 −1 src/Iterators/RecursiveFilter.php
  3. +2 −6 src/Loaders/NetteLoader.php
  4. +2 −7 src/Utils/MimeTypeDetector.php
@@ -9,8 +9,6 @@
namespace Nette\Iterators;
use Nette;
/**
* CallbackFilterIterator for PHP < 5.4.
@@ -22,16 +20,16 @@ class Filter extends \FilterIterator
protected $callback;
public function __construct(\Iterator $iterator, $callback)
public function __construct(\Iterator $iterator, callable $callback)
{
trigger_error(__CLASS__ . ' is deprecated, use CallbackFilterIterator.', E_USER_WARNING);
parent::__construct($iterator);
$this->callback = Nette\Utils\Callback::check($callback);
$this->callback = $callback;
}
public function accept()
{
return call_user_func($this->callback, $this->current(), $this->key(), $this);
return ($this->callback)($this->current(), $this->key(), $this);
}
}
@@ -16,7 +16,7 @@
*/
class RecursiveFilter extends Filter implements \RecursiveIterator
{
public function __construct(\RecursiveIterator $iterator, $callback)
public function __construct(\RecursiveIterator $iterator, callable $callback)
{
trigger_error(__CLASS__ . ' is deprecated, use RecursiveCallbackFilterIterator.', E_USER_WARNING);
parent::__construct($iterator, $callback);
@@ -39,21 +39,17 @@ public static function getInstance()
/**
* Register autoloader.
* @param bool prepend autoloader?
* @return void
*/
public function register($prepend = false)
public function register(bool $prepend = false): void
{
spl_autoload_register([$this, 'tryLoad'], true, (bool) $prepend);
}
/**
* Handles autoloading of classes or interfaces.
* @param string
* @return void
*/
public function tryLoad($type)
public function tryLoad(string $type): void
{
$type = ltrim($type, '\\');
if (isset($this->list[$type])) {
@@ -19,7 +19,6 @@
*/
class MimeTypeDetector
{
/**
* Static class - cannot be instantiated.
*/
@@ -31,10 +30,8 @@ class MimeTypeDetector
/**
* Returns the MIME content type of file.
* @param string
* @return string
*/
public static function fromFile($file)
public static function fromFile(string $file): string
{
trigger_error(__METHOD__ . '() is deprecated; use finfo_file() instead.', E_USER_DEPRECATED);
if (!is_file($file)) {
@@ -47,10 +44,8 @@ public static function fromFile($file)
/**
* Returns the MIME content type of file.
* @param string
* @return string
*/
public static function fromString($data)
public static function fromString(string $data): string
{
trigger_error(__METHOD__ . '() is deprecated; use finfo_buffer() instead.', E_USER_DEPRECATED);
$type = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data);

0 comments on commit 86fa4d8

Please sign in to comment.
You can’t perform that action at this time.