Skip to content

Commit

Permalink
[11.x] Fixes function loading conflicts when using `@include('vendor/…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
s-damian and s-damian authored Sep 30, 2024
1 parent 7aabb89 commit 39a60f1
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions src/Illuminate/Support/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,36 @@
use Illuminate\Support\Defer\DeferredCallbackCollection;
use Illuminate\Support\Process\PhpExecutableFinder;

/**
* Defer execution of the given callback.
*
* @param callable|null $callback
* @param string|null $name
* @param bool $always
* @return \Illuminate\Support\Defer\DeferredCallback
*/
function defer(?callable $callback = null, ?string $name = null, bool $always = false)
{
if ($callback === null) {
return app(DeferredCallbackCollection::class);
}
if (! function_exists('Illuminate\Support\defer')) {
/**
* Defer execution of the given callback.
*
* @param callable|null $callback
* @param string|null $name
* @param bool $always
* @return \Illuminate\Support\Defer\DeferredCallback
*/
function defer(?callable $callback = null, ?string $name = null, bool $always = false)
{
if ($callback === null) {
return app(DeferredCallbackCollection::class);
}

return tap(
new DeferredCallback($callback, $name, $always),
fn ($deferred) => app(DeferredCallbackCollection::class)[] = $deferred
);
return tap(
new DeferredCallback($callback, $name, $always),
fn ($deferred) => app(DeferredCallbackCollection::class)[] = $deferred
);
}
}

/**
* Determine the PHP Binary.
*
* @return string
*/
function php_binary()
{
return (new PhpExecutableFinder)->find(false) ?: 'php';
if (! function_exists('Illuminate\Support\php_binary')) {
/**
* Determine the PHP Binary.
*
* @return string
*/
function php_binary()
{
return (new PhpExecutableFinder)->find(false) ?: 'php';
}
}

0 comments on commit 39a60f1

Please sign in to comment.