Skip to content

Commit

Permalink
Merge branch '8.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Apr 15, 2021
2 parents 6e13421 + d51133b commit c0a3169
Show file tree
Hide file tree
Showing 35 changed files with 162 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/Traits/EnumeratesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ public function reduce(callable $callback, $initial = null)
* Reduce an associative collection to a single value.
*
* @param callable $callback
* @param mixed $initial
* @param mixed $initial
* @return mixed
*/
public function reduceWithKeys(callable $callback, $initial = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ public function setAttribute($key, $value)
{
// First we will check for the presence of a mutator for the set operation
// which simply lets the developers tweak the attribute as it is set on
// the model, such as "json_encoding" an listing of data for storage.
// this model, such as "json_encoding" a listing of data for storage.
if ($this->hasSetMutator($key)) {
return $this->setMutatedAttributeValue($key, $value);
}
Expand Down
8 changes: 2 additions & 6 deletions src/Illuminate/Database/Eloquent/Concerns/HidesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ public function makeVisible($attributes)
*/
public function makeVisibleIf($condition, $attributes)
{
$condition = $condition instanceof Closure ? $condition($this) : $condition;

return $condition ? $this->makeVisible($attributes) : $this;
return value($condition, $this) ? $this->makeVisible($attributes) : $this;
}

/**
Expand All @@ -123,8 +121,6 @@ public function makeHidden($attributes)
*/
public function makeHiddenIf($condition, $attributes)
{
$condition = $condition instanceof Closure ? $condition($this) : $condition;

return value($condition) ? $this->makeHidden($attributes) : $this;
return value($condition, $this) ? $this->makeHidden($attributes) : $this;
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Events/MigrationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
abstract class MigrationEvent implements MigrationEventContract
{
/**
* An migration instance.
* A migration instance.
*
* @var \Illuminate\Database\Migrations\Migration
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class Grammar extends BaseGrammar
/**
* Compile a create database command.
*
* @param string $name
* @param string $name
* @param \Illuminate\Database\Connection $connection
* @return string
*/
Expand All @@ -43,7 +43,7 @@ public function compileCreateDatabase($name, $connection)
/**
* Compile a drop database if exists command.
*
* @param string $name
* @param string $name
* @return string
*/
public function compileDropDatabaseIfExists($name)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MySqlGrammar extends Grammar
/**
* Compile a create database command.
*
* @param string $name
* @param string $name
* @param \Illuminate\Database\Connection $connection
* @return string
*/
Expand All @@ -46,7 +46,7 @@ public function compileCreateDatabase($name, $connection)
/**
* Compile a drop database if exists command.
*
* @param string $name
* @param string $name
* @return string
*/
public function compileDropDatabaseIfExists($name)
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 @@ -38,7 +38,7 @@ class PostgresGrammar extends Grammar
/**
* Compile a create database command.
*
* @param string $name
* @param string $name
* @param \Illuminate\Database\Connection $connection
* @return string
*/
Expand All @@ -54,7 +54,7 @@ public function compileCreateDatabase($name, $connection)
/**
* Compile a drop database if exists command.
*
* @param string $name
* @param string $name
* @return string
*/
public function compileDropDatabaseIfExists($name)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SqlServerGrammar extends Grammar
/**
* Compile a create database command.
*
* @param string $name
* @param string $name
* @param \Illuminate\Database\Connection $connection
* @return string
*/
Expand All @@ -46,7 +46,7 @@ public function compileCreateDatabase($name, $connection)
/**
* Compile a drop database if exists command.
*
* @param string $name
* @param string $name
* @return string
*/
public function compileDropDatabaseIfExists($name)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/MySqlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MySqlBuilder extends Builder
/**
* Create a database in the schema.
*
* @param string $name
* @param string $name
* @return bool
*/
public function createDatabase($name)
Expand All @@ -20,7 +20,7 @@ public function createDatabase($name)
/**
* Drop a database from the schema if the database exists.
*
* @param string $name
* @param string $name
* @return bool
*/
public function dropDatabaseIfExists($name)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/PostgresBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PostgresBuilder extends Builder
/**
* Create a database in the schema.
*
* @param string $name
* @param string $name
* @return bool
*/
public function createDatabase($name)
Expand All @@ -20,7 +20,7 @@ public function createDatabase($name)
/**
* Drop a database from the schema if the database exists.
*
* @param string $name
* @param string $name
* @return bool
*/
public function dropDatabaseIfExists($name)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/SQLiteBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SQLiteBuilder extends Builder
/**
* Create a database in the schema.
*
* @param string $name
* @param string $name
* @return bool
*/
public function createDatabase($name)
Expand All @@ -20,7 +20,7 @@ public function createDatabase($name)
/**
* Drop a database from the schema if the database exists.
*
* @param string $name
* @param string $name
* @return bool
*/
public function dropDatabaseIfExists($name)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/SqlServerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SqlServerBuilder extends Builder
/**
* Create a database in the schema.
*
* @param string $name
* @param string $name
* @return bool
*/
public function createDatabase($name)
Expand All @@ -20,7 +20,7 @@ public function createDatabase($name)
/**
* Drop a database from the schema if the database exists.
*
* @param string $name
* @param string $name
* @return bool
*/
public function dropDatabaseIfExists($name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ trait InteractsWithAuthentication
* Set the currently logged in user for the application.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string|null $driver
* @param string|null $guard
* @return $this
*/
public function actingAs(UserContract $user, $driver = null)
public function actingAs(UserContract $user, $guard = null)
{
return $this->be($user, $driver);
return $this->be($user, $guard);
}

/**
* Set the currently logged in user for the application.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string|null $driver
* @param string|null $guard
* @return $this
*/
public function be(UserContract $user, $driver = null)
public function be(UserContract $user, $guard = null)
{
if (isset($user->wasRecentlyCreated) && $user->wasRecentlyCreated) {
$user->wasRecentlyCreated = false;
}

$this->app['auth']->guard($driver)->setUser($user);
$this->app['auth']->guard($guard)->setUser($user);

$this->app['auth']->shouldUse($driver);
$this->app['auth']->shouldUse($guard);

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Illuminate\Foundation\Testing\Concerns;

use Closure;
use Illuminate\Support\Facades\View as ViewFacade;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -57,11 +56,7 @@ protected function component(string $componentClass, $data = [])
{
$component = $this->app->make($componentClass, $data);

$view = $component->resolveView();

if ($view instanceof Closure) {
$view = $view($data);
}
$view = value($component->resolveView(), $data);

return $view instanceof View
? new TestView($view->with($component->data()))
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ function rescue(callable $callback, $rescue = null, $report = true)
report($e);
}

return $rescue instanceof Closure ? $rescue($e) : $rescue;
return value($rescue, $e);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Http/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @method \Illuminate\Http\Client\PendingRequest dump()
* @method \Illuminate\Http\Client\PendingRequest dd()
* @method \Illuminate\Http\Client\PendingRequest async()
* @method \Illuminate\Http\Client\Pool pool()
* @method \Illuminate\Http\Client\Pool pool(callable $callback)
* @method \Illuminate\Http\Client\Response delete(string $url, array $data = [])
* @method \Illuminate\Http\Client\Response get(string $url, array $query = [])
* @method \Illuminate\Http\Client\Response head(string $url, array $query = [])
Expand Down
3 changes: 3 additions & 0 deletions src/Illuminate/Http/Client/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Illuminate\Http\Client;

/**
* @mixin \Illuminate\Http\Client\Factory
*/
class Pool
{
/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Notifications/Messages/SimpleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected function formatLine($line)
return implode(' ', array_map('trim', $line));
}

return trim(implode(' ', array_map('trim', preg_split('/\\r\\n|\\r|\\n/', $line))));
return trim(implode(' ', array_map('trim', preg_split('/\\r\\n|\\r|\\n/', $line ?? ''))));
}

/**
Expand Down Expand Up @@ -239,7 +239,7 @@ public function toArray()
'outroLines' => $this->outroLines,
'actionText' => $this->actionText,
'actionUrl' => $this->actionUrl,
'displayableActionUrl' => str_replace(['mailto:', 'tel:'], '', $this->actionUrl),
'displayableActionUrl' => str_replace(['mailto:', 'tel:'], '', $this->actionUrl ?? ''),
];
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ protected function createObjectPayload($job, $queue)
: serialize(clone $job);

return array_merge($payload, [
'data' => [
'data' => array_merge($payload['data'], [
'commandName' => get_class($job),
'command' => $command,
],
]),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Facades/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @method static \Illuminate\Http\Client\PendingRequest dump()
* @method static \Illuminate\Http\Client\PendingRequest dd()
* @method static \Illuminate\Http\Client\PendingRequest async()
* @method static \Illuminate\Http\Client\Pool pool()
* @method static \Illuminate\Http\Client\Pool pool(callable $callback)
* @method static \Illuminate\Http\Client\Response delete(string $url, array $data = [])
* @method static \Illuminate\Http\Client\Response get(string $url, array $query = [])
* @method static \Illuminate\Http\Client\Response head(string $url, array $query = [])
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Support/Facades/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @method static bool hasTable(string $table)
* @method static void defaultStringLength(int $length)
* @method static void registerCustomDoctrineType(string $class, string $name, string $type)
* @method static array getColumnListing(string $table)
*
* @see \Illuminate\Database\Schema\Builder
*/
Expand Down
17 changes: 14 additions & 3 deletions src/Illuminate/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@ public static function replaceLast($search, $replace, $subject)
/**
* Remove any occurrence of the given string in the subject.
*
* @param string|array<string> $search
* @param string $subject
* @param bool $caseSensitive
* @param string|array<string> $search
* @param string $subject
* @param bool $caseSensitive
* @return string
*/
public static function remove($search, $subject, $caseSensitive = true)
Expand Down Expand Up @@ -768,6 +768,17 @@ public static function ucfirst($string)
return static::upper(static::substr($string, 0, 1)).static::substr($string, 1);
}

/**
* Get the number of words a string contains.
*
* @param string $string
* @return int
*/
public static function wordCount($string)
{
return str_word_count($string);
}

/**
* Generate a UUID (version 4).
*
Expand Down
16 changes: 13 additions & 3 deletions src/Illuminate/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public function parseCallback($default = null)
/**
* Call the given callback and return a new string.
*
* @param callable $callback
* @param callable $callback
* @return static
*/
public function pipe(callable $callback)
Expand Down Expand Up @@ -470,8 +470,8 @@ public function prepend(...$values)
/**
* Remove any occurrence of the given string in the subject.
*
* @param string|array<string> $search
* @param bool $caseSensitive
* @param string|array<string> $search
* @param bool $caseSensitive
* @return static
*/
public function remove($search, $caseSensitive = true)
Expand Down Expand Up @@ -756,6 +756,16 @@ public function words($words = 100, $end = '...')
return new static(Str::words($this->value, $words, $end));
}

/**
* Get the number of words a string contains.
*
* @return int
*/
public function wordCount()
{
return str_word_count($this->value);
}

/**
* Dump the string.
*
Expand Down

0 comments on commit c0a3169

Please sign in to comment.