Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[PhpUnitBridge]allow outdated vendors mode #24867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Refactor lagging into outdated
  • Loading branch information
greg0ire committed Jan 29, 2018
commit 4d404070135e28d803d5914a236e101c15a5ec0a
26 changes: 13 additions & 13 deletions 26 src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DeprecationErrorHandler
{
const MODE_WEAK = 'weak';
const MODE_WEAK_VENDORS = 'weak_vendors';
const MODE_WEAK_LAGGING_VENDORS = 'weak_lagging_vendors';
const MODE_ALLOW_OUTDATED_VENDORS = 'allow_outdated_vendors';
const MODE_DISABLED = 'disabled';

private static $isRegistered = false;
Expand All @@ -34,7 +34,7 @@ class DeprecationErrorHandler
* The following reporting modes are supported:
* - use "weak" to hide the deprecation report but keep a global count;
* - use "weak_vendors" to act as "weak" but only for vendors;
* - use "weak_lagging_vendors" to act as "weak" but only for vendors that
* - use "allow_outdated_vendors" to act as "weak" but only for vendors that
* failed to keep up with their upstream dependencies deprecations;
* - use "/some-regexp/" to stop the test suite whenever a deprecation
* message matches the given regular expression;
Expand Down Expand Up @@ -63,7 +63,7 @@ public static function register($mode = 0)
if (!in_array($mode, array(
DeprecationErrorHandler::MODE_WEAK,
DeprecationErrorHandler::MODE_WEAK_VENDORS,
DeprecationErrorHandler::MODE_WEAK_LAGGING_VENDORS,
DeprecationErrorHandler::MODE_ALLOW_OUTDATED_VENDORS,
), true) && (!isset($mode[0]) || '/' !== $mode[0])) {
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
}
Expand All @@ -76,13 +76,13 @@ public static function register($mode = 0)
'remainingCount' => 0,
'legacyCount' => 0,
'otherCount' => 0,
'lagging vendorCount' => 0,
'outdated vendorCount' => 0,
'remaining vendorCount' => 0,
'unsilenced' => array(),
'remaining' => array(),
'legacy' => array(),
'other' => array(),
'lagging vendor' => array(),
'outdated vendor' => array(),
'remaining vendor' => array(),
);
$deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix) {
Expand All @@ -98,7 +98,7 @@ public static function register($mode = 0)
$isVendor = false;
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode ||
(DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = self::inVendors($file)) ||
(DeprecationErrorHandler::MODE_WEAK_LAGGING_VENDORS === $mode && $isLaggingVendor = self::isLaggingVendor($trace));
(DeprecationErrorHandler::MODE_ALLOW_OUTDATED_VENDORS === $mode && $isOutdatedVendor = self::isOutdatedVendor($trace));
$i = count($trace);
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) {
// No-op
Expand All @@ -116,7 +116,7 @@ public static function register($mode = 0)
// if the error has been triggered from vendor code.
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode ||
(DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = isset($parsedMsg['triggering_file']) && self::inVendors($parsedMsg['triggering_file'])) ||
(DeprecationErrorHandler::MODE_WEAK_LAGGING_VENDORS === $mode) && $isLaggingVendor = isset($parsedMsg['trace']) && self::isLaggingVendor($parsedMsg['trace']);
(DeprecationErrorHandler::MODE_ALLOW_OUTDATED_VENDORS === $mode) && $isOutdatedVendor = isset($parsedMsg['trace']) && self::isOutdatedVendor($parsedMsg['trace']);
} else {
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
$method = $trace[$i]['function'];
Expand All @@ -133,8 +133,8 @@ public static function register($mode = 0)
|| in_array('legacy', $Test::getGroups($class, $method), true)
) {
$group = 'legacy';
} elseif (DeprecationErrorHandler::MODE_WEAK_LAGGING_VENDORS === $mode && $isLaggingVendor) {
$group = 'lagging vendor';
} elseif (DeprecationErrorHandler::MODE_ALLOW_OUTDATED_VENDORS === $mode && $isOutdatedVendor) {
$group = 'outdated vendor';
} elseif (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor) {
$group = 'remaining vendor';
} else {
Expand Down Expand Up @@ -209,16 +209,16 @@ public static function register($mode = 0)
if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) {
$groups[] = 'remaining vendor';
}
if (DeprecationErrorHandler::MODE_WEAK_LAGGING_VENDORS === $mode) {
$groups[] = 'lagging vendor';
if (DeprecationErrorHandler::MODE_ALLOW_OUTDATED_VENDORS === $mode) {
$groups[] = 'outdated vendor';
}
array_push($groups, 'legacy', 'other');

foreach ($groups as $group) {
if ($deprecations[$group.'Count']) {
echo "\n", $colorize(
sprintf('%s deprecation notices (%d)', ucfirst($group), $deprecations[$group.'Count']),
!in_array($group, array('legacy', 'remaining vendor', 'lagging vendor'), true)
!in_array($group, array('legacy', 'remaining vendor', 'outdated vendor'), true)
), "\n";

uasort($deprecations[$group], $cmp);
Expand Down Expand Up @@ -247,7 +247,7 @@ public static function register($mode = 0)
}
}

private static function isLaggingVendor(array $trace): bool
private static function isOutdatedVendor(array $trace): bool
{
$erroringFile = $erroringPackage = null;
foreach ($trace as $line) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Test DeprecationErrorHandler in weak vendors mode when calling deprecated api
--FILE--
<?php

putenv('SYMFONY_DEPRECATIONS_HELPER=weak_lagging_vendors');
putenv('SYMFONY_DEPRECATIONS_HELPER=allow_outdated_vendors');
putenv('ANSICON');
putenv('ConEmuANSI');
putenv('TERM');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Test DeprecationErrorHandler in weak vendors mode on vendor file
--FILE--
<?php

putenv('SYMFONY_DEPRECATIONS_HELPER=weak_lagging_vendors');
putenv('SYMFONY_DEPRECATIONS_HELPER=allow_outdated_vendors');
putenv('ANSICON');
putenv('ConEmuANSI');
putenv('TERM');
Expand All @@ -28,8 +28,8 @@ class Test
EOPHP
);
require __DIR__.'/fake_vendor/autoload.php';
require __DIR__.'/fake_vendor/acme/lagging-lib/lagging_file.php';
require __DIR__.'/fake_vendor/acme/outdated-lib/outdated_file.php';

?>
--EXPECTF--
Lagging vendor deprecation notices (1)
Outdated vendor deprecation notices (1)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.