Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: symfony/phpunit-bridge
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.4.14
Choose a base ref
...
head repository: symfony/phpunit-bridge
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.4.16
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Nov 8, 2022

  1. Copy the full SHA
    b3378a7 View commit details

Commits on Nov 14, 2022

  1. Merge branch '4.4' into 5.4

    * 4.4:
      [Messenger] Fix time-limit check exception
      [PhpUnitBridge] Fix language deprecations incorrectly marked as direct
      Tell about messenger:consume invalid limit options
      [Messenger] Do not throw 'no handlers' exception when skipping due to duplicate handling
    nicolas-grekas committed Nov 14, 2022
    Copy the full SHA
    5ea977e View commit details
2 changes: 1 addition & 1 deletion DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ public function handleError($type, $msg, $file, $line, $context = [])
$msg = $trace[1]['args'][0];
}

$deprecation = new Deprecation($msg, $trace, $file);
$deprecation = new Deprecation($msg, $trace, $file, \E_DEPRECATED === $type);
if ($deprecation->isMuted()) {
return null;
}
12 changes: 10 additions & 2 deletions DeprecationErrorHandler/Deprecation.php
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ class Deprecation

private $trace = [];
private $message;
private $languageDeprecation;
private $originClass;
private $originMethod;
private $triggeringFile;
@@ -56,8 +57,9 @@ class Deprecation
/**
* @param string $message
* @param string $file
* @param bool $languageDeprecation
*/
public function __construct($message, array $trace, $file)
public function __construct($message, array $trace, $file, $languageDeprecation = false)
{
if (isset($trace[2]['function']) && 'trigger_deprecation' === $trace[2]['function']) {
$file = $trace[2]['file'];
@@ -66,6 +68,7 @@ public function __construct($message, array $trace, $file)

$this->trace = $trace;
$this->message = $message;
$this->languageDeprecation = $languageDeprecation;

$i = \count($trace);
while (1 < $i && $this->lineShouldBeSkipped($trace[--$i])) {
@@ -239,7 +242,12 @@ public function isMuted()
*/
public function getType()
{
if (self::PATH_TYPE_SELF === $pathType = $this->getPathType($this->triggeringFile)) {
$pathType = $this->getPathType($this->triggeringFile);
if ($this->languageDeprecation && self::PATH_TYPE_VENDOR === $pathType) {
// the triggering file must be used for language deprecations
return self::TYPE_INDIRECT;
}
if (self::PATH_TYPE_SELF === $pathType) {
return self::TYPE_SELF;
}
if (self::PATH_TYPE_UNDETERMINED === $pathType) {
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace acme\lib;

class PhpDeprecation implements \Serializable
{
public function serialize(): string
{
return serialize([]);
}

public function unserialize($data): void
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--TEST--
Test that a PHP deprecation from a vendor class autoload is considered indirect.
--SKIPIF--
<?php if (\PHP_VERSION_ID < 80100) echo 'skip'; ?>
--FILE--
<?php

$k = 'SYMFONY_DEPRECATIONS_HELPER';
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'max[total]=0');
putenv('ANSICON');
putenv('ConEmuANSI');
putenv('TERM');

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = dirname($vendor);
}
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
require_once __DIR__.'/../../bootstrap.php';
eval(<<<'EOPHP'
namespace PHPUnit\Util;
class Test
{
public static function getGroups()
{
return array();
}
}
EOPHP
);
require __DIR__.'/fake_vendor/autoload.php';

\Symfony\Component\ErrorHandler\DebugClassLoader::enable();
new \acme\lib\PhpDeprecation();

?>
--EXPECTF--
Remaining indirect deprecation notices (1)

1x: acme\lib\PhpDeprecation implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)
1x in DebugClassLoader::loadClass from Symfony\Component\ErrorHandler