Merge branch '4.4' into 5.0
* 4.4: Provide current file as file path
This commit is contained in:
commit
b0cb757909
@ -99,16 +99,13 @@ class DeprecationErrorHandler
|
|||||||
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
|
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
$trace = debug_backtrace();
|
|
||||||
$filesStack = [];
|
$filesStack = [];
|
||||||
foreach ($trace as $line) {
|
foreach (debug_backtrace() as $frame) {
|
||||||
if (\in_array($line['function'], ['require', 'require_once', 'include', 'include_once'], true)) {
|
if (!isset($frame['file']) || \in_array($frame['function'], ['require', 'require_once', 'include', 'include_once'], true)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($line['file'])) {
|
$filesStack[] = $frame['file'];
|
||||||
$filesStack[] = $line['file'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$deprecations[] = [error_reporting(), $msg, $file, $filesStack];
|
$deprecations[] = [error_reporting(), $msg, $file, $filesStack];
|
||||||
|
@ -165,24 +165,6 @@ class Deprecation
|
|||||||
return false !== strpos($this->triggeringFile, \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR);
|
return false !== strpos($this->triggeringFile, \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getOriginalFilesStack(): array
|
|
||||||
{
|
|
||||||
if (null === $this->originalFilesStack) {
|
|
||||||
$this->originalFilesStack = [];
|
|
||||||
foreach ($this->trace as $line) {
|
|
||||||
if (\in_array($line['function'], ['require', 'require_once', 'include', 'include_once'], true)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!isset($line['file'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->originalFilesStack[] = $line['file'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->originalFilesStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells whether both the calling package and the called package are vendor
|
* Tells whether both the calling package and the called package are vendor
|
||||||
* packages.
|
* packages.
|
||||||
@ -224,6 +206,22 @@ class Deprecation
|
|||||||
return self::TYPE_DIRECT;
|
return self::TYPE_DIRECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getOriginalFilesStack(): array
|
||||||
|
{
|
||||||
|
if (null === $this->originalFilesStack) {
|
||||||
|
$this->originalFilesStack = [];
|
||||||
|
foreach ($this->trace as $frame) {
|
||||||
|
if (!isset($frame['file']) || \in_array($frame['function'], ['require', 'require_once', 'include', 'include_once'], true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->originalFilesStack[] = $frame['file'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->originalFilesStack;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPathType() should always be called prior to calling this method.
|
* getPathType() should always be called prior to calling this method.
|
||||||
*
|
*
|
||||||
|
@ -157,7 +157,7 @@ class DeprecationTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', ''],
|
'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__],
|
||||||
'nonexistent_file' => [Deprecation::TYPE_UNDETERMINED, '', 'MyClass1', 'dummy_vendor_path'],
|
'nonexistent_file' => [Deprecation::TYPE_UNDETERMINED, '', 'MyClass1', 'dummy_vendor_path'],
|
||||||
'serialized_trace_with_nonexistent_triggering_file' => [
|
'serialized_trace_with_nonexistent_triggering_file' => [
|
||||||
Deprecation::TYPE_UNDETERMINED,
|
Deprecation::TYPE_UNDETERMINED,
|
||||||
|
Reference in New Issue
Block a user