Skip to content

Commit d73a545

Browse files
committed
Merge branch '10.x'
# Conflicts: # CHANGELOG.md # src/Illuminate/Foundation/Application.php
2 parents edaac12 + f48141d commit d73a545

File tree

18 files changed

+292
-22
lines changed

18 files changed

+292
-22
lines changed

src/Illuminate/Auth/Access/Gate.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,27 +318,27 @@ public function after(callable $callback)
318318
}
319319

320320
/**
321-
* Determine if the given ability should be granted for the current user.
321+
* Determine if all of the given abilities should be granted for the current user.
322322
*
323-
* @param string $ability
323+
* @param iterable|string $abilities
324324
* @param array|mixed $arguments
325325
* @return bool
326326
*/
327-
public function allows($ability, $arguments = [])
327+
public function allows($abilities, $arguments = [])
328328
{
329-
return $this->check($ability, $arguments);
329+
return $this->check($abilities, $arguments);
330330
}
331331

332332
/**
333-
* Determine if the given ability should be denied for the current user.
333+
* Determine if any of the given abilities should be denied for the current user.
334334
*
335-
* @param string $ability
335+
* @param iterable|string $abilities
336336
* @param array|mixed $arguments
337337
* @return bool
338338
*/
339-
public function denies($ability, $arguments = [])
339+
public function denies($abilities, $arguments = [])
340340
{
341-
return ! $this->allows($ability, $arguments);
341+
return ! $this->allows($abilities, $arguments);
342342
}
343343

344344
/**

src/Illuminate/Collections/Arr.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ public static function dot($array, $prepend = '')
113113

114114
foreach ($array as $key => $value) {
115115
if (is_array($value) && ! empty($value)) {
116-
$results[] = static::dot($value, $prepend.$key.'.');
116+
$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
117117
} else {
118-
$results[] = [$prepend.$key => $value];
118+
$results[$prepend.$key] = $value;
119119
}
120120
}
121121

122-
return array_merge(...$results);
122+
return $results;
123123
}
124124

125125
/**

src/Illuminate/Contracts/Auth/Access/Gate.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ public function before(callable $callback);
5757
public function after(callable $callback);
5858

5959
/**
60-
* Determine if the given ability should be granted for the current user.
60+
* Determine if all of the given abilities should be granted for the current user.
6161
*
62-
* @param string $ability
62+
* @param iterable|string $abilities
6363
* @param array|mixed $arguments
6464
* @return bool
6565
*/
66-
public function allows($ability, $arguments = []);
66+
public function allows($abilities, $arguments = []);
6767

6868
/**
69-
* Determine if the given ability should be denied for the current user.
69+
* Determine if any of the given abilities should be denied for the current user.
7070
*
71-
* @param string $ability
71+
* @param iterable|string $abilities
7272
* @param array|mixed $arguments
7373
* @return bool
7474
*/
75-
public function denies($ability, $arguments = []);
75+
public function denies($abilities, $arguments = []);
7676

