Skip to content

Commit 8813dcd

Browse files
committed
resolve conflicts
2 parents 1212afe + 777f1fe commit 8813dcd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+880
-63
lines changed

src/Illuminate/Collections/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ public function reverse()
10781078
*
10791079
* @param TValue|(callable(TValue,TKey): bool) $value
10801080
* @param bool $strict
1081-
* @return TKey|bool
1081+
* @return TKey|false
10821082
*/
10831083
public function search($value, $strict = false)
10841084
{

src/Illuminate/Collections/LazyCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ public function reverse()
10351035
*
10361036
* @param TValue|(callable(TValue,TKey): bool) $value
10371037
* @param bool $strict
1038-
* @return TKey|bool
1038+
* @return TKey|false
10391039
*/
10401040
public function search($value, $strict = false)
10411041
{

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,25 @@ public function partition($key, $operator = null, $value = null)
464464
return new static([new static($passed), new static($failed)]);
465465
}
466466

467+
/**
468+
* Calculate the percentage of items that pass a given truth test.
469+
*
470+
* @param (callable(TValue, TKey): bool) $callback
471+
* @param int $precision
472+
* @return float|null
473+
*/
474+
public function percentage(callable $callback, int $precision = 2)
475+
{
476+
if ($this->isEmpty()) {
477+
return null;
478+
}
479+
480+
return round(
481+
$this->filter($callback)->count() / $this->count() * 100,
482+
$precision
483+
);
484+
}
485+
467486
/**
468487
* Get the sum of the given values.
469488
*

src/Illuminate/Console/Concerns/InteractsWithIO.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,14 @@ public function getOutput()
450450
{
451451
return $this->output;
452452
}
453+
454+
/**
455+
* Get the output component factory implementation.
456+
*
457+
* @return \Illuminate\Console\View\Components\Factory
458+
*/
459+
public function outputComponents()
460+
{
461+
return $this->components;
462+
}
453463
}

