Skip to content

Commit

Permalink
Merge tag 'v11.40.0'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jan 25, 2025
2 parents 3502c22 + 599a281 commit f107d93
Show file tree
Hide file tree
Showing 44 changed files with 1,084 additions and 350 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"league/flysystem-local": "^3.25.1",
"league/uri": "^7.5.1",
"monolog/monolog": "^3.0",
"nesbot/carbon": "^3.4",
"nesbot/carbon": "^3.8.4",
"nunomaduro/termwind": "^2.0",
"psr/container": "^1.1.1|^2.0.1",
"psr/log": "^1.0|^2.0|^3.0",
Expand Down
127 changes: 124 additions & 3 deletions pint.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,130 @@
{
"preset": "empty",
"rules": {
"method_chaining_indentation": true
"array_indentation": true,
"binary_operator_spaces": {
"default": "single_space"
},
"blank_line_after_namespace": true,
"blank_line_after_opening_tag": true,
"blank_line_before_statement": {
"statements": [
"return"
]
},
"blank_line_between_import_groups": true,
"cast_spaces": true,
"class_reference_name_casing": true,
"clean_namespace": true,
"compact_nullable_type_declaration": true,
"concat_space": true,
"constant_case": {
"case": "lower"
},
"declare_equal_normalize": true,
"elseif": true,
"encoding": true,
"full_opening_tag": true,
"function_declaration": true,
"heredoc_to_nowdoc": true,
"include": true,
"indentation_type": true,
"integer_literal_case": true,
"line_ending": true,
"lowercase_cast": true,
"lowercase_keywords": true,
"lowercase_static_reference": true,
"magic_constant_casing": true,
"magic_method_casing": true,
"method_argument_space": {
"on_multiline": "ignore"
},
"method_chaining_indentation": true,
"native_function_casing": true,
"native_type_declaration_casing": true,
"no_alternative_syntax": true,
"no_binary_string": true,
"no_blank_lines_after_class_opening": true,
"no_blank_lines_after_phpdoc": true,
"no_closing_tag": true,
"no_empty_phpdoc": true,
"no_empty_statement": true,
"no_extra_blank_lines": {
"tokens": [
"extra",
"throw",
"use"
]
},
"no_leading_import_slash": true,
"no_leading_namespace_whitespace": true,
"no_multiline_whitespace_around_double_arrow": true,
"no_short_bool_cast": true,
"no_singleline_whitespace_before_semicolons": true,
"no_space_around_double_colon": true,
"no_spaces_after_function_name": true,
"no_trailing_whitespace": true,
"no_trailing_whitespace_in_comment": true,
"no_unneeded_braces": true,
"no_unneeded_control_parentheses": true,
"no_unneeded_import_alias": true,
"no_unset_cast": true,
"no_unused_imports": true,
"no_useless_return": true,
"no_whitespace_before_comma_in_array": true,
"no_whitespace_in_blank_line": true,
"normalize_index_brace": true,
"not_operator_with_successor_space": true,
"nullable_type_declaration_for_default_null_value": true,
"object_operator_without_whitespace": true,
"ordered_imports": {
"sort_algorithm": "alpha",
"imports_order": [
"const",
"class",
"function"
]
},
"phpdoc_indent": true,
"phpdoc_inline_tag_normalizer": true,
"phpdoc_no_access": true,
"phpdoc_no_package": true,
"phpdoc_no_useless_inheritdoc": true,
"phpdoc_return_self_reference": true,
"phpdoc_scalar": true,
"phpdoc_single_line_var_spacing": true,
"phpdoc_summary": true,
"phpdoc_trim": true,
"phpdoc_types": true,
"phpdoc_var_without_name": true,
"return_type_declaration": {
"space_before": "none"
},
"short_scalar_cast": true,
"single_blank_line_at_eof": true,
"single_class_element_per_statement": true,
"single_line_after_imports": true,
"single_line_comment_style": true,
"single_quote": true,
"space_after_semicolon": true,
"standardize_not_equals": true,
"switch_case_semicolon_to_colon": true,
"switch_case_space": true,
"switch_continue_to_break": true,
"ternary_operator_spaces": true,
"trim_array_spaces": true,
"type_declaration_spaces": true,
"types_spaces": true,
"unary_operator_spaces": true,
"visibility_required": {
"elements": [
"method",
"property"
]
},
"whitespace_after_comma_in_array": true
},
"exclude": [
"tests"
"notPath": [
"tests/Foundation/fixtures/bad-syntax-strategy.php"
]
}
17 changes: 16 additions & 1 deletion src/Illuminate/Cache/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ public function setPrefix($prefix)
protected function pack($value, $connection)
{
if ($connection instanceof PhpRedisConnection) {
if ($this->shouldBeStoredWithoutSerialization($value)) {
return $value;
}

if ($connection->serialized()) {
return $connection->pack([$value])[0];
}
Expand All @@ -452,7 +456,18 @@ protected function pack($value, $connection)
*/
protected function serialize($value)
{
return is_numeric($value) && ! in_array($value, [INF, -INF]) && ! is_nan($value) ? $value : serialize($value);
return $this->shouldBeStoredWithoutSerialization($value) ? $value : serialize($value);
}

/**
* Determine if the given value should be stored as plain value.
*
* @param mixed $value
* @return bool
*/
protected function shouldBeStoredWithoutSerialization($value): bool
{
return is_numeric($value) && ! in_array($value, [INF, -INF]) && ! is_nan($value);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,10 @@ public function select($keys)
*/
public function pop($count = 1)
{
if ($count < 1) {
return new static;
}

if ($count === 1) {
return array_pop($this->items);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Console/Scheduling/ScheduleTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ public function handle(Schedule $schedule)
$description = sprintf(
'Running [%s]%s',
$command,
$event->runInBackground ? ' in background' : '',
$event->runInBackground ? ' normally in background' : '',
);

$event->runInBackground = false;

$this->components->task($description, fn () => $event->run($this->laravel));

if (! $event instanceof CallbackEvent) {
Expand Down
40 changes: 30 additions & 10 deletions src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public function orWhereMorphDoesntHaveRelation($relation, $types, $column, $oper
* Add a morph-to relationship condition to the query.
*
* @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
* @param \Illuminate\Database\Eloquent\Model|string|null $model
* @param \Illuminate\Database\Eloquent\Model|iterable<int, \Illuminate\Database\Eloquent\Model>|string|null $model
* @return $this
*/
public function whereMorphedTo($relation, $model, $boolean = 'and')
Expand All @@ -559,17 +559,27 @@ public function whereMorphedTo($relation, $model, $boolean = 'and')
return $this->where($relation->qualifyColumn($relation->getMorphType()), $model, null, $boolean);
}

return $this->where(function ($query) use ($relation, $model) {
$query->where($relation->qualifyColumn($relation->getMorphType()), $model->getMorphClass())
->where($relation->qualifyColumn($relation->getForeignKeyName()), $model->getKey());
$models = BaseCollection::wrap($model);

if ($models->isEmpty()) {
throw new InvalidArgumentException('Collection given to whereMorphedTo method may not be empty.');
}

return $this->where(function ($query) use ($relation, $models) {
$models->groupBy(fn ($model) => $model->getMorphClass())->each(function ($models) use ($query, $relation) {
$query->orWhere(function ($query) use ($relation, $models) {
$query->where($relation->qualifyColumn($relation->getMorphType()), $models->first()->getMorphClass())
->whereIn($relation->qualifyColumn($relation->getForeignKeyName()), $models->map->getKey());
});
});
}, null, null, $boolean);
}

/**
* Add a not morph-to relationship condition to the query.
*
* @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
* @param \Illuminate\Database\Eloquent\Model|string $model
* @param \Illuminate\Database\Eloquent\Model|iterable<int, \Illuminate\Database\Eloquent\Model>|string $model
* @return $this
*/
public function whereNotMorphedTo($relation, $model, $boolean = 'and')
Expand All @@ -588,17 +598,27 @@ public function whereNotMorphedTo($relation, $model, $boolean = 'and')
return $this->whereNot($relation->qualifyColumn($relation->getMorphType()), '<=>', $model, $boolean);
}

return $this->whereNot(function ($query) use ($relation, $model) {
$query->where($relation->qualifyColumn($relation->getMorphType()), '<=>', $model->getMorphClass())
->where($relation->qualifyColumn($relation->getForeignKeyName()), '<=>', $model->getKey());
$models = BaseCollection::wrap($model);

if ($models->isEmpty()) {
throw new InvalidArgumentException('Collection given to whereNotMorphedTo method may not be empty.');
}

return $this->whereNot(function ($query) use ($relation, $models) {
$models->groupBy(fn ($model) => $model->getMorphClass())->each(function ($models) use ($query, $relation) {
$query->orWhere(function ($query) use ($relation, $models) {
$query->where($relation->qualifyColumn($relation->getMorphType()), '<=>', $models->first()->getMorphClass())
->whereNotIn($relation->qualifyColumn($relation->getForeignKeyName()), $models->map->getKey());
});
});
}, null, null, $boolean);
}

/**
* Add a morph-to relationship condition to the query with an "or where" clause.
*
* @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
* @param \Illuminate\Database\Eloquent\Model|string|null $model
* @param \Illuminate\Database\Eloquent\Model|iterable<int, \Illuminate\Database\Eloquent\Model>|string|null $model
* @return $this
*/
public function orWhereMorphedTo($relation, $model)
Expand All @@ -610,7 +630,7 @@ public function orWhereMorphedTo($relation, $model)
* Add a not morph-to relationship condition to the query with an "or where" clause.
*
* @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
* @param \Illuminate\Database\Eloquent\Model|string $model
* @param \Illuminate\Database\Eloquent\Model|iterable<int, \Illuminate\Database\Eloquent\Model>|string $model
* @return $this
*/
public function orWhereNotMorphedTo($relation, $model)
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Filesystem/FilesystemManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ protected function createFlysystem(FlysystemAdapter $adapter, array $config)
$adapter = new PathPrefixedAdapter($adapter, $config['prefix']);
}

if (str_contains($config['endpoint'] ?? '', 'r2.cloudflarestorage.com')) {
$config['retain_visibility'] = false;
}

return new Flysystem($adapter, Arr::only($config, [
'directory_visibility',
'disable_asserts',
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Foundation/Concerns/ResolvesDumpSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ trait ResolvesDumpSource
*/
protected $editorHrefs = [
'atom' => 'atom://core/open/file?filename={file}&line={line}',
'cursor' => 'cursor://file/{file}:{line}',
'emacs' => 'emacs://open?url=file://{file}&line={line}',
'idea' => 'idea://open?file={file}&line={line}',
'macvim' => 'mvim://open/?url=file://{file}&line={line}',
Expand Down
62 changes: 62 additions & 0 deletions src/Illuminate/Http/Client/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,68 @@ public function throwIfServerError()
return $this->serverError() ? $this->throw() : $this;
}

/**
* Dump the content from the response.
*
* @param string|null $key
* @return $this
*/
public function dump($key = null)
{
$content = $this->body();

$json = json_decode($content);

if (json_last_error() === JSON_ERROR_NONE) {
$content = $json;
}

if (! is_null($key)) {
dump(data_get($content, $key));
} else {
dump($content);
}

return $this;
}

/**
* Dump the content from the response and end the script.
*
* @param string|null $key
* @return never
*/
public function dd($key = null)
{
$this->dump($key);

exit(1);
}

/**
* Dump the headers from the response.
*
* @return $this
*/
public function dumpHeaders()
{
dump($this->headers());

return $this;
}

/**
* Dump the headers from the response and end the script.
*
* @return never
*/
public function ddHeaders()
{
$this->dumpHeaders();

exit(1);
}

/**
* Determine if the given offset exists.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"illuminate/conditionable": "^12.0",
"illuminate/contracts": "^12.0",
"illuminate/macroable": "^12.0",
"nesbot/carbon": "^3.4",
"nesbot/carbon": "^3.8.4",
"voku/portable-ascii": "^2.0.2"
},
"conflict": {
Expand Down
Loading

0 comments on commit f107d93

Please sign in to comment.