simplified code

This commit is contained in:
Fabien Potencier
2015-08-18 15:18:43 +02:00
parent a089f1e8a7
commit dfd323dec0
+6 -17
View File
@@ -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;
}
}
}