src/Illuminate/Console/Parser.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Parser
1616
*
1717
* @throws \InvalidArgumentException
1818
*/
19-
public static function parse($expression)
19+
public static function parse(string $expression)
2020
{
2121
$name = static::name($expression);
2222

@@ -35,7 +35,7 @@ public static function parse($expression)
3535
*
3636
* @throws \InvalidArgumentException
3737
*/
38-
protected static function name($expression)
38+
protected static function name(string $expression)
3939
{
4040
if (! preg_match('/[^\s]+/', $expression, $matches)) {
4141
throw new InvalidArgumentException('Unable to determine command name from signature.');
@@ -45,7 +45,7 @@ protected static function name($expression)
4545
}
4646

4747
/**
48-
* Extract all of the parameters from the tokens.
48+
* Extract all parameters from the tokens.
4949
*
5050
* @param array $tokens
5151
* @return array
@@ -57,7 +57,7 @@ protected static function parameters(array $tokens)
5757
$options = [];
5858

5959
foreach ($tokens as $token) {
60-
if (preg_match('/-{2,}(.*)/', $token, $matches)) {
60+
if (preg_match('/^-{2,}(.*)/', $token, $matches)) {
6161
$options[] = static::parseOption($matches[1]);
6262
} else {
6363
$arguments[] = static::parseArgument($token);
@@ -73,7 +73,7 @@ protected static function parameters(array $tokens)
7373
* @param string $token
7474
* @return \Symfony\Component\Console\Input\InputArgument
7575
*/
76-
protected static function parseArgument($token)
76+
protected static function parseArgument(string $token)
7777
{
7878
[$token, $description] = static::extractDescription($token);
7979

@@ -99,7 +99,7 @@ protected static function parseArgument($token)
9999
* @param string $token
100100
* @return \Symfony\Component\Console\Input\InputOption
101101
*/
102-
protected static function parseOption($token)
102+
protected static function parseOption(string $token)
103103
{
104104
[$token, $description] = static::extractDescription($token);
105105

@@ -132,7 +132,7 @@ protected static function parseOption($token)
132132
* @param string $token
133133
* @return array
134134
*/
135-
protected static function extractDescription($token)
135+
protected static function extractDescription(string $token)
136136
{
137137
$parts = preg_split('/\s+:\s+/', trim($token), 2);
138138

src/Illuminate/Database/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ public function escape($value, $binary = false)
10801080
*/
10811081
protected function escapeString($value)
10821082
{
1083-
return $this->getPdo()->quote($value);
1083+
return $this->getReadPdo()->quote($value);
10841084
}
10851085

10861086
/**

src/Illuminate/Database/Console/Migrations/StatusCommand.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,24 @@ public function handle()
6060

6161
$batches = $this->migrator->getRepository()->getMigrationBatches();
6262

63-
if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) {
63+
$migrations = $this->getStatusFor($ran, $batches)
64+
->when($this->option('pending'), fn ($collection) => $collection->filter(function ($migration) {
65+
return str($migration[1])->contains('Pending');
66+
}));
67+
68+
if (count($migrations) > 0) {
6469
$this->newLine();
6570

6671
$this->components->twoColumnDetail('<fg=gray>Migration name</>', '<fg=gray>Batch / Status</>');
6772

6873
$migrations
69-
->when($this->option('pending'), fn ($collection) => $collection->filter(function ($migration) {
70-
return str($migration[1])->contains('Pending');
71-
}))
7274
->each(
7375
fn ($migration) => $this->components->twoColumnDetail($migration[0], $migration[1])
7476
);
7577

7678
$this->newLine();
79+
} elseif ($this->option('pending')) {
80+
$this->components->info('No pending migrations');
7781
} else {
7882
$this->components->info('No migrations found');
7983
}

src/Illuminate/Database/Eloquent/Builder.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,10 +1139,21 @@ protected function addUpdatedAtColumn(array $values)
11391139

11401140
$column = $this->model->getUpdatedAtColumn();
11411141

1142-
$values = array_merge(
1143-
[$column => $this->model->freshTimestampString()],
1144-
$values
1145-
);
1142+
if (! array_key_exists($column, $values)) {
1143+
$timestamp = $this->model->freshTimestampString();
1144+
1145+
if (
1146+
$this->model->hasSetMutator($column)
1147+
|| $this->model->hasAttributeSetMutator($column)
1148+
|| $this->model->hasCast($column)
1149+
) {
1150+
$timestamp = $this->model->newInstance()
1151+
->forceFill([$column => $timestamp])
1152+
->getAttributes()[$column];
1153+
}
1154+
1155+
$values = array_merge([$column => $timestamp], $values);
1156+
}
11461157

11471158
$segments = preg_split('/\s+as\s+/i', $this->query->from);
11481159

src/Illuminate/Database/Eloquent/Concerns/HasUniqueIds.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function usesUniqueIds()
2222
}
2323

2424
/**
25-
* Generate a unique keys for model.
25+
* Generate unique keys for the model.
2626
*
2727
* @return void
2828
*/

src/Illuminate/Database/Eloquent/Factories/Factory.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,15 @@ public function createOneQuietly($attributes = [])
235235
/**
236236
* Create a collection of models and persist them to the database.
237237
*
238-
* @param iterable<int, array<string, mixed>> $records
238+
* @param int|iterable<int, array<string, mixed>> $records
239239
* @return \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model|TModel>
240240
*/
241-
public function createMany(iterable $records)
241+
public function createMany(int|iterable $records)
242242
{
243+
if (is_numeric($records)) {
244+
$records = array_fill(0, $records, []);
245+
}
246+
243247
return new EloquentCollection(
244248
collect($records)->map(function ($record) {
245249
return $this->state($record)->create();
@@ -250,10 +254,10 @@ public function createMany(iterable $records)
250254
/**
251255
* Create a collection of models and persist them to the database without dispatching any model events.
252256
*
253-
* @param iterable<int, array<string, mixed>> $records
257+
* @param int|iterable<int, array<string, mixed>> $records
254258
* @return \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model|TModel>
255259
*/
256-
public function createManyQuietly(iterable $records)
260+
public function createManyQuietly(int|iterable $records)
257261
{
258262
return Model::withoutEvents(function () use ($records) {
259263
return $this->createMany($records);

0 commit comments

Comments
 (0)