mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 20:06:31 +00:00
simplified code
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
class Twig_Util_DeprecationCollector
|
||||
{
|
||||
private $twig;
|
||||
private $deprecations;
|
||||
|
||||
public function __construct(Twig_Environment $twig)
|
||||
{
|
||||
@@ -50,9 +49,12 @@ class Twig_Util_DeprecationCollector
|
||||
*/
|
||||
public function collect(Iterator $iterator)
|
||||
{
|
||||
$this->deprecations = array();
|
||||
|
||||
set_error_handler(array($this, 'errorHandler'));
|
||||
$deprecations = array();
|
||||
set_error_handler(function($type, $msg) use (&$deprecations) {
|
||||
if (E_USER_DEPRECATED === $type) {
|
||||
$deprecations[] = $msg;
|
||||
}
|
||||
});
|
||||
|
||||
foreach ($iterator as $name => $contents) {
|
||||
try {
|
||||
@@ -64,19 +66,6 @@ class Twig_Util_DeprecationCollector
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
$deprecations = $this->deprecations;
|
||||
$this->deprecations = array();
|
||||
|
||||
return $deprecations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function errorHandler($type, $msg)
|
||||
{
|
||||
if (E_USER_DEPRECATED === $type) {
|
||||
$this->deprecations[] = $msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user