This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/autoload.php.dist
Fabien Potencier b33b1dc00c Merge branch '2.7'
* 2.7: (24 commits)
  bumped Symfony version to 2.6.4
  updated VERSION for 2.6.3
  updated CHANGELOG for 2.6.3
  bumped Symfony version to 2.6.3
  updated VERSION for 2.6.2
  updated CHANGELOG for 2.6.2
  bumped Symfony version to 2.5.10
  updated VERSION for 2.5.9
  updated CHANGELOG for 2.5.9
  [FrameworkBundle] Use security.token_storage service in Controller::getUser()
  bumped Symfony version to 2.3.25
  updated VERSION for 2.3.24
  update CONTRIBUTORS for 2.3.24
  added missing E_USER_DEPRECATED argument to trigger_error() calls
  Removed unneeded version requirements
  updated CHANGELOG for 2.3.24
  fixed tests
  [Security] Don't destroy the session on buggy php releases.
  Enhance deprecation summary at end of tests
  [2.7] silence deprecations for getFactory*() BC layer
  ...

Conflicts:
	CHANGELOG-2.3.md
	CHANGELOG-2.5.md
	CHANGELOG-2.6.md
	src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
2015-01-07 16:59:06 +01:00

134 lines
4.6 KiB
Plaintext

<?php
// Disabling Zend Garbage Collection to prevent segfaults
// https://bugs.php.net/bug.php?id=53976
if (gc_enabled()) {
gc_disable();
}
/**
* Catch deprecation notices and print a summary report at the end of the test suite
*
* @internal
*/
class DeprecationErrorHandler
{
private static $isRegistered = false;
public static function register()
{
if (self::$isRegistered) {
return;
}
$deprecations = array(
'remainingCount' => 0,
'legacyCount' => 0,
'otherCount' => 0,
'remaining' => array(),
'legacy' => array(),
'other' => array(),
);
$deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations) {
if (E_USER_DEPRECATED !== $type) {
return PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
}
$trace = debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
$i = count($trace);
while (isset($trace[--$i]['class']) && ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_'))) {
// No-op
}
if (isset($trace[$i]['class'])) {
$class = $trace[$i]['class'];
$method = $trace[$i]['function'];
$type = 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || strpos($class, '\Legacy') ? 'legacy' : 'remaining';
if ('legacy' === $type && 0 === (error_reporting() & E_USER_DEPRECATED)) {
@++$deprecations[$type]['Silenced']['count'];
} else {
@++$deprecations[$type][$msg]['count'];
@++$deprecations[$type][$msg][$class.'::'.$method];
}
} else {
$type = 'other';
@++$deprecations[$type][$msg]['count'];
}
++$deprecations[$type.'Count'];
};
$oldErrorHandler = set_error_handler($deprecationHandler);
if (null !== $oldErrorHandler) {
restore_error_handler();
if (array('PHPUnit_Util_ErrorHandler', 'handleError') === $oldErrorHandler) {
restore_error_handler();
self::register();
}
} else {
self::$isRegistered = true;
register_shutdown_function(function () use (&$deprecations, $deprecationHandler) {
$colorize = new \SebastianBergmann\Environment\Console();
if ($colorize->hasColorSupport()) {
$colorize = function ($str, $red) {
$color = $red ? '41;37' : '43;30';
return "\x1B[{$color}m{$str}\x1B[0m";
};
} else {
$colorize = function ($str) {return $str;};
}
$currErrorHandler = set_error_handler('var_dump');
restore_error_handler();
if ($currErrorHandler !== $deprecationHandler) {
echo "\n", $colorize('THE ERROR HANDLER HAS CHANGED!', true), "\n";
}
$cmp = function ($a, $b) {
return $b['count'] - $a['count'];
};
foreach (array('remaining', 'legacy', 'other') as $type) {
if ($deprecations[$type]) {
echo "\n", $colorize(sprintf('%s deprecation notices (%d)', ucfirst($type), $deprecations[$type.'Count']), 'legacy' !== $type), "\n";
uasort($deprecations[$type], $cmp);
foreach ($deprecations[$type] as $msg => $notices) {
echo "\n", $msg, ': ', $notices['count'], "x\n";
arsort($notices);
foreach ($notices as $method => $count) {
if ('count' !== $method) {
echo ' ', $count, 'x in ', preg_replace('/(.*)\\\\(.*?::.*?)$/', '$2 from $1', $method), "\n";
}
}
}
}
}
if (!empty($notices)) {
echo "\n";
}
});
}
}
}
if (class_exists('PHPUnit_Util_ErrorHandler')) {
DeprecationErrorHandler::register();
}
$loader = require_once __DIR__.'/vendor/autoload.php';
use Doctrine\Common\Annotations\AnnotationRegistry;
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;