Skip to content

Commit 39a60f1

Browse files
authored
[11.x] Fixes function loading conflicts when using @include('vendor/autoload.php') via Laravel Envoy (#52974)
* Fix conflicts with ading function_exists in Support functions * Fix with php_binary * Fix with namespace --------- Co-authored-by: s-damian <[email protected]>
1 parent 7aabb89 commit 39a60f1

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

src/Illuminate/Support/functions.php

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,36 @@
66
use Illuminate\Support\Defer\DeferredCallbackCollection;
77
use Illuminate\Support\Process\PhpExecutableFinder;
88

9-
/**
10-
* Defer execution of the given callback.
11-
*
12-
* @param callable|null $callback
13-
* @param string|null $name
14-
* @param bool $always
15-
* @return \Illuminate\Support\Defer\DeferredCallback
16-
*/
17-
function defer(?callable $callback = null, ?string $name = null, bool $always = false)
18-
{
19-
if ($callback === null) {
20-
return app(DeferredCallbackCollection::class);
21-
}
9+
if (! function_exists('Illuminate\Support\defer')) {
10+
/**
11+
* Defer execution of the given callback.
12+
*
13+
* @param callable|null $callback
14+
* @param string|null $name
15+
* @param bool $always
16+
* @return \Illuminate\Support\Defer\DeferredCallback
17+
*/
18+
function defer(?callable $callback = null, ?string $name = null, bool $always = false)
19+
{
20+
if ($callback === null) {
21+
return app(DeferredCallbackCollection::class);
22+
}
2223

23-
return tap(
24-
new DeferredCallback($callback, $name, $always),
25-
fn ($deferred) => app(DeferredCallbackCollection::class)[] = $deferred
26-
);
24+
return tap(
25+
new DeferredCallback($callback, $name, $always),
26+
fn ($deferred) => app(DeferredCallbackCollection::class)[] = $deferred
27+
);
28+
}
2729
}
2830

29-
/**
30-
* Determine the PHP Binary.
31-
*
32-
* @return string
33-
*/
34-
function php_binary()
35-
{
36-
return (new PhpExecutableFinder)->find(false) ?: 'php';
31+
if (! function_exists('Illuminate\Support\php_binary')) {
32+
/**
33+
* Determine the PHP Binary.
34+
*
35+
* @return string
36+
*/
37+
function php_binary()
38+
{
39+
return (new PhpExecutableFinder)->find(false) ?: 'php';
40+
}
3741
}

0 commit comments

Comments
 (0)