Skip to content

Commit 1ee9fdb

Browse files
committed
Merge branch '10.x'
# Conflicts: # src/Illuminate/View/ComponentAttributeBag.php # tests/View/Blade/BladeEchoHandlerTest.php
2 parents 3a530f3 + ab9f7c4 commit 1ee9fdb

36 files changed

+480
-86
lines changed

src/Illuminate/Cache/DynamoDbStore.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function add($key, $value, $seconds)
285285
],
286286
'ExpressionAttributeValues' => [
287287
':now' => [
288-
'N' => (string) Carbon::now()->getTimestamp(),
288+
'N' => (string) $this->currentTime(),
289289
],
290290
],
291291
]);
@@ -326,7 +326,7 @@ public function increment($key, $value = 1)
326326
],
327327
'ExpressionAttributeValues' => [
328328
':now' => [
329-
'N' => (string) Carbon::now()->getTimestamp(),
329+
'N' => (string) $this->currentTime(),
330330
],
331331
':amount' => [
332332
'N' => (string) $value,
@@ -371,7 +371,7 @@ public function decrement($key, $value = 1)
371371
],
372372
'ExpressionAttributeValues' => [
373373
':now' => [
374-
'N' => (string) Carbon::now()->getTimestamp(),
374+
'N' => (string) $this->currentTime(),
375375
],
376376
':amount' => [
377377
'N' => (string) $value,
@@ -469,7 +469,7 @@ protected function toTimestamp($seconds)
469469
{
470470
return $seconds > 0
471471
? $this->availableAt($seconds)
472-
: Carbon::now()->getTimestamp();
472+
: $this->currentTime();
473473
}
474474

475475
/**

src/Illuminate/Cache/FileStore.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,11 @@ protected function getPayload($key)
290290
// just return null. Otherwise, we'll get the contents of the file and get
291291
// the expiration UNIX timestamps from the start of the file's contents.
292292
try {
293-
$expire = substr(
294-
$contents = $this->files->get($path, true), 0, 10
295-
);
293+
if (is_null($contents = $this->files->get($path, true))) {
294+
return $this->emptyPayload();
295+
}
296+
297+
$expire = substr($contents, 0, 10);
296298
} catch (Exception) {
297299
return $this->emptyPayload();
298300
}

src/Illuminate/Collections/Arr.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,7 @@ public static function keyBy($array, $keyBy)
476476
*/
477477
public static function prependKeysWith($array, $prependWith)
478478
{
479-
return Collection::make($array)->mapWithKeys(function ($item, $key) use ($prependWith) {
480-
return [$prependWith.$key => $item];
481-
})->all();
479+
return static::mapWithKeys($array, fn ($item, $key) => [$prependWith.$key => $item]);
482480
}
483481

484482
/**

src/Illuminate/Database/DatabaseManager.php

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,39 @@ public function connection($name = null)
101101
$this->makeConnection($database), $type
102102
);
103103

104-
if ($this->app->bound('events')) {
105-
$this->app['events']->dispatch(
106-
new ConnectionEstablished($this->connections[$name])
107-
);
108-
}
104+
$this->dispatchConnectionEstablishedEvent($this->connections[$name]);
109105
}
110106

111107
return $this->connections[$name];
112108
}
113109

110+
/**
111+
* Get a database connection instance from the given configuration.
112+
*
113+
* @param string $name
114+
* @param array $config
115+
* @param bool $force
116+
* @return \Illuminate\Database\ConnectionInterface
117+
*/
118+
public function connectUsing(string $name, array $config, bool $force = false)
119+
{
120+
if ($force) {
121+
$this->purge($name);
122+
}
123+
124+
if (isset($this->connections[$name])) {
125+
throw new RuntimeException("Cannot establish connection [$name] because another connection with that name already exists.");
126+
}
127+
128+
$connection = $this->configure(
129+
$this->factory->make($config, $name), null
130+
);
131+
132+
$this->dispatchConnectionEstablishedEvent($connection);
133+
134+
return tap($connection, fn ($connection) => $this->connections[$name] = $connection);
135+
}
136+
114137
/**
115138
* Parse the connection into an array of the name and read / write type.
116139
*
@@ -209,6 +232,23 @@ protected function configure(Connection $connection, $type)
209232
return $connection;
210233
}
211234

235+
/**
236+
* Dispatch the ConnectionEstablished event if the event dispatcher is available.
237+
*
238+
* @param \Illuminate\Database\Connection $connection
239+
* @return void
240+
*/
241+
protected function dispatchConnectionEstablishedEvent(Connection $connection)
242+
{
243+
if (! $this->app->bound('events')) {
244+
return;
245+
}
246+
247+
$this->app['events']->dispatch(
248+
new ConnectionEstablished($connection)
249+
);
250+
}
251+
212252
/**
213253
* Prepare the read / write mode for database connection instance.
214254
*

src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function get($model, $key, $value, $attributes)
2525

2626
$data = Json::decode($attributes[$key]);
2727

28-
return is_array($data) ? new ArrayObject($data) : null;
28+
return is_array($data) ? new ArrayObject($data, ArrayObject::ARRAY_AS_PROPS) : null;
2929
}
3030

3131
public function set($model, $key, $value, $attributes)

src/Illuminate/Database/Query/Builder.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Builder implements BuilderContract
8383
/**
8484
* The columns that should be returned.
8585
*
86-
* @var array
86+
* @var array|null
8787
*/
8888
public $columns;
8989

@@ -1380,7 +1380,7 @@ public function orWhereNotNull($column)
13801380
* Add a "where date" statement to the query.
13811381
*
13821382
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1383-
* @param string $operator
1383+
* @param \DateTimeInterface|string|null $operator
13841384
* @param \DateTimeInterface|string|null $value
13851385
* @param string $boolean
13861386
* @return $this
@@ -1404,7 +1404,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
14041404
* Add an "or where date" statement to the query.
14051405
*
14061406
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1407-
* @param string $operator
1407+
* @param \DateTimeInterface|string|null $operator
14081408
* @param \DateTimeInterface|string|null $value
14091409
* @return $this
14101410
*/
@@ -1421,7 +1421,7 @@ public function orWhereDate($column, $operator, $value = null)
14211421
* Add a "where time" statement to the query.
14221422
*
14231423
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1424-
* @param string $operator
1424+
* @param \DateTimeInterface|string|null $operator
14251425
* @param \DateTimeInterface|string|null $value
14261426
* @param string $boolean
14271427
* @return $this
@@ -1445,7 +1445,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and')
14451445
* Add an "or where time" statement to the query.
14461446
*
14471447
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1448-
* @param string $operator
1448+
* @param \DateTimeInterface|string|null $operator
14491449
* @param \DateTimeInterface|string|null $value
14501450
* @return $this
14511451
*/
@@ -1462,7 +1462,7 @@ public function orWhereTime($column, $operator, $value = null)
14621462
* Add a "where day" statement to the query.
14631463
*
14641464
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1465-
* @param string $operator
1465+
* @param \DateTimeInterface|string|int|null $operator
14661466
* @param \DateTimeInterface|string|int|null $value
14671467
* @param string $boolean
14681468
* @return $this
@@ -1490,7 +1490,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and')
14901490
* Add an "or where day" statement to the query.
14911491
*
14921492
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1493-
* @param string $operator
1493+
* @param \DateTimeInterface|string|int|null $operator
14941494
* @param \DateTimeInterface|string|int|null $value
14951495
* @return $this
14961496
*/
@@ -1507,7 +1507,7 @@ public function orWhereDay($column, $operator, $value = null)
15071507
* Add a "where month" statement to the query.
15081508
*
15091509
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1510-
* @param string $operator
1510+
* @param \DateTimeInterface|string|int|null $operator
15111511
* @param \DateTimeInterface|string|int|null $value
15121512
* @param string $boolean
15131513
* @return $this
@@ -1535,7 +1535,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and')
15351535
* Add an "or where month" statement to the query.
15361536
*
15371537
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1538-
* @param string $operator
1538+
* @param \DateTimeInterface|string|int|null $operator
15391539
* @param \DateTimeInterface|string|int|null $value
15401540
* @return $this
15411541
*/
@@ -1552,7 +1552,7 @@ public function orWhereMonth($column, $operator, $value = null)
15521552
* Add a "where year" statement to the query.
15531553
*
15541554
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1555-
* @param string $operator
1555+
* @param \DateTimeInterface|string|int|null $operator
15561556
* @param \DateTimeInterface|string|int|null $value
15571557
* @param string $boolean
15581558
* @return $this
@@ -1576,7 +1576,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and')
15761576
* Add an "or where year" statement to the query.
15771577
*
15781578
* @param \Illuminate\Contracts\Database\Query\Expression|string $column
1579-
* @param string $operator
1579+
* @param \DateTimeInterface|string|int|null $operator
15801580
* @param \DateTimeInterface|string|int|null $value
15811581
* @return $this
15821582
*/

src/Illuminate/Database/Schema/Builder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
use Closure;
66
use Illuminate\Container\Container;
77
use Illuminate\Database\Connection;
8+
use Illuminate\Support\Traits\Macroable;
89
use InvalidArgumentException;
910
use LogicException;
1011

1112
class Builder
1213
{
14+
use Macroable;
15+
1316
/**
1417
* The database connection instance.
1518
*

src/Illuminate/Foundation/Console/AboutCommand.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,16 @@ protected function toSearchKeyword(string $value)
302302
{
303303
return (string) Str::of($value)->lower()->snake();
304304
}
305+
306+
/**
307+
* Flush the registered about data.
308+
*
309+
* @return void
310+
*/
311+
public static function flushState()
312+
{
313+
static::$data = [];
314+
315+
static::$customDataResolvers = [];
316+
}
305317
}

src/Illuminate/Foundation/Exceptions/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ public function renderForConsole($output, Throwable $e)
933933
$message .= '. Did you mean one of these?';
934934

935935
with(new Error($output))->render($message);
936-
with(new BulletList($output))->render($e->getAlternatives());
936+
with(new BulletList($output))->render($alternatives);
937937

938938
$output->writeln('');
939939
} else {

src/Illuminate/Foundation/Testing/TestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Database\Eloquent\Model;
99
use Illuminate\Foundation\Application;
1010
use Illuminate\Foundation\Bootstrap\HandleExceptions;
11+
use Illuminate\Foundation\Console\AboutCommand;
1112
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
1213
use Illuminate\Foundation\Http\Middleware\TrimStrings;
1314
use Illuminate\Queue\Queue;
@@ -239,6 +240,7 @@ protected function tearDown(): void
239240
$this->originalExceptionHandler = null;
240241
$this->originalDeprecationHandler = null;
241242

243+
AboutCommand::flushState();
242244
Artisan::forgetBootstrappers();
243245
Component::flushCache();
244246
Component::forgetComponentsResolver();

0 commit comments

Comments
 (0)