7777
/**
7878
* Determine if all of the given abilities should be granted for the current user.

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,7 @@ public function originalIsEquivalent($key)
21572157
}
21582158

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

21632163
/**
@@ -2182,6 +2182,13 @@ protected function transformModelValue($key, $value)
21822182
// an appropriate native PHP type dependent upon the associated value
21832183
// given with the key in the pair. Dayle made this comment line up.
21842184
if ($this->hasCast($key)) {
2185+
if (static::preventsAccessingMissingAttributes() &&
2186+
! array_key_exists($key, $this->attributes) &&
2187+
($this->isEnumCastable($key) ||
2188+
in_array($this->getCastType($key), static::$primitiveCastTypes))) {
2189+
$this->throwMissingAttributeExceptionIfApplicable($key);
2190+
}
2191+
21852192
return $this->castAttribute($key, $value);
21862193
}
21872194

src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function compileTables($database)
8888
return sprintf(
8989
'select table_name as `name`, (data_length + index_length) as `size`, '
9090
.'table_comment as `comment`, engine as `engine`, table_collation as `collation` '
91-
."from information_schema.tables where table_schema = %s and table_type = 'BASE TABLE' "
91+
."from information_schema.tables where table_schema = %s and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') "
9292
.'order by table_name',
9393
$this->quoteString($database)
9494
);

src/Illuminate/Session/Store.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ public function only(array $keys)
245245
return Arr::only($this->attributes, $keys);
246246
}
247247

248+
/**
249+
* Get all the session data except for a specified array of items.
250+
*
251+
* @param array $keys
252+
* @return array
253+
*/
254+
public function except(array $keys)
255+
{
256+
return Arr::except($this->attributes, $keys);
257+
}
258+
248259
/**
249260
* Checks if a key exists.
250261
*

src/Illuminate/Support/Facades/Gate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* @method static \Illuminate\Auth\Access\Gate policy(string $class, string $policy)
1414
* @method static \Illuminate\Auth\Access\Gate before(callable $callback)
1515
* @method static \Illuminate\Auth\Access\Gate after(callable $callback)
16-
* @method static bool allows(string $ability, array|mixed $arguments = [])
17-
* @method static bool denies(string $ability, array|mixed $arguments = [])
16+
* @method static bool allows(iterable|string $abilities, array|mixed $arguments = [])
17+
* @method static bool denies(iterable|string $abilities, array|mixed $arguments = [])
1818
* @method static bool check(iterable|string $abilities, array|mixed $arguments = [])
1919
* @method static bool any(iterable|string $abilities, array|mixed $arguments = [])
2020
* @method static bool none(iterable|string $abilities, array|mixed $arguments = [])

src/Illuminate/Support/Facades/Session.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* @method static void ageFlashData()
2222
* @method static array all()
2323
* @method static array only(array $keys)
24+
* @method static array except(array $keys)
2425
* @method static bool exists(string|array $key)
2526
* @method static bool missing(string|array $key)
2627
* @method static bool has(string|array $key)

src/Illuminate/Support/Number.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ protected static function summarize(int|float $number, int $precision = 0, ?int
208208
return trim(sprintf('%s%s', static::format($number, $precision, $maxPrecision), $units[$displayExponent] ?? ''));
209209
}
210210

211+
/**
212+
* Clamp the given number between the given minimum and maximum.
213+
*
214+
* @param int|float $number
215+
* @param int|float $min
216+
* @param int|float $max
217+
* @return int|float
218+
*/
219+
public static function clamp(int|float $number, int|float $min, int|float $max)
220+
{
221+
return min(max($number, $min), $max);
222+
}
223+
211224
/**
212225
* Execute the given callback using the given locale.
213226
*

tests/Auth/AuthAccessGateTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,47 @@ public function testAfterCallbacksDoNotOverrideEachOther()
326326
$this->assertTrue($gate->denies('deny'));
327327
}
328328

329+
public function testArrayAbilitiesInAllows()
330+
{
331+
$gate = $this->getBasicGate();
332+
333+
$gate->define('allow_1', function ($user) {
334+
return true;
335+
});
336+
$gate->define('allow_2', function ($user) {
337+
return true;
338+
});
339+
$gate->define('deny', function ($user) {
340+
return false;
341+
});
342+
343+
$this->assertTrue($gate->allows(['allow_1']));
344+
$this->assertTrue($gate->allows(['allow_1', 'allow_2']));
345+
$this->assertFalse($gate->allows(['allow_1', 'allow_2', 'deny']));
346+
$this->assertFalse($gate->allows(['deny', 'allow_1', 'allow_2']));
347+
}
348+
349+
public function testArrayAbilitiesInDenies()
350+
{
351+
$gate = $this->getBasicGate();
352+
353+
$gate->define('deny_1', function ($user) {
354+
return false;
355+
});
356+
$gate->define('deny_2', function ($user) {
357+
return false;
358+
});
359+
$gate->define('allow', function ($user) {
360+
return true;
361+
});
362+
363+
$this->assertTrue($gate->denies(['deny_1']));
364+
$this->assertTrue($gate->denies(['deny_1', 'deny_2']));
365+
$this->assertTrue($gate->denies(['deny_1', 'allow']));
366+
$this->assertTrue($gate->denies(['allow', 'deny_1']));
367+
$this->assertFalse($gate->denies(['allow']));
368+
}
369+
329370
public function testCurrentUserThatIsOnGateAlwaysInjectedIntoClosureCallbacks()
330371
{
331372
$gate = $this->getBasicGate();

0 commit comments

Comments
 (0)