Skip to content

Commit c43ac09

Browse files
committed
Configurator - silence E_USER_DEPRECATED from nette/di
1 parent a69c96d commit c43ac09

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/DependencyInjection/Configurator.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
namespace PHPStan\DependencyInjection;
44

55
use Nette\DI\Config\Loader;
6+
use Nette\DI\Container as OriginalNetteContainer;
67
use Nette\DI\ContainerLoader;
78
use PHPStan\File\FileReader;
89
use function array_keys;
10+
use function error_reporting;
11+
use function restore_error_handler;
12+
use function set_error_handler;
913
use function sha1;
14+
use const E_USER_DEPRECATED;
1015
use const PHP_RELEASE_VERSION;
1116
use const PHP_VERSION_ID;
1217

@@ -60,6 +65,26 @@ public function loadContainer(): string
6065
);
6166
}
6267

68+
public function createContainer(bool $initialize = true): OriginalNetteContainer
69+
{
70+
set_error_handler(static function (int $errno): bool {
71+
if ((error_reporting() & $errno) === 0) {
72+
// silence @ operator
73+
return true;
74+
}
75+
76+
return $errno === E_USER_DEPRECATED;
77+
});
78+
79+
try {
80+
$container = parent::createContainer($initialize);
81+
} finally {
82+
restore_error_handler();
83+
}
84+
85+
return $container;
86+
}
87+
6388
/**
6489
* @return string[]
6590
*/

0 commit comments

Comments
 (0)