Skip to content

Commit

Permalink
Merge tag 'v11.37.0'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Jan 6, 2025
2 parents 06c33e3 + 6cb103d commit 537a348
Show file tree
Hide file tree
Showing 31 changed files with 498 additions and 64 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public function has($key)
/**
* Determine if any of the keys exist in the collection.
*
* @param mixed $key
* @param TKey|array<array-key, TKey> $key
* @return bool
*/
public function hasAny($key)
Expand All @@ -602,7 +602,7 @@ public function hasAny($key)
$keys = is_array($key) ? $key : func_get_args();

foreach ($keys as $value) {
if ($this->has($value)) {
if (array_key_exists($value, $this->items)) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Concurrency/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"illuminate/contracts": "^11.0",
"illuminate/process": "^11.0",
"illuminate/support": "^11.0",
"laravel/serializable-closure": "^1.2.2"
"laravel/serializable-closure": "^1.3|^2.0"
},
"autoload": {
"psr-4": {
Expand Down
26 changes: 13 additions & 13 deletions src/Illuminate/Console/Scheduling/ManagesFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function everyThirtySeconds()
/**
* Schedule the event to run multiple times per minute.
*
* @param int $seconds
* @param int<0, 59> $seconds
* @return $this
*/
protected function repeatEvery($seconds)
Expand Down Expand Up @@ -250,7 +250,7 @@ public function hourly()
/**
* Schedule the event to run hourly at a given offset in the hour.
*
* @param array|string|int $offset
* @param array|string|int<0, 23>|int<0, 23>[] $offset
* @return $this
*/
public function hourlyAt($offset)
Expand Down Expand Up @@ -353,8 +353,8 @@ public function dailyAt($time)
/**
* Schedule the event to run twice daily.
*
* @param int $first
* @param int $second
* @param int<0, 23> $first
* @param int<0, 23> $second
* @return $this
*/
public function twiceDaily($first = 1, $second = 13)
Expand All @@ -365,9 +365,9 @@ public function twiceDaily($first = 1, $second = 13)
/**
* Schedule the event to run twice daily at a given offset.
*
* @param int $first
* @param int $second
* @param int $offset
* @param int<0, 23> $first
* @param int<0, 23> $second
* @param int<0, 59> $offset
* @return $this
*/
public function twiceDailyAt($first = 1, $second = 13, $offset = 0)
Expand All @@ -380,8 +380,8 @@ public function twiceDailyAt($first = 1, $second = 13, $offset = 0)
/**
* Schedule the event to run at the given minutes and hours.
*
* @param array|string|int $minutes
* @param array|string|int $hours
* @param array|string|int<0, 59> $minutes
* @param array|string|int<0, 23> $hours
* @return $this
*/
protected function hourBasedSchedule($minutes, $hours)
Expand Down Expand Up @@ -525,7 +525,7 @@ public function monthly()
/**
* Schedule the event to run monthly on a given day and time.
*
* @param int $dayOfMonth
* @param int<1, 31> $dayOfMonth
* @param string $time
* @return $this
*/
Expand All @@ -539,8 +539,8 @@ public function monthlyOn($dayOfMonth = 1, $time = '0:0')
/**
* Schedule the event to run twice monthly at a given time.
*
* @param int $first
* @param int $second
* @param int<1, 31> $first
* @param int<1, 31> $second
* @param string $time
* @return $this
*/
Expand Down Expand Up @@ -611,7 +611,7 @@ public function yearly()
* Schedule the event to run yearly on a given month, day, and time.
*
* @param int $month
* @param int|string $dayOfMonth
* @param int<1, 31>|string $dayOfMonth
* @param string $time
* @return $this
*/
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Database/DetectsLostConnections.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ protected function causedByLostConnection(Throwable $e)
'SQLSTATE[HY000] [2002] The requested address is not valid in its context',
'SQLSTATE[HY000] [2002] A socket operation was attempted to an unreachable network',
'SQLSTATE[HY000] [2002] Operation now in progress',
'SQLSTATE[HY000] [2002] Operation in progress',
'SQLSTATE[HY000]: General error: 3989',
'went away',
'No such file or directory',
Expand Down
74 changes: 74 additions & 0 deletions src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,46 @@ public function orWhereRelation($relation, $column, $operator = null, $value = n
});
}

/**
* Add a basic count / exists condition to a relationship query.
*
* @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
* @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
* @param mixed $operator
* @param mixed $value
* @return $this
*/
public function whereDoesntHaveRelation($relation, $column, $operator = null, $value = null)
{
return $this->whereDoesntHave($relation, function ($query) use ($column, $operator, $value) {
if ($column instanceof Closure) {
$column($query);
} else {
$query->where($column, $operator, $value);
}
});
}

/**
* Add an "or where" clause to a relationship query.
*
* @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
* @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
* @param mixed $operator
* @param mixed $value
* @return $this
*/
public function orWhereDoesntHaveRelation($relation, $column, $operator = null, $value = null)
{
return $this->orWhereDoesntHave($relation, function ($query) use ($column, $operator, $value) {
if ($column instanceof Closure) {
$column($query);
} else {
$query->where($column, $operator, $value);
}
});
}

/**
* Add a polymorphic relationship condition to the query with a where clause.
*
Expand Down Expand Up @@ -458,6 +498,40 @@ public function orWhereMorphRelation($relation, $types, $column, $operator = nul
});
}

/**
* Add a polymorphic relationship condition to the query with a doesn't have clause.
*
* @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
* @param string|array $types
* @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
* @param mixed $operator
* @param mixed $value
* @return $this
*/
public function whereMorphDoesntHaveRelation($relation, $types, $column, $operator = null, $value = null)
{
return $this->whereDoesntHaveMorph($relation, $types, function ($query) use ($column, $operator, $value) {
$query->where($column, $operator, $value);
});
}

/**
* Add a polymorphic relationship condition to the query with an "or doesn't have" clause.
*
* @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
* @param string|array $types
* @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
* @param mixed $operator
* @param mixed $value
* @return $this
*/
public function orWhereMorphDoesntHaveRelation($relation, $types, $column, $operator = null, $value = null)
{
return $this->orWhereDoesntHaveMorph($relation, $types, function ($query) use ($column, $operator, $value) {
$query->where($column, $operator, $value);
});
}

/**
* Add a morph-to relationship condition to the query.
*
Expand Down
7 changes: 5 additions & 2 deletions src/Illuminate/Database/Query/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1168,8 +1168,11 @@ public function compileInsert(Builder $query, array $values)
return "insert into {$table} default values";
}

if (! is_array(reset($values))) {
$values = [$values];
if (! array_is_list($values)) {
$values = (new Collection(array_keys($values)))
->some(fn ($key) => ! is_numeric($key))
? [$values]
: array_values($values);
}

$columns = $this->columnize(array_keys(reset($values)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ public function withRouting(?Closure $using = null,
{
if (is_null($using) && (is_string($web) || is_array($web) || is_string($api) || is_array($api) || is_string($pages) || is_string($health)) || is_callable($then)) {
$using = $this->buildRoutingCallback($web, $api, $pages, $health, $apiPrefix, $then);

if (is_string($health)) {
PreventRequestsDuringMaintenance::except($health);
}
}

AppRouteServiceProvider::loadRoutesUsing($using);
Expand Down Expand Up @@ -212,8 +216,6 @@ protected function buildRoutingCallback(array|string|null $web,
}

if (is_string($health)) {
PreventRequestsDuringMaintenance::except($health);

Route::get($health, function () {
$exception = null;

Expand Down
35 changes: 19 additions & 16 deletions src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Cookie\CookieValuePrefix;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Uri;
use Illuminate\Testing\LoggedExceptionCollection;
use Illuminate\Testing\TestResponse;
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
Expand Down Expand Up @@ -355,7 +356,7 @@ public function withPrecognition()
/**
* Visit the given URI with a GET request.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $headers
* @return \Illuminate\Testing\TestResponse
*/
Expand All @@ -370,7 +371,7 @@ public function get($uri, array $headers = [])
/**
* Visit the given URI with a GET request, expecting a JSON response.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $headers
* @param int $options
* @return \Illuminate\Testing\TestResponse
Expand All @@ -383,7 +384,7 @@ public function getJson($uri, array $headers = [], $options = 0)
/**
* Visit the given URI with a POST request.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @return \Illuminate\Testing\TestResponse
Expand All @@ -399,7 +400,7 @@ public function post($uri, array $data = [], array $headers = [])
/**
* Visit the given URI with a POST request, expecting a JSON response.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @param int $options
Expand All @@ -413,7 +414,7 @@ public function postJson($uri, array $data = [], array $headers = [], $options =
/**
* Visit the given URI with a PUT request.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @return \Illuminate\Testing\TestResponse
Expand All @@ -429,7 +430,7 @@ public function put($uri, array $data = [], array $headers = [])
/**
* Visit the given URI with a PUT request, expecting a JSON response.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @param int $options
Expand All @@ -443,7 +444,7 @@ public function putJson($uri, array $data = [], array $headers = [], $options =
/**
* Visit the given URI with a PATCH request.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @return \Illuminate\Testing\TestResponse
Expand All @@ -459,7 +460,7 @@ public function patch($uri, array $data = [], array $headers = [])
/**
* Visit the given URI with a PATCH request, expecting a JSON response.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @param int $options
Expand All @@ -473,7 +474,7 @@ public function patchJson($uri, array $data = [], array $headers = [], $options
/**
* Visit the given URI with a DELETE request.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @return \Illuminate\Testing\TestResponse
Expand All @@ -489,7 +490,7 @@ public function delete($uri, array $data = [], array $headers = [])
/**
* Visit the given URI with a DELETE request, expecting a JSON response.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @param int $options
Expand All @@ -503,7 +504,7 @@ public function deleteJson($uri, array $data = [], array $headers = [], $options
/**
* Visit the given URI with an OPTIONS request.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @return \Illuminate\Testing\TestResponse
Expand All @@ -520,7 +521,7 @@ public function options($uri, array $data = [], array $headers = [])
/**
* Visit the given URI with an OPTIONS request, expecting a JSON response.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @param int $options
Expand All @@ -534,7 +535,7 @@ public function optionsJson($uri, array $data = [], array $headers = [], $option
/**
* Visit the given URI with a HEAD request.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $headers
* @return \Illuminate\Testing\TestResponse
*/
Expand All @@ -551,7 +552,7 @@ public function head($uri, array $headers = [])
* Call the given URI with a JSON request.
*
* @param string $method
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $data
* @param array $headers
* @param int $options
Expand Down Expand Up @@ -584,7 +585,7 @@ public function json($method, $uri, array $data = [], array $headers = [], $opti
* Call the given URI and return the Response.
*
* @param string $method
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @param array $parameters
* @param array $cookies
* @param array $files
Expand Down Expand Up @@ -619,11 +620,13 @@ public function call($method, $uri, $parameters = [], $cookies = [], $files = []
/**
* Turn the given URI into a fully qualified URL.
*
* @param string $uri
* @param \Illuminate\Support\Uri|string $uri
* @return string
*/
protected function prepareUrlForRequest($uri)
{
$uri = $uri instanceof Uri ? $uri->value() : $uri;

if (str_starts_with($uri, '/')) {
$uri = substr($uri, 1);
}
Expand Down
Loading

0 comments on commit 537a348

Please sign in to comment.