Skip to content

Commit

Permalink
Merge branch '8.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Feb 15, 2021
2 parents 8a106ef + 4042985 commit 2eb476b
Show file tree
Hide file tree
Showing 90 changed files with 1,066 additions and 102 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ jobs:
tools: composer:v2
coverage: none

- name: Setup problem matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Set Minimum Guzzle Version
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require guzzlehttp/guzzle:^7.2 --no-interaction --no-update
if: matrix.php >= 8

- name: Install dependencies
uses: nick-invision/retry@v1
Expand Down Expand Up @@ -92,8 +97,13 @@ jobs:
tools: composer:v2
coverage: none

- name: Setup problem matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Set Minimum Guzzle Version
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require guzzlehttp/guzzle:^7.2 --no-interaction --no-update
if: matrix.php >= 8

- name: Install dependencies
uses: nick-invision/retry@v1
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/GuardHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait GuardHelpers
protected $provider;

/**
* Determine if current user is authenticated. If not, throw an exception.
* Determine if the current user is authenticated. If not, throw an exception.
*
* @return \Illuminate\Contracts\Auth\Authenticatable
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function broadcast(array $channels, $event, array $payload = [])
}

/**
* Return true if channel is protected by authentication.
* Return true if the channel is protected by authentication.
*
* @param string $channel
* @return bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
trait UsePusherChannelConventions
{
/**
* Return true if channel is protected by authentication.
* Return true if the channel is protected by authentication.
*
* @param string $channel
* @return bool
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Event
public $expiresAt = 1440;

/**
* Indicates if the command should run in background.
* Indicates if the command should run in the background.
*
* @var bool
*/
Expand Down Expand Up @@ -587,7 +587,7 @@ protected function pingCallback($url)
}

/**
* State that the command should run in background.
* State that the command should run in the background.
*
* @return $this
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,14 @@ protected function resolveClass(ReflectionParameter $parameter)
// the value of the dependency, similarly to how we do this with scalars.
catch (BindingResolutionException $e) {
if ($parameter->isDefaultValueAvailable()) {
array_pop($this->with);

return $parameter->getDefaultValue();
}

if ($parameter->isVariadic()) {
array_pop($this->with);

return [];
}

Expand Down
14 changes: 14 additions & 0 deletions src/Illuminate/Container/ContextualBindingBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,18 @@ public function giveTagged($tag)
return is_array($taggedServices) ? $taggedServices : iterator_to_array($taggedServices);
});
}

/**
* Specify the configuration item to bind as a primitive.
*
* @param string $key
* @param ?string $default
* @return void
*/
public function giveConfig($key, $default = null)
{
$this->give(function ($container) use ($key, $default) {
return $container->get('config')->get($key, $default);
});
}
}
21 changes: 21 additions & 0 deletions src/Illuminate/Database/Concerns/BuildsQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\RecordsNotFoundException;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;

trait BuildsQueries
{
Expand Down Expand Up @@ -50,6 +51,26 @@ public function chunk($count, callable $callback)
return true;
}

/**
* Run a map over each item while chunking.
*
* @param callable $callback
* @param int $count
* @return \Illuminate\Support\Collection
*/
public function chunkMap(callable $callback, $count = 1000)
{
$collection = Collection::make();

$this->chunk($count, function ($items) use ($collection, $callback) {
$items->each(function ($item) use ($collection, $callback) {
$collection->push($callback($item));
});
});

return $collection;
}

/**
* Execute a callback over each item while chunking.
*
Expand Down
40 changes: 40 additions & 0 deletions src/Illuminate/Database/Eloquent/Casts/ArrayObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Illuminate\Database\Eloquent\Casts;

use ArrayObject as BaseArrayObject;
use Illuminate\Contracts\Support\Arrayable;
use JsonSerializable;

class ArrayObject extends BaseArrayObject implements Arrayable, JsonSerializable
{
/**
* Get a collection containing the underlying array.
*
* @return \Illuminate\Support\Collection
*/
public function collect()
{
return collect($this->getArrayCopy());
}

/**
* Get the instance as an array.
*
* @return array
*/
public function toArray()
{
return $this->getArrayCopy();
}

/**
* Get the array that should be JSON serialized.
*
* @return array
*/
public function jsonSerialize()
{
return $this->getArrayCopy();
}
}
35 changes: 35 additions & 0 deletions src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Illuminate\Database\Eloquent\Casts;

