File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ class PharExtensionInterceptor implements Assertable {
2222 *
2323 * @param string $path
2424 * The path of the phar file to check.
25- *
2625 * @param string $command
2726 * The command being carried out.
2827 *
@@ -46,6 +45,8 @@ public function assert($path, $command) {
4645 }
4746
4847 /**
48+ * Determines if a path has a .phar extension or invoked execution.
49+ *
4950 * @param string $path
5051 * The path of the phar file to check.
5152 *
@@ -62,8 +63,13 @@ private function baseFileContainsPharExtension($path) {
6263 // not not have .phar extension then this should be allowed. For
6364 // example, some CLI tools recommend removing the extension.
6465 $ backtrace = debug_backtrace (DEBUG_BACKTRACE_IGNORE_ARGS );
65- $ caller = array_pop ($ backtrace );
66- if (isset ($ caller ['file ' ]) && $ baseFile === $ caller ['file ' ]) {
66+ // Find the last entry in the backtrace containing a 'file' key as
67+ // sometimes the last caller is executed outside the scope of a file. For
68+ // example, this occurs with shutdown functions.
69+ do {
70+ $ caller = array_pop ($ backtrace );
71+ } while (empty ($ caller ['file ' ]) && !empty ($ backtrace ));
72+ if (isset ($ caller ['file ' ]) && $ baseFile === Helper::determineBaseFile ($ caller ['file ' ])) {
6773 return TRUE ;
6874 }
6975 $ fileExtension = pathinfo ($ baseFile , PATHINFO_EXTENSION );
You can’t perform that action at this time.
0 commit comments