Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 115de5a

Browse files
Merge branch '5.0'
* 5.0: Provide current file as file path
2 parents 2646fa9 + b0cb757 commit 115de5a

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,13 @@ public static function collectDeprecations($outputFile)
9696
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
9797
}
9898

99-
$trace = debug_backtrace();
10099
$filesStack = [];
101-
foreach ($trace as $line) {
102-
if (\in_array($line['function'], ['require', 'require_once', 'include', 'include_once'], true)) {
100+
foreach (debug_backtrace() as $frame) {
101+
if (!isset($frame['file']) || \in_array($frame['function'], ['require', 'require_once', 'include', 'include_once'], true)) {
103102
continue;
104103
}
105104

106-
if (isset($line['file'])) {
107-
$filesStack[] = $line['file'];
108-
}
105+
$filesStack[] = $frame['file'];
109106
}
110107

111108
$deprecations[] = [error_reporting(), $msg, $file, $filesStack];

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -165,24 +165,6 @@ public function isMuted()
165165
return false !== strpos($this->triggeringFile, \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR);
166166
}
167167

168-
private function getOriginalFilesStack(): array
169-
{
170-
if (null === $this->originalFilesStack) {
171-
$this->originalFilesStack = [];
172-
foreach ($this->trace as $line) {
173-
if (\in_array($line['function'], ['require', 'require_once', 'include', 'include_once'], true)) {
174-
continue;
175-
}
176-
if (!isset($line['file'])) {
177-
continue;
178-
}
179-
$this->originalFilesStack[] = $line['file'];
180-
}
181-
}
182-
183-
return $this->originalFilesStack;
184-
}
185-
186168
/**
187169
* Tells whether both the calling package and the called package are vendor
188170
* packages.
@@ -224,6 +206,22 @@ public function getType()
224206
return self::TYPE_DIRECT;
225207
}
226208

209+
private function getOriginalFilesStack(): array
210+
{
211+
if (null === $this->originalFilesStack) {
212+
$this->originalFilesStack = [];
213+
foreach ($this->trace as $frame) {
214+
if (!isset($frame['file']) || \in_array($frame['function'], ['require', 'require_once', 'include', 'include_once'], true)) {
215+
continue;
216+
}
217+
218+
$this->originalFilesStack[] = $frame['file'];
219+
}
220+
}
221+
222+
return $this->originalFilesStack;
223+
}
224+
227225
/**
228226
* getPathType() should always be called prior to calling this method.
229227
*

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function providerGetTypeDetectsSelf(): array
157157
}
158158

159159
return [
160-
'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', ''],
160+
'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__],
161161
'nonexistent_file' => [Deprecation::TYPE_UNDETERMINED, '', 'MyClass1', 'dummy_vendor_path'],
162162
'serialized_trace_with_nonexistent_triggering_file' => [
163163
Deprecation::TYPE_UNDETERMINED,

0 commit comments

Comments
 (0)