Skip to content

Commit

Permalink
Merge branch '10.x'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Dec 21, 2023
2 parents 4acf1df + c38ff56 commit e5b60d9
Show file tree
Hide file tree
Showing 45 changed files with 545 additions and 52 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@
"psr/simple-cache-implementation": "1.0|2.0|3.0"
},
"conflict": {
"carbonphp/carbon-doctrine-types": "<3.0.0|>=4.0",
"doctrine/dbal": "<4.0.0|>=5.0",
"tightenco/collect": "<5.5.33"
},
"autoload": {
"files": [
"src/Illuminate/Collections/helpers.php",
"src/Illuminate/Events/functions.php",
"src/Illuminate/Filesystem/functions.php",
"src/Illuminate/Foundation/helpers.php",
"src/Illuminate/Support/helpers.php"
],
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Bus/DynamoBatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function get($limit = 50, $before = null)
':id' => array_filter(['S' => $before]),
]),
'Limit' => $limit,
'ScanIndexForward' => false,
]);

return array_map(
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Cache/ArrayLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public function release()
*/
protected function getCurrentOwner()
{
if (! $this->exists()) {
return null;
}

return $this->store->locks[$this->name]['owner'];
}

Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Collections/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ public static function divide($array)
*/
public static function dot($array, $prepend = '')
{
$results = [];
$results = [[]];

foreach ($array as $key => $value) {
if (is_array($value) && ! empty($value)) {
$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
$results[] = static::dot($value, $prepend.$key.'.');
} else {
$results[$prepend.$key] = $value;
$results[] = [$prepend.$key => $value];
}
}

return $results;
return array_merge(...$results);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Console/MigrationGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Illuminate\Filesystem\Filesystem;

use function Illuminate\Filesystem\join_paths;

abstract class MigrationGeneratorCommand extends Command
{
/**
Expand Down Expand Up @@ -102,7 +104,7 @@ protected function replaceMigrationPlaceholders($path, $table)
protected function migrationExists($table)
{
return count($this->files->glob(
$this->laravel->joinPaths($this->laravel->databasePath('migrations'), '*_*_*_*_create_'.$table.'_table.php')
join_paths($this->laravel->databasePath('migrations'), '*_*_*_*_create_'.$table.'_table.php')
)) !== 0;
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/ManagesFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public function quarterly()
* Schedule the event to run quarterly on a given day and time.
*
* @param int $dayOfQuarter
* @param int $time
* @param string $time
* @return $this
*/
public function quarterlyOn($dayOfQuarter = 1, $time = '0:0')
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Console/TableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ protected function displayForCli(array $data)
$columns->each(function ($column) {
$this->components->twoColumnDetail(
$column['column'].' <fg=gray>'.$column['attributes']->implode(', ').'</>',
($column['default'] ? '<fg=gray>'.$column['default'].'</> ' : '').''.$column['type'].''
(! is_null($column['default']) ? '<fg=gray>'.$column['default'].'</> ' : '').''.$column['type'].''
);
});

Expand Down
25 changes: 25 additions & 0 deletions src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,31 @@ protected function compileJsonLength($column, $operator, $value)
return 'json_array_length('.$field.$path.') '.$operator.' '.$value;
}

/**
* Compile a "JSON contains" statement into SQL.
*
* @param string $column
* @param mixed $value
* @return string
*/
protected function compileJsonContains($column, $value)
{
[$field, $path] = $this->wrapJsonFieldAndPath($column);

return 'exists (select 1 from json_each('.$field.$path.') where '.$this->wrap('json_each.value').' is '.$value.')';
}

/**
* Prepare the binding for a "JSON contains" statement.
*
* @param mixed $binding
* @return mixed
*/
public function prepareBindingForJsonContains($binding)
{
return $binding;
}

/**
* Compile a "JSON contains key" statement into SQL.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function processColumns($results)
$autoincrement = $result->default !== null && str_starts_with($result->default, 'nextval(');

return [
'name' => str_starts_with($result->name, '"') ? str_replace('"', '', $result->name) : $result->name,
'name' => $result->name,
'type_name' => $result->type_name,
'type' => $result->type,
'collation' => $result->collation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function processColumns($results)

return [
'name' => $result->name,
'type_name' => strtok($type, '('),
'type_name' => strtok($type, '(') ?: '',
'type' => $type,
'collation' => null,
'nullable' => (bool) $result->nullable,
Expand Down
26 changes: 26 additions & 0 deletions src/Illuminate/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ public function toSql(Connection $connection, Grammar $grammar)
$this->ensureCommandsAreValid($connection);

foreach ($this->commands as $command) {
if ($command->shouldBeSkipped) {
continue;
}

$method = 'compile'.ucfirst($command->name);

if (method_exists($grammar, $method) || $grammar::hasMacro($method)) {
Expand Down Expand Up @@ -309,6 +313,28 @@ public function innoDb()
$this->engine('InnoDB');
}

/**
* Specify the character set that should be used for the table.
*
* @param string $charset
* @return void
*/
public function charset($charset)
{
$this->charset = $charset;
}

/**
* Specify the collation that should be used for the table.
*
* @param string $collation
* @return void
*/
public function collation($collation)
{
$this->collation = $collation;
}

/**
* Indicate that the table needs to be temporary.
*
Expand Down
16 changes: 14 additions & 2 deletions src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function compileColumns($database, $table)
return sprintf(
'select column_name as `name`, data_type as `type_name`, column_type as `type`, '
.'collation_name as `collation`, is_nullable as `nullable`, '
.'column_default as `default`, column_comment AS `comment`, extra as `extra` '
.'column_default as `default`, column_comment as `comment`, extra as `extra` '
.'from information_schema.columns where table_schema = %s and table_name = %s '
.'order by ordinal_position asc',
$this->quoteString($database),
Expand Down Expand Up @@ -248,10 +248,22 @@ public function compileCreate(Blueprint $blueprint, Fluent $command, Connection
*/
protected function compileCreateTable($blueprint, $command, $connection)
{
$tableStructure = $this->getColumns($blueprint);

if ($primaryKey = $this->getCommandByName($blueprint, 'primary')) {
$tableStructure[] = sprintf(
'primary key %s(%s)',
$primaryKey->algorithm ? 'using '.$primaryKey->algorithm : '',
$this->columnize($primaryKey->columns)
);

$primaryKey->shouldBeSkipped = true;
}

return sprintf('%s table %s (%s)',
$blueprint->temporary ? 'create temporary' : 'create',
$this->wrapTable($blueprint),
implode(', ', $this->getColumns($blueprint))
implode(', ', $tableStructure)
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ public function compileColumnListing()
public function compileColumns($schema, $table)
{
return sprintf(
'select quote_ident(a.attname) as name, t.typname as type_name, format_type(a.atttypid, a.atttypmod) as type, '
'select a.attname as name, t.typname as type_name, format_type(a.atttypid, a.atttypmod) as type, '
.'(select tc.collcollate from pg_catalog.pg_collation tc where tc.oid = a.attcollation) as collation, '
.'not a.attnotnull as nullable, '
.'(select pg_get_expr(adbin, adrelid) from pg_attrdef where c.oid = pg_attrdef.adrelid and pg_attrdef.adnum = a.attnum) as default, '
.'(select pg_description.description from pg_description where pg_description.objoid = c.oid and a.attnum = pg_description.objsubid) as comment '
.'col_description(c.oid, a.attnum) as comment '
.'from pg_attribute a, pg_class c, pg_type t, pg_namespace n '
.'where c.relname = %s and n.nspname = %s and a.attnum > 0 and a.attrelid = c.oid and a.atttypid = t.oid and n.oid = c.relnamespace '
.'order by a.attnum',
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function compileColumnListing($table)
public function compileColumns($table)
{
return sprintf(
"select name, type, not 'notnull' as 'nullable', dflt_value as 'default', pk as 'primary' "
'select name, type, not "notnull" as "nullable", dflt_value as "default", pk as "primary" '
.'from pragma_table_info(%s) order by cid asc',
$this->wrap(str_replace('.', '__', $table))
);
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public function compileColumns($table)
.'join sys.schemas as scm on obj.schema_id = scm.schema_id '
.'left join sys.default_constraints def on col.default_object_id = def.object_id and col.object_id = def.parent_object_id '
."left join sys.extended_properties as prop on obj.object_id = prop.major_id and col.column_id = prop.minor_id and prop.name = 'MS_Description' "
."where obj.type = 'U' and obj.name = %s and scm.name = SCHEMA_NAME()",
."where obj.type in ('U', 'V') and obj.name = %s and scm.name = SCHEMA_NAME() "
.'order by col.column_id',
$this->quoteString($table),
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Database/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"dev-master": "11.x-dev"
}
},
"conflict": {
"carbonphp/carbon-doctrine-types": "<3.0.0|>=4.0",
"doctrine/dbal": "<4.0.0|>=5.0"
},
"suggest": {
"ext-filter": "Required to use the Postgres database driver.",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^4.0).",
Expand Down
5 changes: 4 additions & 1 deletion src/Illuminate/Filesystem/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
"autoload": {
"psr-4": {
"Illuminate\\Filesystem\\": ""
}
},
"files": [
"functions.php"
]
},
"extra": {
"branch-alias": {
Expand Down
25 changes: 25 additions & 0 deletions src/Illuminate/Filesystem/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Illuminate\Filesystem;

if (! function_exists('Illuminate\Filesystem\join_paths')) {
/**
* Join the given paths together.
*
* @param string|null $basePath
* @param string ...$paths
* @return string
*/
function join_paths($basePath, string ...$paths)
{
foreach ($paths as $index => $path) {
if (empty($path)) {
unset($paths[$index]);
} else {
$paths[$index] = DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR);
}
}

return $basePath.implode('', $paths);
}
}
4 changes: 3 additions & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;

use function Illuminate\Filesystem\join_paths;

class Application extends Container implements ApplicationContract, CachesConfiguration, CachesRoutes, HttpKernelInterface
{
use Macroable;
Expand Down Expand Up @@ -624,7 +626,7 @@ public function viewPath($path = '')
*/
public function joinPaths($basePath, $path = '')
{
return $basePath.($path != '' ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : '');
return join_paths($basePath, $path);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Illuminate/Foundation/Console/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ protected function displayJson($data)
*/
protected function gatherApplicationInformation()
{
self::$data = [];

$formatEnabledStatus = fn ($value) => $value ? '<fg=yellow;options=bold>ENABLED</>' : 'OFF';
$formatCachedStatus = fn ($value) => $value ? '<fg=green;options=bold>CACHED</>' : '<fg=yellow;options=bold>NOT CACHED</>';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ public function registerConsoleSchedule()
*/
public function registerDumper()
{
AbstractCloner::$defaultCasters[ConnectionInterface::class] = [StubCaster::class, 'cutInternals'];
AbstractCloner::$defaultCasters[Container::class] = [StubCaster::class, 'cutInternals'];
AbstractCloner::$defaultCasters[Dispatcher::class] = [StubCaster::class, 'cutInternals'];
AbstractCloner::$defaultCasters[Factory::class] = [StubCaster::class, 'cutInternals'];
AbstractCloner::$defaultCasters[Grammar::class] = [StubCaster::class, 'cutInternals'];
AbstractCloner::$defaultCasters[ConnectionInterface::class] ??= [StubCaster::class, 'cutInternals'];
AbstractCloner::$defaultCasters[Container::class] ??= [StubCaster::class, 'cutInternals'];
AbstractCloner::$defaultCasters[Dispatcher::class] ??= [StubCaster::class, 'cutInternals'];
AbstractCloner::$defaultCasters[Factory::class] ??= [StubCaster::class, 'cutInternals'];
AbstractCloner::$defaultCasters[Grammar::class] ??= [StubCaster::class, 'cutInternals'];

$basePath = $this->app->basePath();

Expand Down
13 changes: 12 additions & 1 deletion src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public function call($method, $uri, $parameters = [], $cookies = [], $files = []
);

$response = $kernel->handle(
$request = Request::createFromBase($symfonyRequest)
$request = $this->createTestRequest($symfonyRequest)
);

$kernel->terminate($request, $response);
Expand Down Expand Up @@ -710,6 +710,17 @@ protected function followRedirects($response)
return $response;
}

/**
* Create the request instance used for testing from the given Symfony request.
*
* @param \Symfony\Component\HttpFoundation\Request $symfonyRequest
* @return \Illuminate\Http\Request
*/
protected function createTestRequest($symfonyRequest)
{
return Request::createFromBase($symfonyRequest);
}

/**
* Create the test response instance from the given response.
*
Expand Down
15 changes: 15 additions & 0 deletions src/Illuminate/Notifications/Messages/MailMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ public function view($view, array $data = [])
return $this;
}

/**
* Set the plain text view for the mail message.
*
* @param string $textView
* @param array $data
* @return $this
*/
public function text($textView, array $data = [])
{
return $this->view([
'html' => is_array($this->view) ? ($this->view['html'] ?? null) : $this->view,
'text' => $textView,
], $data);
}

/**
* Set the Markdown template for the notification.
*
Expand Down
Loading

0 comments on commit e5b60d9

Please sign in to comment.