use Illuminate\Contracts\Database\Eloquent\Castable;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class AsArrayObject implements Castable
{
/**
* Get the caster class to use when casting from / to this cast target.
*
* @param array $arguments
* @return object|string
*/
public static function castUsing(array $arguments)
{
return new class implements CastsAttributes {
public function get($model, $key, $value, $attributes)
{
return new ArrayObject(json_decode($attributes[$key], true));
}

public function set($model, $key, $value, $attributes)
{
return [$key => json_encode($value)];
}

public function serialize($model, string $key, $value, array $attributes)
{
return $value->getArrayCopy();
}
};
}
}
31 changes: 31 additions & 0 deletions src/Illuminate/Database/Eloquent/Casts/AsCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Illuminate\Database\Eloquent\Casts;

use Illuminate\Contracts\Database\Eloquent\Castable;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Support\Collection;

class AsCollection implements Castable
{
/**
* Get the caster class to use when casting from / to this cast target.
*
* @param array $arguments
* @return object|string
*/
public static function castUsing(array $arguments)
{
return new class implements CastsAttributes {
public function get($model, $key, $value, $attributes)
{
return new Collection(json_decode($attributes[$key], true));
}

public function set($model, $key, $value, $attributes)
{
return [$key => json_encode($value)];
}
};
}
}
36 changes: 36 additions & 0 deletions src/Illuminate/Database/Eloquent/Casts/AsEncryptedArrayObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Illuminate\Database\Eloquent\Casts;

use Illuminate\Contracts\Database\Eloquent\Castable;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Support\Facades\Crypt;

class AsEncryptedArrayObject implements Castable
{
/**
* Get the caster class to use when casting from / to this cast target.
*
* @param array $arguments
* @return object|string
*/
public static function castUsing(array $arguments)
{
return new class implements CastsAttributes {
public function get($model, $key, $value, $attributes)
{
return new ArrayObject(json_decode(Crypt::decryptString($attributes[$key]), true));
}

public function set($model, $key, $value, $attributes)
{
return [$key => Crypt::encryptString(json_encode($value))];
}

public function serialize($model, string $key, $value, array $attributes)
{
return $value->getArrayCopy();
}
};
}
}
32 changes: 32 additions & 0 deletions src/Illuminate/Database/Eloquent/Casts/AsEncryptedCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Illuminate\Database\Eloquent\Casts;

use Illuminate\Contracts\Database\Eloquent\Castable;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Crypt;

class AsEncryptedCollection implements Castable
{
/**
* Get the caster class to use when casting from / to this cast target.
*
* @param array $arguments
* @return object|string
*/
public static function castUsing(array $arguments)
{
return new class implements CastsAttributes {
public function get($model, $key, $value, $attributes)
{
return new Collection(json_decode(Crypt::decryptString($attributes[$key]), true));
}

public function set($model, $key, $value, $attributes)
{
return [$key => Crypt::encryptString(json_encode($value))];
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static function reguard()
}

/**
* Determine if current state is "unguarded".
* Determine if the current state is "unguarded".
*
* @return bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ protected function hasChanges($changes, $attributes = null)
}

/**
* Get the attributes that have been changed since last sync.
* Get the attributes that have been changed since the last sync.
*
* @return array
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Factories/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Closure;
use Faker\Generator;
use Illuminate\Container\Container;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Application;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\ForwardsCalls;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ public function delete()
/**
* Force a hard delete on a soft deleted model.
*
* This method protects developers from running forceDelete when trait is missing.
* This method protects developers from running forceDelete when the trait is missing.
*
* @return bool|null
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public function orderByPivot($column, $direction = 'asc')
}

/**
* Find a related model by its primary key or return new instance of the related model.
* Find a related model by its primary key or return a new instance of the related model.
*
* @param mixed $id
* @param array $columns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected function buildDictionary(Collection $results)
}

/**
* Find a model by its primary key or return new instance of the related model.
* Find a model by its primary key or return a new instance of the related model.
*
* @param mixed $id
* @param array $columns
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Relations/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected function gatherKeysByType($type, $keyType)
? array_keys($this->dictionary[$type])
: array_map(function ($modelId) {
return (string) $modelId;
}, array_keys($this->dictionary[$type]));
}, array_filter(array_keys($this->dictionary[$type])));
}

/**
Expand Down
Loading

0 comments on commit 2eb476b

Please sign in to comment.