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 Jan 17, 2024
2 parents dc8b91c + 158767f commit f630b39
Show file tree
Hide file tree
Showing 29 changed files with 393 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ permissions:
pull-requests: write

jobs:
uneditable:
pull-requests:
uses: laravel/.github/.github/workflows/pull-requests.yml@main
12 changes: 6 additions & 6 deletions src/Illuminate/Auth/Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,25 +320,25 @@ public function after(callable $callback)
/**
* Determine if all of the given abilities should be granted for the current user.
*
* @param iterable|string $abilities
* @param iterable|string $ability
* @param array|mixed $arguments
* @return bool
*/
public function allows($abilities, $arguments = [])
public function allows($ability, $arguments = [])
{
return $this->check($abilities, $arguments);
return $this->check($ability, $arguments);
}

/**
* Determine if any of the given abilities should be denied for the current user.
*
* @param iterable|string $abilities
* @param iterable|string $ability
* @param array|mixed $arguments
* @return bool
*/
public function denies($abilities, $arguments = [])
public function denies($ability, $arguments = [])
{
return ! $this->allows($abilities, $arguments);
return ! $this->allows($ability, $arguments);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected function possibleModels()
{
$modelPath = is_dir(app_path('Models')) ? app_path('Models') : app_path();

return collect((new Finder)->files()->depth(0)->in($modelPath))
return collect(Finder::create()->files()->depth(0)->in($modelPath))
->map(fn ($file) => $file->getBasename('.php'))
->sort()
->values()
Expand All @@ -269,7 +269,7 @@ protected function possibleEvents()
return [];
}

return collect((new Finder)->files()->depth(0)->in($eventPath))
return collect(Finder::create()->files()->depth(0)->in($eventPath))
->map(fn ($file) => $file->getBasename('.php'))
->sort()
->values()
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Contracts/Auth/Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ public function after(callable $callback);
/**
* Determine if all of the given abilities should be granted for the current user.
*
* @param iterable|string $abilities
* @param iterable|string $ability
* @param array|mixed $arguments
* @return bool
*/
public function allows($abilities, $arguments = []);
public function allows($ability, $arguments = []);

/**
* Determine if any of the given abilities should be denied for the current user.
*
* @param iterable|string $abilities
* @param iterable|string $ability
* @param array|mixed $arguments
* @return bool
*/
public function denies($abilities, $arguments = []);
public function denies($ability, $arguments = []);

/**
* Determine if all of the given abilities should be granted for the current user.
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Contracts/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function get($key, array $replace = [], $locale = null);
* Get a translation according to an integer value.
*
* @param string $key
* @param \Countable|int|array $number
* @param \Countable|int|float|array $number
* @param array $replace
* @param string|null $locale
* @return string
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Console/PruneCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected function models()
throw new InvalidArgumentException('The --models and --except options cannot be combined.');
}

return collect((new Finder)->in($this->getPath())->files()->name('*.php'))
return collect(Finder::create()->in($this->getPath())->files()->name('*.php'))
->map(function ($model) {
$namespace = $this->laravel->getNamespace();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2157,7 +2157,7 @@ public function originalIsEquivalent($key)
}

return is_numeric($attribute) && is_numeric($original)
&& BigDecimal::of($attribute)->isEqualTo($original);
&& strcmp((string) $attribute, (string) $original) === 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ protected function load($paths)

$namespace = $this->app->getNamespace();

foreach ((new Finder)->in($paths)->files() as $file) {
foreach (Finder::create()->in($paths)->files() as $file) {
$command = $this->commandClassFromFile($file, $namespace);

if (is_subclass_of($command, Command::class) &&
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Foundation/Console/stubs/job.queued.stub
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace {{ namespace }};

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Events/DiscoverEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DiscoverEvents
public static function within($listenerPath, $basePath)
{
$listeners = collect(static::getListenerEvents(
(new Finder)->files()->in($listenerPath), $basePath
Finder::create()->files()->in($listenerPath), $basePath
));

$discoveredEvents = [];
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 @@ -929,7 +929,7 @@ function trans($key = null, $replace = [], $locale = null)
* Translates the given message based on a count.
*
* @param string $key
* @param \Countable|int|array $number
* @param \Countable|int|float|array $number
* @param array $replace
* @param string|null $locale
* @return string
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Http/Client/PendingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PendingRequest
/**
* The raw body for the request.
*
* @var string
* @var \Psr\Http\Message\StreamInterface|string
*/
protected $pendingBody;

Expand Down Expand Up @@ -260,7 +260,7 @@ public function baseUrl(string $url)
/**
* Attach a raw body to the request.
*
* @param string $content
* @param \Psr\Http\Message\StreamInterface|string $content
* @param string $contentType
* @return $this
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>

<div>
<span class="relative z-0 inline-flex shadow-sm rounded-md">
<span class="relative z-0 inline-flex rtl:flex-row-reverse shadow-sm rounded-md">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<span aria-disabled="true" aria-label="{{ __('pagination.previous') }}">
Expand Down
2 changes: 2 additions & 0 deletions src/Illuminate/Queue/Console/ClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public function handle()
$this->components->info('Cleared '.$count.' '.Str::plural('job', $count).' from the ['.$queueName.'] queue');
} else {
$this->components->error('Clearing queues is not supported on ['.(new ReflectionClass($queue))->getShortName().']');

return 1;
}

return 0;
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Queue/Console/ForgetFailedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ class ForgetFailedCommand extends Command
/**
* Execute the console command.
*
* @return void
* @return int|null
*/
public function handle()
{
if ($this->laravel['queue.failer']->forget($this->argument('id'))) {
$this->components->info('Failed job deleted successfully.');
} else {
$this->components->error('No failed job matches the given ID.');

return 1;
}
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Support/Facades/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* @method static \Illuminate\Auth\Access\Gate policy(string $class, string $policy)
* @method static \Illuminate\Auth\Access\Gate before(callable $callback)
* @method static \Illuminate\Auth\Access\Gate after(callable $callback)
* @method static bool allows(iterable|string $abilities, array|mixed $arguments = [])
* @method static bool denies(iterable|string $abilities, array|mixed $arguments = [])
* @method static bool allows(iterable|string $ability, array|mixed $arguments = [])
* @method static bool denies(iterable|string $ability, array|mixed $arguments = [])
* @method static bool check(iterable|string $abilities, array|mixed $arguments = [])
* @method static bool any(iterable|string $abilities, array|mixed $arguments = [])
* @method static bool none(iterable|string $abilities, array|mixed $arguments = [])
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 @@ -27,7 +27,7 @@
* @method static void flushMacros()
* @method static mixed macroCall(string $method, array $parameters)
* @method static \Illuminate\Http\Client\PendingRequest baseUrl(string $url)
* @method static \Illuminate\Http\Client\PendingRequest withBody(string $content, string $contentType = 'application/json')
* @method static \Illuminate\Http\Client\PendingRequest withBody(\Psr\Http\Message\StreamInterface|string $content, string $contentType = 'application/json')
* @method static \Illuminate\Http\Client\PendingRequest asJson()
* @method static \Illuminate\Http\Client\PendingRequest asForm()
* @method static \Illuminate\Http\Client\PendingRequest attach(string|array $name, string|resource $contents = '', string|null $filename = null, array $headers = [])
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Facades/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @method static bool hasForLocale(string $key, string|null $locale = null)
* @method static bool has(string $key, string|null $locale = null, bool $fallback = true)
* @method static string|array get(string $key, array $replace = [], string|null $locale = null, bool $fallback = true)
* @method static string choice(string $key, \Countable|int|array $number, array $replace = [], string|null $locale = null)
* @method static string choice(string $key, \Countable|int|float|array $number, array $replace = [], string|null $locale = null)
* @method static void addLines(array $lines, string $locale, string $namespace = '*')
* @method static void load(string $namespace, string $group, string $locale)
* @method static \Illuminate\Translation\Translator handleMissingKeysUsing(callable|null $callback)
Expand Down
23 changes: 13 additions & 10 deletions src/Illuminate/Support/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,26 @@ public static function fileSize(int|float $bytes, int $precision = 0, ?int $maxP
}

/**
* Convert the number to its human readable equivalent.
* Convert the number to its human-readable equivalent.
*
* @param int $number
* @param int|float $number
* @param int $precision
* @param int|null $maxPrecision
* @return string
* @return bool|string
*/
public static function abbreviate(int|float $number, int $precision = 0, ?int $maxPrecision = null)
{
return static::forHumans($number, $precision, $maxPrecision, abbreviate: true);
}

/**
* Convert the number to its human readable equivalent.
* Convert the number to its human-readable equivalent.
*
* @param int $number
* @param int|float $number
* @param int $precision
* @param int|null $maxPrecision
* @return string
* @param bool $abbreviate
* @return bool|string
*/
public static function forHumans(int|float $number, int $precision = 0, ?int $maxPrecision = null, bool $abbreviate = false)
{
Expand All @@ -182,13 +183,13 @@ public static function forHumans(int|float $number, int $precision = 0, ?int $ma
}

/**
* Convert the number to its human readable equivalent.
* Convert the number to its human-readable equivalent.
*
* @param int $number
* @param int|float $number
* @param int $precision
* @param int|null $maxPrecision
* @param array $units
* @return string
* @return string|false
*/
protected static function summarize(int|float $number, int $precision = 0, ?int $maxPrecision = null, array $units = [])
{
Expand Down Expand Up @@ -266,7 +267,9 @@ public static function useLocale(string $locale)
protected static function ensureIntlExtensionIsInstalled()
{
if (! extension_loaded('intl')) {
throw new RuntimeException('The "intl" PHP extension is required to use this method.');
$method = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function'];

throw new RuntimeException('The "intl" PHP extension is required to use the ['.$method.'] method.');
}
}
}
5 changes: 3 additions & 2 deletions src/Illuminate/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1281,11 +1281,12 @@ public function toString()
/**
* Get the underlying string value as an integer.
*
* @param int $base
* @return int
*/
public function toInteger()
public function toInteger($base = 10)
{
return intval($this->value);
return intval($this->value, $base);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Translation/PotentiallyTranslatedString.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function translate($replace = [], $locale = null)
/**
* Translates the string based on a count.
*
* @param \Countable|int|array $number
* @param \Countable|int|float|array $number
* @param array $replace
* @param string|null $locale
* @return $this
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function get($key, array $replace = [], $locale = null, $fallback = true)
* Get a translation according to an integer value.
*
* @param string $key
* @param \Countable|int|array $number
* @param \Countable|int|float|array $number
* @param array $replace
* @param string|null $locale
* @return string
Expand Down
21 changes: 21 additions & 0 deletions tests/Http/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use GuzzleHttp\Middleware;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7\Response as Psr7Response;
use GuzzleHttp\Psr7\Utils;
use GuzzleHttp\TransferStats;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Support\Arrayable;
Expand Down Expand Up @@ -357,6 +358,26 @@ public function testSendRequestBodyWithManyAmpersands()
$this->factory->withBody($body, 'text/plain')->send('post', 'http://foo.com/api');
}

public function testSendStreamRequestBody()
{
$string = 'Look at me, i am a stream!!';
$resource = fopen('php://temp', 'w');
fwrite($resource, $string);
rewind($resource);
$body = Utils::streamFor($resource);

$fakeRequest = function (Request $request) use ($string) {
self::assertSame($string, $request->body());
self::assertContains('text/plain', $request->header('Content-Type'));

return ['my' => 'response'];
};

$this->factory->fake($fakeRequest);

$this->factory->withBody($body, 'text/plain')->send('post', 'http://foo.com/api');
}

public function testUrlsCanBeStubbedByPath()
{
$this->factory->fake([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,33 +177,6 @@ public function testDeviableCasts()
$this->assertSame((new Decimal('220.987'))->getValue(), $model->price->getValue());
}

public function testDirtyOnCustomNumericCasts()
{
$model = new TestEloquentModelWithCustomCast;
$model->price = '123.00';
$model->save();

$this->assertFalse($model->isDirty());

$model->price = '123.00';
$this->assertFalse($model->isDirty('price'));

$model->price = '123.0';
$this->assertFalse($model->isDirty('price'));

$model->price = '123';
$this->assertFalse($model->isDirty('price'));

$model->price = '00123.00';
$this->assertFalse($model->isDirty('price'));

$model->price = '123.4000';
$this->assertTrue($model->isDirty('price'));

$model->price = '123.0004';
$this->assertTrue($model->isDirty('price'));
}

public function testSerializableCasts()
{
$model = new TestEloquentModelWithCustomCast;
Expand Down
Loading

0 comments on commit f630b39

Please sign in to comment.