Skip to content

Commit

Permalink
Merge branch '6.0' into 6.1
Browse files Browse the repository at this point in the history
* 6.0:
  [Messenger] cs fix
  [Messenger] Fix time-limit check exception
  [Console] Fix console `ProgressBar::override()` after manual `ProgressBar::cleanup()`
  [FrameworkBundle] typo default_lifetime example
  [HttpClient] Handle Amp HTTP client v5 incompatibility gracefully
  [HttpKernel] Don’t try to wire Response argument with controller.service_arguments
  [PhpUnitBridge] Fix language deprecations incorrectly marked as direct
  [FrameworkBundle] Removed unused $willBeAvailable params on Configuration
  [Cache] Remove extra type condition in MemcachedAdapter::createConnection()
  Tell about messenger:consume invalid limit options
  [Messenger] Do not throw 'no handlers' exception when skipping due to duplicate handling
  • Loading branch information
nicolas-grekas committed Nov 14, 2022
2 parents 07cf788 + 2368af7 commit c8163ef
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 10 additions & 2 deletions DeprecationErrorHandler/Deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Deprecation

private $trace = [];
private $message;
private $languageDeprecation;
private $originClass;
private $originMethod;
private $triggeringFile;
Expand All @@ -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'];
Expand All @@ -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])) {
Expand Down Expand Up @@ -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) {
Expand Down
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

0 comments on commit c8163ef

Please sign in to comment.