language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | laravel | framework | beda5af8952ecac04aadfe9278d4b79d9135fadd.json | Apply fixes from StyleCI | tests/Support/Fixtures/UnionTypesClosure.php | @@ -3,6 +3,6 @@
use Illuminate\Tests\Support\AnotherExampleParameter;
use Illuminate\Tests\Support\ExampleParameter;
-return function (ExampleParameter | AnotherExampleParameter $a, $b) {
+return function (ExampleParameter|AnotherExampleParameter $a, $b) {
//
}; | true |
Other | laravel | framework | 5a39e9dcb5650d674d6ff6e839a4619c25c7f334.json | Apply fixes from StyleCI | src/Illuminate/Console/Scheduling/Event.php | @@ -577,7 +577,7 @@ protected function pingCallback($url)
return function (Container $container, HttpClient $http) use ($url) {
try {
$http->get($url);
- } catch (ClientExceptionInterface | TransferException $e) {
+ } catch (ClientExceptionInterface|TransferException $e) {
$container->make(ExceptionHandler::class)->report($e);
}
}; | true |
Other | laravel | framework | 5a39e9dcb5650d674d6ff6e839a4619c25c7f334.json | Apply fixes from StyleCI | src/Illuminate/Support/Traits/ForwardsCalls.php | @@ -21,7 +21,7 @@ protected function forwardCallTo($object, $method, $parameters)
{
try {
return $object->{$method}(...$parameters);
- } catch (Error | BadMethodCallException $e) {
+ } catch (Error|BadMethodCallException $e) {
$pattern = '~^Call to undefined method (?P<class>[^:]+)::(?P<method>[^\(]+)\(\)$~';
if (! preg_match($pattern, $e->getMessage(), $matches)) { | true |
Other | laravel | framework | f59268ec56b7f157303132a408ba08b257f156d2.json | Fix return type of Event::fakeFor() (#38691)
Event::fakeFor() returns the result of $callable() | src/Illuminate/Support/Facades/Event.php | @@ -50,7 +50,7 @@ public static function fake($eventsToFake = [])
*
* @param callable $callable
* @param array $eventsToFake
- * @return callable
+ * @return mixed
*/
public static function fakeFor(callable $callable, array $eventsToFake = [])
{ | false |
Other | laravel | framework | abab1c87a2e54710e44d562d2ab3ac2dc67c6631.json | Show a pretty diff for assertExactJson() (#38655) | src/Illuminate/Testing/AssertableJsonString.php | @@ -96,7 +96,10 @@ public function assertExact(array $data)
$expected = $this->reorderAssocKeys($data);
- PHPUnit::assertEquals(json_encode($expected), json_encode($actual));
+ PHPUnit::assertEquals(
+ json_encode($expected, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES),
+ json_encode($actual, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
+ );
return $this;
} | false |
Other | laravel | framework | cdb14c79e9035acfc925a1c9794aa577cb7ef452.json | Apply fixes from StyleCI | src/Illuminate/Notifications/AnonymousNotifiable.php | @@ -52,7 +52,7 @@ public function with($attributes)
$this->attributes = array_merge($this->attributes, $attributes);
return $this;
- }
+ }
/**
* Send the given notification. | false |
Other | laravel | framework | 4e46cf6290edd538cb3815901abe16eb61751a3e.json | Add PHPDoc method for `View` facade (#38636) | src/Illuminate/Support/Facades/View.php | @@ -6,6 +6,7 @@
* @method static \Illuminate\Contracts\View\Factory addNamespace(string $namespace, string|array $hints)
* @method static \Illuminate\Contracts\View\View first(array $views, \Illuminate\Contracts\Support\Arrayable|array $data = [], array $mergeData = [])
* @method static \Illuminate\Contracts\View\Factory replaceNamespace(string $namespace, string|array $hints)
+ * @method static \Illuminate\Contracts\View\Factory addExtension(string $extension, string $engine, \Closure|null $resolver = null)
* @method static \Illuminate\Contracts\View\View file(string $path, array $data = [], array $mergeData = [])
* @method static \Illuminate\Contracts\View\View make(string $view, array $data = [], array $mergeData = [])
* @method static array composer(array|string $views, \Closure|string $callback) | false |
Other | laravel | framework | ab9d8872a92c60d221adf88b2f1d47b935d8afa0.json | Fix flaky cipher tag test (#38649) | tests/Encryption/EncrypterTest.php | @@ -102,7 +102,7 @@ public function testThatAnAeadTagCantBeModified()
$this->expectException(DecryptException::class);
$this->expectExceptionMessage('Could not decrypt the data.');
- $data->tag = 'A'.substr($data->tag, 1, 23);
+ $data->tag[0] = $data->tag[0] === 'A' ? 'B' : 'A';
$encrypted = base64_encode(json_encode($data));
$e->decrypt($encrypted);
} | false |
Other | laravel | framework | e9cd94c89f59c833c13d04f32f1e31db419a4c0c.json | allow quiet creation | src/Illuminate/Database/Eloquent/Factories/Factory.php | @@ -202,6 +202,17 @@ public function createOne($attributes = [])
return $this->count(null)->create($attributes);
}
+ /**
+ * Create a single model and persist it to the database.
+ *
+ * @param array $attributes
+ * @return \Illuminate\Database\Eloquent\Model
+ */
+ public function createOneQuietly($attributes = [])
+ {
+ return $this->count(null)->createQuietly($attributes);
+ }
+
/**
* Create a collection of models and persist them to the database.
*
@@ -217,6 +228,19 @@ public function createMany(iterable $records)
);
}
+ /**
+ * Create a collection of models and persist them to the database.
+ *
+ * @param iterable $records
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public function createManyQuietly(iterable $records)
+ {
+ return Model::withoutEvents(function () use ($records) {
+ return $this->createMany($records);
+ });
+ }
+
/**
* Create a collection of models and persist them to the database.
*
@@ -245,6 +269,20 @@ public function create($attributes = [], ?Model $parent = null)
return $results;
}
+ /**
+ * Create a collection of models and persist them to the database.
+ *
+ * @param array $attributes
+ * @param \Illuminate\Database\Eloquent\Model|null $parent
+ * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model
+ */
+ public function createQuietly($attributes = [], ?Model $parent = null)
+ {
+ return Model::withoutEvents(function () use ($attributes, $parent) {
+ return $this->create($attributes, $parent);
+ });
+ }
+
/**
* Create a callback that persists a model in the database when invoked.
* | false |
Other | laravel | framework | 31151477aa65e4ff2c76fc8ad33c423b7adf0bfa.json | Use lowercase cipher names (#38600) | src/Illuminate/Encryption/Encrypter.php | @@ -161,7 +161,7 @@ public function decrypt($payload, $unserialize = true)
$tag = empty($payload['tag']) ? null : base64_decode($payload['tag']);
- if (self::$supportedCiphers[$this->cipher]['aead'] && strlen($tag) !== 16) {
+ if (self::$supportedCiphers[strtolower($this->cipher)]['aead'] && strlen($tag) !== 16) {
throw new DecryptException('Could not decrypt the data.');
}
| false |
Other | laravel | framework | 87b7fa721edd87c092916053f5f831ef619038e0.json | Update cipher tests (#38599) | src/Illuminate/Encryption/Encrypter.php | @@ -161,6 +161,10 @@ public function decrypt($payload, $unserialize = true)
$tag = empty($payload['tag']) ? null : base64_decode($payload['tag']);
+ if (self::$supportedCiphers[$this->cipher]['aead'] && strlen($tag) !== 16) {
+ throw new DecryptException('Could not decrypt the data.');
+ }
+
// Here we will decrypt the value. If we are able to successfully decrypt it
// we will then unserialize it and return it out to the caller. If we are
// unable to decrypt this value we will throw out an exception message. | true |
Other | laravel | framework | 87b7fa721edd87c092916053f5f831ef619038e0.json | Update cipher tests (#38599) | tests/Encryption/EncrypterTest.php | @@ -79,6 +79,34 @@ public function testThatAnAeadCipherIncludesTag()
$this->assertNotEmpty($data->tag);
}
+ public function testThatAnAeadTagMustBeProvidedInFullLength()
+ {
+ $e = new Encrypter(str_repeat('b', 32), 'AES-256-GCM');
+ $encrypted = $e->encrypt('foo');
+ $data = json_decode(base64_decode($encrypted));
+
+ $this->expectException(DecryptException::class);
+ $this->expectExceptionMessage('Could not decrypt the data.');
+
+ $data->tag = substr($data->tag, 0, 4);
+ $encrypted = base64_encode(json_encode($data));
+ $e->decrypt($encrypted);
+ }
+
+ public function testThatAnAeadTagCantBeModified()
+ {
+ $e = new Encrypter(str_repeat('b', 32), 'AES-256-GCM');
+ $encrypted = $e->encrypt('foo');
+ $data = json_decode(base64_decode($encrypted));
+
+ $this->expectException(DecryptException::class);
+ $this->expectExceptionMessage('Could not decrypt the data.');
+
+ $data->tag = 'A'.substr($data->tag, 1, 23);
+ $encrypted = base64_encode(json_encode($data));
+ $e->decrypt($encrypted);
+ }
+
public function testThatANonAeadCipherIncludesMac()
{
$e = new Encrypter(str_repeat('b', 32), 'AES-256-CBC'); | true |
Other | laravel | framework | 9ed095dc2d0c254e6558b514ea285b767407034b.json | update doc block | src/Illuminate/Database/Eloquent/Model.php | @@ -1002,7 +1002,7 @@ public function save(array $options = [])
}
/**
- * Save the model to the database using transaction.
+ * Save the model to the database within a transaction.
*
* @param array $options
* @return bool | false |
Other | laravel | framework | 36ca1bea4c217fbc2457844a87f035e28303f8f6.json | Apply fixes from StyleCI | src/Illuminate/Auth/Notifications/ResetPassword.php | @@ -67,7 +67,7 @@ public function toMail($notifiable)
return $this->buildMailMessage($url);
}
-
+
/**
* Get the password reset URL for the given notifiable.
* | false |
Other | laravel | framework | 82913a35db2c80f61b3af713b9493b97235fe89e.json | Reduce duplicate calls (#38541)
Reduce duplicate calls | src/Illuminate/Queue/Worker.php | @@ -126,7 +126,7 @@ public function __construct(QueueManager $manager,
*/
public function daemon($connectionName, $queue, WorkerOptions $options)
{
- if ($this->supportsAsyncSignals()) {
+ if ($supportsAsyncSignals = $this->supportsAsyncSignals()) {
$this->listenForSignals();
}
@@ -159,7 +159,7 @@ public function daemon($connectionName, $queue, WorkerOptions $options)
$this->manager->connection($connectionName), $queue
);
- if ($this->supportsAsyncSignals()) {
+ if ($supportsAsyncSignals) {
$this->registerTimeoutHandler($job, $options);
}
@@ -178,7 +178,7 @@ public function daemon($connectionName, $queue, WorkerOptions $options)
$this->sleep($options->sleep);
}
- if ($this->supportsAsyncSignals()) {
+ if ($supportsAsyncSignals) {
$this->resetTimeoutHandler();
}
| false |
Other | laravel | framework | 081f467ade3cea2edf7d581e20a3772c882029f5.json | Dump specific key of the response (#38468) | src/Illuminate/Testing/TestResponse.php | @@ -1349,9 +1349,10 @@ protected function session()
/**
* Dump the content from the response.
*
+ * @param string|null $key
* @return $this
*/
- public function dump()
+ public function dump($key = null)
{
$content = $this->getContent();
@@ -1361,7 +1362,11 @@ public function dump()
$content = $json;
}
- dump($content);
+ if (! is_null($key)) {
+ dump(data_get($content, $key));
+ } else {
+ dump($content);
+ }
return $this;
} | false |
Other | laravel | framework | 3800323e1d0572401eedc498728462e5c635e084.json | Remove unnecessary double MAC for AEAD ciphers | src/Illuminate/Encryption/Encrypter.php | @@ -10,6 +10,18 @@
class Encrypter implements EncrypterContract, StringEncrypter
{
+ /**
+ * The supported cipher algorithms and their properties.
+ *
+ * @var array
+ */
+ private static $supportedCiphers = [
+ 'AES-128-CBC' => ['size' => 16, 'aead' => false],
+ 'AES-256-CBC' => ['size' => 32, 'aead' => false],
+ 'AES-128-GCM' => ['size' => 16, 'aead' => true],
+ 'AES-256-GCM' => ['size' => 32, 'aead' => true],
+ ];
+
/**
* The encryption key.
*
@@ -37,12 +49,13 @@ public function __construct($key, $cipher = 'AES-128-CBC')
{
$key = (string) $key;
- if (static::supported($key, $cipher)) {
- $this->key = $key;
- $this->cipher = $cipher;
- } else {
- throw new RuntimeException('The only supported ciphers are AES-128-CBC, AES-256-CBC, AES-128-GCM, and AES-256-GCM with the correct key lengths.');
+ if (! static::supported($key, $cipher)) {
+ $ciphers = implode(', ', array_keys(self::$supportedCiphers));
+ throw new RuntimeException("Unsupported cipher or incorrect key length. Supported ciphers are: $ciphers.");
}
+
+ $this->key = $key;
+ $this->cipher = $cipher;
}
/**
@@ -54,12 +67,11 @@ public function __construct($key, $cipher = 'AES-128-CBC')
*/
public static function supported($key, $cipher)
{
- $length = mb_strlen($key, '8bit');
+ if (! isset(self::$supportedCiphers[$cipher])) {
+ return false;
+ }
- return ($cipher === 'AES-128-CBC' && $length === 16) ||
- ($cipher === 'AES-256-CBC' && $length === 32) ||
- ($cipher === 'AES-128-GCM' && $length === 16) ||
- ($cipher === 'AES-256-GCM' && $length === 32);
+ return mb_strlen($key, '8bit') === self::$supportedCiphers[$cipher]['size'];
}
/**
@@ -70,7 +82,7 @@ public static function supported($key, $cipher)
*/
public static function generateKey($cipher)
{
- return random_bytes($cipher === 'AES-128-CBC' ? 16 : 32);
+ return random_bytes(self::$supportedCiphers[$cipher]['size']);
}
/**
@@ -86,33 +98,31 @@ public function encrypt($value, $serialize = true)
{
$iv = random_bytes(openssl_cipher_iv_length($this->cipher));
- $tag = in_array($this->cipher, ['AES-128-GCM', 'AES-256-GCM']) ? '' : null;
-
- // First we will encrypt the value using OpenSSL. After this is encrypted we
- // will proceed to calculating a MAC for the encrypted value so that this
- // value can be verified later as not having been changed by the users.
- $value =
- in_array($this->cipher, ['AES-128-GCM', 'AES-256-GCM']) ?
- \openssl_encrypt(
- $serialize ? serialize($value) : $value,
- $this->cipher, $this->key, 0, $iv, $tag
- ) :
- \openssl_encrypt(
- $serialize ? serialize($value) : $value,
- $this->cipher, $this->key, 0, $iv
- );
+ // A tag (mac) is returned by openssl_encrypt for AEAD ciphers.
+ // Including $tag in the call for non-AEAD ciphers results in a warning before PHP 8.1.
+ $tag = '';
+ $value = self::$supportedCiphers[$this->cipher]['aead']
+ ? \openssl_encrypt(
+ $serialize ? serialize($value) : $value,
+ $this->cipher, $this->key, 0, $iv, $tag
+ )
+ : \openssl_encrypt(
+ $serialize ? serialize($value) : $value,
+ $this->cipher, $this->key, 0, $iv
+ );
if ($value === false) {
throw new EncryptException('Could not encrypt the data.');
}
- // Once we get the encrypted value we'll go ahead and base64_encode the input
- // vector and create the MAC for the encrypted value so we can then verify
- // its authenticity. Then, we'll JSON the data into the "payload" array.
- $mac = $this->hash(
- $iv = base64_encode($iv), $value, $tag = $tag ? base64_encode($tag) : ''
- );
+ $iv = base64_encode($iv);
+ $tag = base64_encode($tag);
+
+ $mac = self::$supportedCiphers[$this->cipher]['aead']
+ ? '' // For AEAD-algoritms, the tag/mac is returned by openssl_encrypt
+ : $this->hash($iv, $value);
+ // Both tag and mac are included for compatibility reasons. A breaking update could use the same name for these.
$json = json_encode(compact('iv', 'value', 'mac', 'tag'), JSON_UNESCAPED_SLASHES);
if (json_last_error() !== JSON_ERROR_NONE) {
@@ -184,12 +194,11 @@ public function decryptString($payload)
*
* @param string $iv
* @param mixed $value
- * @param string $tag
* @return string
*/
- protected function hash($iv, $value, $tag = '')
+ protected function hash($iv, $value)
{
- return hash_hmac('sha256', $tag.$iv.$value, $this->key);
+ return hash_hmac('sha256', $iv.$value, $this->key);
}
/**
@@ -211,7 +220,8 @@ protected function getJsonPayload($payload)
throw new DecryptException('The payload is invalid.');
}
- if (! $this->validMac($payload)) {
+ // We only need to check for the valid MAC if a non-AEAD algorithm is used
+ if (! self::$supportedCiphers[$this->cipher]['aead'] && ! $this->validMac($payload)) {
throw new DecryptException('The MAC is invalid.');
}
@@ -239,7 +249,7 @@ protected function validPayload($payload)
protected function validMac(array $payload)
{
return hash_equals(
- $this->hash($payload['iv'], $payload['value'], $payload['tag'] ?? ''), $payload['mac']
+ $this->hash($payload['iv'], $payload['value']), $payload['mac']
);
}
| true |
Other | laravel | framework | 3800323e1d0572401eedc498728462e5c635e084.json | Remove unnecessary double MAC for AEAD ciphers | tests/Encryption/EncrypterTest.php | @@ -56,34 +56,54 @@ public function testWithCustomCipher()
$this->assertSame('foo', $e->decrypt($encrypted));
}
+ public function testThatAnAeadCipherIncludesTag()
+ {
+ $e = new Encrypter(str_repeat('b', 32), 'AES-256-GCM');
+ $encrypted = $e->encrypt('foo');
+ $data = json_decode(base64_decode($encrypted));
+
+ $this->assertEmpty($data->mac);
+ $this->assertNotEmpty($data->tag);
+ }
+
+ public function testThatANonAeadCipherIncludesMac()
+ {
+ $e = new Encrypter(str_repeat('b', 32), 'AES-256-CBC');
+ $encrypted = $e->encrypt('foo');
+ $data = json_decode(base64_decode($encrypted));
+
+ $this->assertEmpty($data->tag);
+ $this->assertNotEmpty($data->mac);
+ }
+
public function testDoNoAllowLongerKey()
{
$this->expectException(RuntimeException::class);
- $this->expectExceptionMessage('The only supported ciphers are AES-128-CBC, AES-256-CBC, AES-128-GCM, and AES-256-GCM with the correct key lengths.');
+ $this->expectExceptionMessage('Unsupported cipher or incorrect key length. Supported ciphers are: AES-128-CBC, AES-256-CBC, AES-128-GCM, AES-256-GCM.');
new Encrypter(str_repeat('z', 32));
}
public function testWithBadKeyLength()
{
$this->expectException(RuntimeException::class);
- $this->expectExceptionMessage('The only supported ciphers are AES-128-CBC, AES-256-CBC, AES-128-GCM, and AES-256-GCM with the correct key lengths.');
+ $this->expectExceptionMessage('Unsupported cipher or incorrect key length. Supported ciphers are: AES-128-CBC, AES-256-CBC, AES-128-GCM, AES-256-GCM.');
new Encrypter(str_repeat('a', 5));
}
public function testWithBadKeyLengthAlternativeCipher()
{
$this->expectException(RuntimeException::class);
- $this->expectExceptionMessage('The only supported ciphers are AES-128-CBC, AES-256-CBC, AES-128-GCM, and AES-256-GCM with the correct key lengths.');
+ $this->expectExceptionMessage('Unsupported cipher or incorrect key length. Supported ciphers are: AES-128-CBC, AES-256-CBC, AES-128-GCM, AES-256-GCM.');
new Encrypter(str_repeat('a', 16), 'AES-256-CFB8');
}
public function testWithUnsupportedCipher()
{
$this->expectException(RuntimeException::class);
- $this->expectExceptionMessage('The only supported ciphers are AES-128-CBC, AES-256-CBC, AES-128-GCM, and AES-256-GCM with the correct key lengths.');
+ $this->expectExceptionMessage('Unsupported cipher or incorrect key length. Supported ciphers are: AES-128-CBC, AES-256-CBC, AES-128-GCM, AES-256-GCM.');
new Encrypter(str_repeat('c', 16), 'AES-256-CFB8');
} | true |
Other | laravel | framework | f409e0433fd1d9186dc6dfb32e277adb74e96fdc.json | Update firstOrFail logic (#38470) | src/Illuminate/Collections/Collection.php | @@ -1146,7 +1146,7 @@ public function firstOrFail($key = null, $operator = null, $value = null)
? $this->operatorForWhere(...func_get_args())
: $key;
- $items = $this->when($filter)->filter($filter);
+ $items = $this->unless($filter == null)->filter($filter);
if ($items->isEmpty()) {
throw new ItemNotFoundException; | true |
Other | laravel | framework | f409e0433fd1d9186dc6dfb32e277adb74e96fdc.json | Update firstOrFail logic (#38470) | src/Illuminate/Collections/LazyCollection.php | @@ -1091,7 +1091,7 @@ public function firstOrFail($key = null, $operator = null, $value = null)
: $key;
return $this
- ->when($filter)
+ ->unless($filter == null)
->filter($filter)
->take(1)
->collect() | true |
Other | laravel | framework | 1a2ecc9ed42c0cf13d91a0c1c98095eb92bb6b5b.json | Apply fixes from StyleCI | src/Illuminate/Validation/ValidationRuleParser.php | @@ -293,7 +293,7 @@ public static function filterConditionalRules($rules, array $data = [])
if ($attributeRules instanceof ConditionalRules) {
return [$attribute => $attributeRules->passes($data)
? $attributeRules->rules()
- : $attributeRules->defaultRules()];
+ : $attributeRules->defaultRules(), ];
}
return [$attribute => collect($attributeRules)->map(function ($rule) use ($data) { | false |
Other | laravel | framework | 5e4ded83bacc64e5604b6f71496734071c53b221.json | allow only keys directly on safe | src/Illuminate/Foundation/Http/FormRequest.php | @@ -188,11 +188,14 @@ protected function failedAuthorization()
/**
* Get a validated input container for the validated input.
*
- * @return \Illuminate\Support\ValidatedInput
+ * @param array|null $keys
+ * @return \Illuminate\Support\ValidatedInput|array
*/
- public function safe()
+ public function safe(array $keys = null)
{
- return $this->validator->safe();
+ return is_array($keys)
+ ? $this->validator->safe()->only($keys)
+ : $this->validator->safe();
}
/** | true |
Other | laravel | framework | 5e4ded83bacc64e5604b6f71496734071c53b221.json | allow only keys directly on safe | src/Illuminate/Validation/Validator.php | @@ -510,11 +510,14 @@ public function validateWithBag(string $errorBag)
/**
* Get a validated input container for the validated input.
*
- * @return \Illuminate\Support\ValidatedInput
+ * @param array|null $keys
+ * @return \Illuminate\Support\ValidatedInput|array
*/
- public function safe()
+ public function safe(array $keys = null)
{
- return new ValidatedInput($this->validated());
+ return is_array($keys)
+ ? (new ValidatedInput($this->validated()))->only($keys)
+ : new ValidatedInput($this->validated());
}
/** | true |
Other | laravel | framework | f84f72594bbbed3f4dff11137e5f827d1f15192c.json | Convert non-existant namespace (#38449) | src/Illuminate/Collections/Collection.php | @@ -4,8 +4,6 @@
use ArrayAccess;
use ArrayIterator;
-use Illuminate\Collections\ItemNotFoundException;
-use Illuminate\Collections\MultipleItemsFoundException;
use Illuminate\Support\Traits\EnumeratesValues;
use Illuminate\Support\Traits\Macroable;
use stdClass;
@@ -1110,8 +1108,8 @@ public function splitIn($numberOfGroups)
* @param mixed $value
* @return mixed
*
- * @throws \Illuminate\Collections\ItemNotFoundException
- * @throws \Illuminate\Collections\MultipleItemsFoundException
+ * @throws \Illuminate\Support\ItemNotFoundException
+ * @throws \Illuminate\Support\MultipleItemsFoundException
*/
public function sole($key = null, $operator = null, $value = null)
{ | true |
Other | laravel | framework | f84f72594bbbed3f4dff11137e5f827d1f15192c.json | Convert non-existant namespace (#38449) | src/Illuminate/Collections/ItemNotFoundException.php | @@ -1,6 +1,6 @@
<?php
-namespace Illuminate\Collections;
+namespace Illuminate\Support;
use RuntimeException;
| true |
Other | laravel | framework | f84f72594bbbed3f4dff11137e5f827d1f15192c.json | Convert non-existant namespace (#38449) | src/Illuminate/Collections/LazyCollection.php | @@ -1057,8 +1057,8 @@ public function split($numberOfGroups)
* @param mixed $value
* @return mixed
*
- * @throws \Illuminate\Collections\ItemNotFoundException
- * @throws \Illuminate\Collections\MultipleItemsFoundException
+ * @throws \Illuminate\Support\ItemNotFoundException
+ * @throws \Illuminate\Support\MultipleItemsFoundException
*/
public function sole($key = null, $operator = null, $value = null)
{ | true |
Other | laravel | framework | f84f72594bbbed3f4dff11137e5f827d1f15192c.json | Convert non-existant namespace (#38449) | src/Illuminate/Collections/MultipleItemsFoundException.php | @@ -1,6 +1,6 @@
<?php
-namespace Illuminate\Collections;
+namespace Illuminate\Support;
use RuntimeException;
| true |
Other | laravel | framework | f84f72594bbbed3f4dff11137e5f827d1f15192c.json | Convert non-existant namespace (#38449) | tests/Support/SupportCollectionTest.php | @@ -7,13 +7,13 @@
use ArrayObject;
use CachingIterator;
use Exception;
-use Illuminate\Collections\ItemNotFoundException;
-use Illuminate\Collections\MultipleItemsFoundException;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString;
+use Illuminate\Support\ItemNotFoundException;
use Illuminate\Support\LazyCollection;
+use Illuminate\Support\MultipleItemsFoundException;
use Illuminate\Support\Str;
use InvalidArgumentException;
use JsonSerializable; | true |
Other | laravel | framework | f84f72594bbbed3f4dff11137e5f827d1f15192c.json | Convert non-existant namespace (#38449) | tests/Support/SupportLazyCollectionIsLazyTest.php | @@ -2,8 +2,8 @@
namespace Illuminate\Tests\Support;
-use Illuminate\Collections\MultipleItemsFoundException;
use Illuminate\Support\LazyCollection;
+use Illuminate\Support\MultipleItemsFoundException;
use PHPUnit\Framework\TestCase;
use stdClass;
| true |
Other | laravel | framework | b25347082b3f592cbcc21033632079bebb4a6fb3.json | Apply fixes from StyleCI | src/Illuminate/Testing/TestComponent.php | @@ -9,26 +9,26 @@
class TestComponent
{
/**
- * The original component.
- *
- * @var \Illuminate\View\Component
- */
+ * The original component.
+ *
+ * @var \Illuminate\View\Component
+ */
public $component;
/**
- * The rendered component contents.
- *
- * @var string
- */
+ * The rendered component contents.
+ *
+ * @var string
+ */
protected $rendered;
/**
- * Create a new test component instance.
- *
- * @param \Illuminate\View\Component $component
- * @param \Illuminate\View\View $view
- * @return void
- */
+ * Create a new test component instance.
+ *
+ * @param \Illuminate\View\Component $component
+ * @param \Illuminate\View\View $view
+ * @return void
+ */
public function __construct($component, $view)
{
$this->component = $component;
@@ -37,12 +37,12 @@ public function __construct($component, $view)
}
/**
- * Assert that the given string is contained within the rendered component.
- *
- * @param string $value
- * @param bool $escape
- * @return $this
- */
+ * Assert that the given string is contained within the rendered component.
+ *
+ * @param string $value
+ * @param bool $escape
+ * @return $this
+ */
public function assertSee($value, $escape = true)
{
$value = $escape ? e($value) : $value;
@@ -53,12 +53,12 @@ public function assertSee($value, $escape = true)
}
/**
- * Assert that the given strings are contained in order within the rendered component.
- *
- * @param array $values
- * @param bool $escape
- * @return $this
- */
+ * Assert that the given strings are contained in order within the rendered component.
+ *
+ * @param array $values
+ * @param bool $escape
+ * @return $this
+ */
public function assertSeeInOrder(array $values, $escape = true)
{
$values = $escape ? array_map('e', ($values)) : $values;
@@ -69,12 +69,12 @@ public function assertSeeInOrder(array $values, $escape = true)
}
/**
- * Assert that the given string is contained within the rendered component text.
- *
- * @param string $value
- * @param bool $escape
- * @return $this
- */
+ * Assert that the given string is contained within the rendered component text.
+ *
+ * @param string $value
+ * @param bool $escape
+ * @return $this
+ */
public function assertSeeText($value, $escape = true)
{
$value = $escape ? e($value) : $value;
@@ -85,12 +85,12 @@ public function assertSeeText($value, $escape = true)
}
/**
- * Assert that the given strings are contained in order within the rendered component text.
- *
- * @param array $values
- * @param bool $escape
- * @return $this
- */
+ * Assert that the given strings are contained in order within the rendered component text.
+ *
+ * @param array $values
+ * @param bool $escape
+ * @return $this
+ */
public function assertSeeTextInOrder(array $values, $escape = true)
{
$values = $escape ? array_map('e', ($values)) : $values;
@@ -101,12 +101,12 @@ public function assertSeeTextInOrder(array $values, $escape = true)
}
/**
- * Assert that the given string is not contained within the rendered component.
- *
- * @param string $value
- * @param bool $escape
- * @return $this
- */
+ * Assert that the given string is not contained within the rendered component.
+ *
+ * @param string $value
+ * @param bool $escape
+ * @return $this
+ */
public function assertDontSee($value, $escape = true)
{
$value = $escape ? e($value) : $value;
@@ -117,12 +117,12 @@ public function assertDontSee($value, $escape = true)
}
/**
- * Assert that the given string is not contained within the rendered component text.
- *
- * @param string $value
- * @param bool $escape
- * @return $this
- */
+ * Assert that the given string is not contained within the rendered component text.
+ *
+ * @param string $value
+ * @param bool $escape
+ * @return $this
+ */
public function assertDontSeeText($value, $escape = true)
{
$value = $escape ? e($value) : $value;
@@ -133,10 +133,10 @@ public function assertDontSeeText($value, $escape = true)
}
/**
- * Get the string contents of the rendered component.
- *
- * @return string
- */
+ * Get the string contents of the rendered component.
+ *
+ * @return string
+ */
public function __toString()
{
return $this->rendered; | true |
Other | laravel | framework | b25347082b3f592cbcc21033632079bebb4a6fb3.json | Apply fixes from StyleCI | tests/Foundation/Testing/Concerns/InteractsWithViewsTest.php | @@ -22,10 +22,12 @@ public function testComponentCanAccessPublicProperties()
$exampleComponent = new class extends Component
{
public $foo = 'bar';
+
public function speak()
{
return 'hello';
}
+
public function render()
{
return 'rendered content'; | true |
Other | laravel | framework | 9e9bdaf06e9e65057e40f04bc34a0e45c689eb8c.json | Update InteractsWithInput.php (#38426)
* Update InteractsWithInput.php
Recently I came across some conditions that I needed to send both `Basic` and `Bearer` token. As we can send `Authorization Basic X, Bearer Y` we need to change logic how to get token from the `Authorization` header.
* Update InteractsWithInput.php
* Update InteractsWithInput.php
* formatting
* use strpos method
Co-authored-by: Taylor Otwell <taylorotwell@gmail.com> | src/Illuminate/Http/Concerns/InteractsWithInput.php | @@ -4,7 +4,6 @@
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
-use Illuminate\Support\Str;
use SplFileInfo;
use stdClass;
use Symfony\Component\VarDumper\VarDumper;
@@ -55,8 +54,12 @@ public function bearerToken()
{
$header = $this->header('Authorization', '');
- if (Str::startsWith($header, 'Bearer ')) {
- return Str::substr($header, 7);
+ $position = strrpos($header, 'Bearer');
+
+ if ($position !== false) {
+ $header = substr($header, $position + 7);
+
+ return strpos($header, ',') !== false ? strstr(',', $header, true) : $header;
}
}
| true |
Other | laravel | framework | 9e9bdaf06e9e65057e40f04bc34a0e45c689eb8c.json | Update InteractsWithInput.php (#38426)
* Update InteractsWithInput.php
Recently I came across some conditions that I needed to send both `Basic` and `Bearer` token. As we can send `Authorization Basic X, Bearer Y` we need to change logic how to get token from the `Authorization` header.
* Update InteractsWithInput.php
* Update InteractsWithInput.php
* formatting
* use strpos method
Co-authored-by: Taylor Otwell <taylorotwell@gmail.com> | tests/Http/HttpRequestTest.php | @@ -695,6 +695,15 @@ public function testHeaderMethod()
$this->assertSame('foo', $all['do-this'][0]);
}
+ public function testBearerTokenMethod()
+ {
+ $request = Request::create('/', 'GET', [], [], [], ['HTTP_AUTHORIZATION' => 'Bearer foo']);
+ $this->assertSame('foo', $request->bearerToken());
+
+ $request = Request::create('/', 'GET', [], [], [], ['HTTP_AUTHORIZATION' => 'Basic foo, Bearer bar']);
+ $this->assertSame('bar', $request->bearerToken());
+ }
+
public function testJSONMethod()
{
$payload = ['name' => 'taylor']; | true |
Other | laravel | framework | f43091f78e1021f0156f834ee685ec46cda83a54.json | accept only array | src/Illuminate/Database/Eloquent/Model.php | @@ -437,12 +437,11 @@ public function qualifyColumn($column)
/**
* Qualify the column's lists name by the model's table.
*
- * @param array|mixed $columns
+ * @param array $columns
* @return array
*/
public function qualifyColumns($columns)
{
- $columns = is_array($columns) ? $columns : func_get_args();
$qualifiedArray = [];
foreach ($columns as $column) { | true |
Other | laravel | framework | f43091f78e1021f0156f834ee685ec46cda83a54.json | accept only array | tests/Database/DatabaseEloquentBuilderTest.php | @@ -203,7 +203,6 @@ public function testQualifyColumns()
$builder->setModel(new EloquentModelStub);
- $this->assertEquals(['stub.column', 'stub.name'], $builder->qualifyColumns('column', 'name'));
$this->assertEquals(['stub.column', 'stub.name'], $builder->qualifyColumns(['column', 'name']));
}
| true |
Other | laravel | framework | 03bf7d5c917dc6b548c158645777cac1ac1aa239.json | try fix last test | tests/Database/DatabaseEloquentBuilderTest.php | @@ -203,8 +203,8 @@ public function testQualifyColumns()
$builder->setModel(new EloquentModelStub);
- $this->assertEquals(['stub.column', 'stub.name'], $builder->qualifyColumns(['column', 'name']));
$this->assertEquals(['stub.column', 'stub.name'], $builder->qualifyColumns('column', 'name'));
+ $this->assertEquals(['stub.column', 'stub.name'], $builder->qualifyColumns(['column', 'name']));
}
public function testGetMethodLoadsModelsAndHydratesEagerRelations() | false |
Other | laravel | framework | 587668fcf51a329fa6618a97cbb80bce2a855e10.json | fix code style 6 | src/Illuminate/Database/Eloquent/Model.php | @@ -447,8 +447,8 @@ public function qualifyColumns($columns)
foreach ($columns as $column) {
$qualifiedArray[] = $this->qualifyColumn($column);
- }
-
+ }
+
return $qualifiedArray;
}
| false |
Other | laravel | framework | 69015fc853c47ce54d9ad36d8c8874c85ccf0bbb.json | fix code style 5 | src/Illuminate/Database/Eloquent/Model.php | @@ -448,6 +448,7 @@ public function qualifyColumns($columns)
foreach ($columns as $column) {
$qualifiedArray[] = $this->qualifyColumn($column);
}
+
return $qualifiedArray;
}
| false |
Other | laravel | framework | b3a61698a6455dc9ff4e0134bed9a8239d8b9d70.json | fix code style 4 | src/Illuminate/Database/Eloquent/Model.php | @@ -443,13 +443,11 @@ public function qualifyColumn($column)
public function qualifyColumns($columns)
{
$columns = is_array($columns) ? $columns : func_get_args();
-
$qualifiedArray = [];
foreach ($columns as $column) {
$qualifiedArray[] = $this->qualifyColumn($column);
- }
-
+ }
return $qualifiedArray;
}
| false |
Other | laravel | framework | 3a7d9ac0c9d731f9626ca707cc154af9fb3799ff.json | fix code style 3 | src/Illuminate/Database/Eloquent/Model.php | @@ -443,7 +443,9 @@ public function qualifyColumn($column)
public function qualifyColumns($columns)
{
$columns = is_array($columns) ? $columns : func_get_args();
+
$qualifiedArray = [];
+
foreach ($columns as $column) {
$qualifiedArray[] = $this->qualifyColumn($column);
} | false |
Other | laravel | framework | 4883bb5ae32ba3b79a67598932b648f8f85ecf32.json | fix code style 2 | src/Illuminate/Database/Eloquent/Model.php | @@ -447,6 +447,7 @@ public function qualifyColumns($columns)
foreach ($columns as $column) {
$qualifiedArray[] = $this->qualifyColumn($column);
}
+
return $qualifiedArray;
}
| false |
Other | laravel | framework | e336ecac583c6607a3719c362dc3a745e3fd7c0a.json | fix code style | src/Illuminate/Database/Eloquent/Model.php | @@ -440,11 +440,11 @@ public function qualifyColumn($column)
* @param array|mixed $columns
* @return array
*/
- public function qualifyColumns($columns)
+ public function qualifyColumns($columns)
{
$columns = is_array($columns) ? $columns : func_get_args();
$qualifiedArray = [];
- foreach($columns as $column) {
+ foreach ($columns as $column) {
$qualifiedArray[] = $this->qualifyColumn($column);
}
return $qualifiedArray; | false |
Other | laravel | framework | fb58f1906e7a486759393aa6dbfdf35615c82add.json | fix simple test | tests/Database/DatabaseEloquentBuilderTest.php | @@ -203,8 +203,7 @@ public function testQualifyColumns()
$builder->setModel(new EloquentModelStub);
- $this->assertEquals(['stub.column', 'stub.column2', 'stub.column3'], $builder->qualifyColumns('column', 'column2', 'column3'));
- $this->assertEquals(['stub.column', 'stub.column2', 'stub.column3'], $builder->qualifyColumns(['column', 'column2', 'column3']));
+ $this->assertEquals(['stub.column'], $builder->qualifyColumns('column'));
}
public function testGetMethodLoadsModelsAndHydratesEagerRelations() | false |
Other | laravel | framework | d373a1c3c17fb8b830e5e8e3949016694f0713ff.json | Define qualifyColumns method | src/Illuminate/Database/Eloquent/Model.php | @@ -434,6 +434,20 @@ public function qualifyColumn($column)
return $this->getTable().'.'.$column;
}
+ /**
+ * Qualify the column's lists name by the model's table.
+ *
+ * @param array|mixed $columns
+ * @return array
+ */
+ public function qualifyColumns(...$columns) {
+ $qualifiedArray = [];
+ foreach($columns as $column) {
+ $qualifiedArray[] = $this->qualifyColumn($column);
+ }
+ return $qualifiedArray;
+ }
+
/**
* Create a new instance of the given model.
* | false |
Other | laravel | framework | 3a8efd737a93e828267cfcfbd6eea370a3b4180b.json | Remove unecessary @method doc (#38392) | src/Illuminate/Support/Facades/Queue.php | @@ -21,7 +21,6 @@
* @method static void assertPushed(string|\Closure $job, callable|int $callback = null)
* @method static void assertPushedOn(string $queue, string|\Closure $job, callable|int $callback = null)
* @method static void assertPushedWithChain(string $job, array $expectedChain = [], callable $callback = null)
- * @method static void popUsing(string $workerName, callable $callback)
*
* @see \Illuminate\Queue\QueueManager
* @see \Illuminate\Queue\Queue | false |
Other | laravel | framework | ff9d29e455829bd404680b4f31be33b7dcbbaf23.json | Create a test for TestComponent Class | tests/Foundation/Testing/Concerns/InteractsWithViewsTest.php | @@ -3,6 +3,7 @@
namespace Illuminate\Tests\Foundation\Testing\Concerns;
use Illuminate\Foundation\Testing\Concerns\InteractsWithViews;
+use Illuminate\View\Component;
use Orchestra\Testbench\TestCase;
class InteractsWithViewsTest extends TestCase
@@ -15,4 +16,19 @@ public function testBladeCorrectlyRendersString()
$this->assertEquals('test ', $string);
}
+
+ public function testComponentCanAccessPublicProperties()
+ {
+ $exampleComponent = new class extends Component
+ {
+ public $foo = 'bar';
+ public function render()
+ {
+ return '';
+ }
+ };
+ $component = $this->component(get_class($exampleComponent));
+
+ $this->assertEquals('bar', $component->foo);
+ }
} | false |
Other | laravel | framework | 59b674a31492dae75c1407cd3f14b03c80ca145e.json | Apply fixes from StyleCI | tests/Support/SupportReflectsClosuresTest.php | @@ -74,7 +74,7 @@ public function testItWorksWithUnionTypes()
ExampleParameter::class,
], $types);
- $types = ReflectsClosuresClass::reflectFirstAll(function (ExampleParameter|AnotherExampleParameter $a, $b) {
+ $types = ReflectsClosuresClass::reflectFirstAll(function (ExampleParameter | AnotherExampleParameter $a, $b) {
//
});
| false |
Other | laravel | framework | 8cbdf8fa668898c98b750c394e555c2db682b2b2.json | Apply fixes from StyleCI | tests/Integration/Foundation/Fixtures/EventDiscovery/UnionListeners/UnionListener.php | @@ -7,7 +7,7 @@
class UnionListener
{
- public function handle(EventOne|EventTwo $event)
+ public function handle(EventOne | EventTwo $event)
{
//
} | false |
Other | laravel | framework | 8c65b3d8edf245ea0dbb13ed203eb23209b2b8fe.json | Support union types on event discovery (#38383)
* support union types on event discovery
* add test
* add test
* fix tests
* extract method | src/Illuminate/Foundation/Events/DiscoverEvents.php | @@ -21,11 +21,23 @@ class DiscoverEvents
*/
public static function within($listenerPath, $basePath)
{
- return collect(static::getListenerEvents(
+ $listeners = collect(static::getListenerEvents(
(new Finder)->files()->in($listenerPath), $basePath
- ))->mapToDictionary(function ($event, $listener) {
- return [$event => $listener];
- })->all();
+ ));
+
+ $discoveredEvents = [];
+
+ foreach ($listeners as $listener => $events) {
+ foreach ($events as $event) {
+ if (! isset($discoveredEvents[$event])) {
+ $discoveredEvents[$event] = [];
+ }
+
+ $discoveredEvents[$event][] = $listener;
+ }
+ }
+
+ return $discoveredEvents;
}
/**
@@ -59,7 +71,7 @@ protected static function getListenerEvents($listeners, $basePath)
}
$listenerEvents[$listener->name.'@'.$method->name] =
- Reflector::getParameterClassName($method->getParameters()[0]);
+ Reflector::getParameterClassNames($method->getParameters()[0]);
}
}
| true |
Other | laravel | framework | 8c65b3d8edf245ea0dbb13ed203eb23209b2b8fe.json | Support union types on event discovery (#38383)
* support union types on event discovery
* add test
* add test
* fix tests
* extract method | src/Illuminate/Support/Reflector.php | @@ -5,6 +5,7 @@
use ReflectionClass;
use ReflectionMethod;
use ReflectionNamedType;
+use ReflectionUnionType;
class Reflector
{
@@ -69,6 +70,45 @@ public static function getParameterClassName($parameter)
return;
}
+ return static::getTypeName($parameter, $type);
+ }
+
+ /**
+ * Get the class names of the given parameter's type, including union types.
+ *
+ * @param \ReflectionParameter $parameter
+ * @return array
+ */
+ public static function getParameterClassNames($parameter)
+ {
+ $type = $parameter->getType();
+
+ if (! $type instanceof ReflectionUnionType) {
+ return [static::getParameterClassName($parameter)];
+ }
+
+ $unionTypes = [];
+
+ foreach ($type->getTypes() as $listedType) {
+ if (! $listedType instanceof ReflectionNamedType || $listedType->isBuiltin()) {
+ continue;
+ }
+
+ $unionTypes[] = static::getTypeName($parameter, $listedType);
+ }
+
+ return $unionTypes;
+ }
+
+ /**
+ * Get the given type's class name.
+ *
+ * @param \ReflectionParameter $parameter
+ * @param \ReflectionNamedType $type
+ * @return string
+ */
+ protected static function getTypeName($parameter, $type)
+ {
$name = $type->getName();
if (! is_null($class = $parameter->getDeclaringClass())) { | true |
Other | laravel | framework | 8c65b3d8edf245ea0dbb13ed203eb23209b2b8fe.json | Support union types on event discovery (#38383)
* support union types on event discovery
* add test
* add test
* fix tests
* extract method | tests/Integration/Foundation/DiscoverEventsTest.php | @@ -8,6 +8,7 @@
use Illuminate\Tests\Integration\Foundation\Fixtures\EventDiscovery\Listeners\AbstractListener;
use Illuminate\Tests\Integration\Foundation\Fixtures\EventDiscovery\Listeners\Listener;
use Illuminate\Tests\Integration\Foundation\Fixtures\EventDiscovery\Listeners\ListenerInterface;
+use Illuminate\Tests\Integration\Foundation\Fixtures\EventDiscovery\UnionListeners\UnionListener;
use Orchestra\Testbench\TestCase;
class DiscoverEventsTest extends TestCase
@@ -30,4 +31,24 @@ class_alias(ListenerInterface::class, 'Tests\Integration\Foundation\Fixtures\Eve
],
], $events);
}
+
+ public function testUnionEventsCanBeDiscovered()
+ {
+ if (version_compare(phpversion(), '8.0.0', '<')) {
+ $this->markTestSkipped('Test uses union types.');
+ }
+
+ class_alias(UnionListener::class, 'Tests\Integration\Foundation\Fixtures\EventDiscovery\UnionListeners\UnionListener');
+
+ $events = DiscoverEvents::within(__DIR__.'/Fixtures/EventDiscovery/UnionListeners', getcwd());
+
+ $this->assertEquals([
+ EventOne::class => [
+ UnionListener::class.'@handle',
+ ],
+ EventTwo::class => [
+ UnionListener::class.'@handle',
+ ],
+ ], $events);
+ }
} | true |
Other | laravel | framework | 8c65b3d8edf245ea0dbb13ed203eb23209b2b8fe.json | Support union types on event discovery (#38383)
* support union types on event discovery
* add test
* add test
* fix tests
* extract method | tests/Integration/Foundation/Fixtures/EventDiscovery/UnionListeners/UnionListener.php | @@ -0,0 +1,14 @@
+<?php
+
+namespace Illuminate\Tests\Integration\Foundation\Fixtures\EventDiscovery\UnionListeners;
+
+use Illuminate\Tests\Integration\Foundation\Fixtures\EventDiscovery\Events\EventOne;
+use Illuminate\Tests\Integration\Foundation\Fixtures\EventDiscovery\Events\EventTwo;
+
+class UnionListener
+{
+ public function handle(EventOne|EventTwo $event)
+ {
+ //
+ }
+} | true |
Other | laravel | framework | a3eebe0c883759b2503b77195e66cd863fce5948.json | fix styleCI issue | src/Illuminate/Http/Client/PendingRequest.php | @@ -808,7 +808,7 @@ public function createClient($handlerStack)
}
/**
- * add handlers to the handler stack
+ * add handlers to the handler stack.
*
* @param \GuzzleHttp\HandlerStack $handlerStack
* @return \GuzzleHttp\HandlerStack
@@ -1046,7 +1046,7 @@ public function setClient(Client $client)
}
/**
- * set the handler function
+ * set the handler function.
*
* @param callable $handler
* @return $this | true |
Other | laravel | framework | a3eebe0c883759b2503b77195e66cd863fce5948.json | fix styleCI issue | src/Illuminate/Http/Client/Pool.php | @@ -17,7 +17,7 @@ class Pool
protected $factory;
/**
- * The handler function for Guzzle client
+ * The handler function for Guzzle client.
*
* @var callable
*/ | true |
Other | laravel | framework | a3eebe0c883759b2503b77195e66cd863fce5948.json | fix styleCI issue | tests/Http/HttpClientTest.php | @@ -958,7 +958,6 @@ public function testTheRequestSendingAndResponseReceivedEventsAreFiredWhenAReque
];
});
-
m::close();
}
| true |
Other | laravel | framework | f8b9392b9f2651db566a67fa57fc3e285463bbf6.json | add test for async request fire events | tests/Http/HttpClientTest.php | @@ -940,6 +940,28 @@ public function testTheRequestSendingAndResponseReceivedEventsAreFiredWhenAReque
m::close();
}
+ public function testTheRequestSendingAndResponseReceivedEventsAreFiredWhenARequestIsSentAsync()
+ {
+ $events = m::mock(Dispatcher::class);
+ $events->shouldReceive('dispatch')->times(5)->with(m::type(RequestSending::class));
+ $events->shouldReceive('dispatch')->times(5)->with(m::type(ResponseReceived::class));
+
+ $factory = new Factory($events);
+ $factory->fake();
+ $factory->pool(function (Pool $pool) {
+ return [
+ $pool->get('https://example.com'),
+ $pool->head('https://example.com'),
+ $pool->post('https://example.com'),
+ $pool->patch('https://example.com'),
+ $pool->delete('https://example.com'),
+ ];
+ });
+
+
+ m::close();
+ }
+
public function testTheTransferStatsAreCalledSafelyWhenFakingTheRequest()
{
$this->factory->fake(['https://example.com' => ['world' => 'Hello world']]); | false |
Other | laravel | framework | 94c1b8a72250b07d4a16233f545f1ec8bc195f9a.json | Fix incorrect type | src/Illuminate/Http/Exceptions/PostTooLargeException.php | @@ -10,13 +10,13 @@ class PostTooLargeException extends HttpException
/**
* Create a new "post too large" exception instance.
*
- * @param string|null $message
+ * @param string $message
* @param \Throwable|null $previous
* @param array $headers
* @param int $code
* @return void
*/
- public function __construct($message = null, Throwable $previous = null, array $headers = [], $code = 0)
+ public function __construct($message = '', Throwable $previous = null, array $headers = [], $code = 0)
{
parent::__construct(413, $message, $previous, $headers, $code);
} | false |
Other | laravel | framework | f67efea418b541dd3e6e083335f40a848f8660f4.json | Update return type for tap (#38353)
`when` already has `$this|mixed` so this should be reflected in `tap` on `BuildsQueries`. If you look at the logic inside `when` you'll see that this is the correct return type as it's either the return value of the given callback or `$this`. A previous attempt was made here: https://github.com/laravel/framework/pull/32717
See a more thorough explanation here: https://github.com/laravel/framework/issues/38343 | src/Illuminate/Database/Concerns/BuildsQueries.php | @@ -422,7 +422,7 @@ protected function cursorPaginator($items, $perPage, $cursor, $options)
* Pass the query to a given callback.
*
* @param callable $callback
- * @return $this
+ * @return $this|mixed
*/
public function tap($callback)
{ | false |
Other | laravel | framework | ede6ee6b8743449cbef3fa4b59f115cf764c24e0.json | Fix wrong PHPDoc (#38336) | src/Illuminate/Database/Query/JoinClause.php | @@ -104,7 +104,7 @@ public function on($first, $operator = null, $second = null, $boolean = 'and')
*
* @param \Closure|string $first
* @param string|null $operator
- * @param string|null $second
+ * @param \Illuminate\Database\Query\Expression|string|null $second
* @return \Illuminate\Database\Query\JoinClause
*/
public function orOn($first, $operator = null, $second = null) | false |
Other | laravel | framework | bc1188d74d434ea2b8e9e7f60642cbc67f85956a.json | add stringable support for isUuid (#38330) | src/Illuminate/Support/Stringable.php | @@ -258,6 +258,16 @@ public function isAscii()
return Str::isAscii($this->value);
}
+ /**
+ * Determine if a given string is a valid UUID.
+ *
+ * @return bool
+ */
+ public function isUuid()
+ {
+ return Str::isUuid($this->value);
+ }
+
/**
* Determine if the given string is empty.
* | true |
Other | laravel | framework | bc1188d74d434ea2b8e9e7f60642cbc67f85956a.json | add stringable support for isUuid (#38330) | tests/Support/SupportStringableTest.php | @@ -31,6 +31,12 @@ public function testIsAscii()
$this->assertFalse($this->stringable('ù')->isAscii());
}
+ public function testIsUuid()
+ {
+ $this->assertTrue($this->stringable('2cdc7039-65a6-4ac7-8e5d-d554a98e7b15')->isUuid());
+ $this->assertFalse($this->stringable('2cdc7039-65a6-4ac7-8e5d-d554a98')->isUuid());
+ }
+
public function testIsEmpty()
{
$this->assertTrue($this->stringable('')->isEmpty()); | true |
Other | laravel | framework | be94e7bf403c044446f060b940c8d641d28a9a1f.json | Apply fixes from StyleCI | tests/Cache/CacheRateLimiterTest.php | @@ -89,7 +89,7 @@ public function testAttemptsCallbackReturnsTrue()
$rateLimiter = new RateLimiter($cache);
- $this->assertTrue($rateLimiter->attempt('key', 1, function() use (&$executed) {
+ $this->assertTrue($rateLimiter->attempt('key', 1, function () use (&$executed) {
$executed = true;
}, 1));
$this->assertTrue($executed);
@@ -105,7 +105,7 @@ public function testAttemptsCallbackReturnsCallbackReturn()
$rateLimiter = new RateLimiter($cache);
- $this->assertEquals('foo', $rateLimiter->attempt('key', 1, function() {
+ $this->assertEquals('foo', $rateLimiter->attempt('key', 1, function () {
return 'foo';
}, 1));
}
@@ -120,7 +120,7 @@ public function testAttemptsCallbackReturnsFalse()
$rateLimiter = new RateLimiter($cache);
- $this->assertFalse($rateLimiter->attempt('key', 1, function() use (&$executed) {
+ $this->assertFalse($rateLimiter->attempt('key', 1, function () use (&$executed) {
$executed = true;
}, 1));
$this->assertFalse($executed); | false |
Other | laravel | framework | 9b7491e31381bad1216d018973563d996c77c082.json | add bitwise not operator (#38316) | src/Illuminate/Database/Query/Builder.php | @@ -195,7 +195,7 @@ class Builder
public $operators = [
'=', '<', '>', '<=', '>=', '<>', '!=', '<=>',
'like', 'like binary', 'not like', 'ilike',
- '&', '|', '^', '<<', '>>',
+ '&', '|', '^', '<<', '>>', '&~',
'rlike', 'not rlike', 'regexp', 'not regexp',
'~', '~*', '!~', '!~*', 'similar to',
'not similar to', 'not ilike', '~~*', '!~~*', | false |
Other | laravel | framework | c77fcbe68d25be7805d334f4e22068f34493312d.json | Fix Factory hasMany method (#38319) | src/Illuminate/Database/Eloquent/Factories/Factory.php | @@ -211,9 +211,9 @@ public function createOne($attributes = [])
public function createMany(iterable $records)
{
return new EloquentCollection(
- array_map(function ($record) {
+ collect($records)->map(function ($record) {
return $this->state($record)->create();
- }, $records)
+ })
);
}
| false |
Other | laravel | framework | a31b48afc92668ac02c29ed322734bf25e49f9d3.json | Add ReturnTypeWillChange to SplFileInfo usage | src/Illuminate/Http/Testing/File.php | @@ -107,6 +107,7 @@ public function size($kilobytes)
*
* @return int
*/
+ #[\ReturnTypeWillChange]
public function getSize()
{
return $this->sizeToReport ?: parent::getSize(); | false |
Other | laravel | framework | f1427d16220fa2b47b7314f29247593600b720ab.json | use type hints in cast.stub (#38234) | src/Illuminate/Foundation/Console/stubs/cast.stub | @@ -15,7 +15,7 @@ class {{ class }} implements CastsAttributes
* @param array $attributes
* @return mixed
*/
- public function get($model, $key, $value, $attributes)
+ public function get($model, string $key, $value, array $attributes)
{
return $value;
}
@@ -29,7 +29,7 @@ class {{ class }} implements CastsAttributes
* @param array $attributes
* @return mixed
*/
- public function set($model, $key, $value, $attributes)
+ public function set($model, string $key, $value, array $attributes)
{
return $value;
} | false |
Other | laravel | framework | 72da4ec576fb195536a488b1fbe3234bfacbd944.json | Fix resource type in DocBlocks (#38218) | src/Illuminate/Http/Client/PendingRequest.php | @@ -181,7 +181,7 @@ public function baseUrl(string $url)
/**
* Attach a raw body to the request.
*
- * @param resource|string $content
+ * @param string $content
* @param string $contentType
* @return $this
*/
@@ -220,7 +220,7 @@ public function asForm()
* Attach a file to the request.
*
* @param string|array $name
- * @param string $contents
+ * @param string|resource $contents
* @param string|null $filename
* @param array $headers
* @return $this | false |
Other | laravel | framework | f99752151ec05f3eb572f5bc00b2fdcbed45a51a.json | Apply fixes from StyleCI | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | @@ -51,7 +51,6 @@ public function validateAccepted($attribute, $value)
*/
public function validateAcceptedIf($attribute, $value, $parameters)
{
-
$acceptable = ['yes', 'on', '1', 1, true, 'true'];
$this->requireParameterCount(2, $parameters, 'accepted_if'); | true |
Other | laravel | framework | f99752151ec05f3eb572f5bc00b2fdcbed45a51a.json | Apply fixes from StyleCI | tests/Validation/ValidationValidatorTest.php | @@ -1773,7 +1773,6 @@ public function testValidateAccepted()
public function testValidateAcceptedIf()
{
-
$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => 'no', 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']);
$this->assertFalse($v->passes());
@@ -1806,7 +1805,7 @@ public function testValidateAcceptedIf()
$this->assertTrue($v->passes());
$v = new Validator($trans, ['foo' => 'true', 'bar' => 'aaa'], ['foo' => 'accepted_if:bar,aaa']);
- $this->assertTrue($v->passes());
+ $this->assertTrue($v->passes());
}
public function testValidateEndsWith() | true |
Other | laravel | framework | 9581cd6feb5be3e21c5b32ef154431f63eae89a8.json | Remove ext-json from composer.json (#38202) | composer.json | @@ -16,7 +16,6 @@
],
"require": {
"php": "^8.0",
- "ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"doctrine/inflector": "^2.0", | false |
Other | laravel | framework | e24acf0f8cb319d057853a2727821d674bdda552.json | Fix previous column for cursor pagination (#38203) | src/Illuminate/Database/Concerns/BuildsQueries.php | @@ -305,7 +305,11 @@ protected function paginateUsingCursor($perPage, $columns = ['*'], $cursorName =
if (! is_null($cursor)) {
$addCursorConditions = function (self $builder, $previousColumn, $i) use (&$addCursorConditions, $cursor, $orders) {
if (! is_null($previousColumn)) {
- $builder->where($previousColumn, '=', $cursor->parameter($previousColumn));
+ $builder->where(
+ $this->getOriginalColumnNameForCursorPagination($this, $previousColumn),
+ '=',
+ $cursor->parameter($previousColumn)
+ );
}
$builder->where(function (self $builder) use ($addCursorConditions, $cursor, $orders, $i) { | false |
Other | laravel | framework | 43b08f8cb378133d9a047fda703ac90e27a66cbc.json | add supporting test (#38179) | tests/Validation/ValidationUniqueRuleTest.php | @@ -81,6 +81,17 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule()
$rule->where('foo', '"bar"');
$this->assertSame('unique:table,NULL,NULL,id,foo,"""bar"""', (string) $rule);
}
+
+ public function testItIgnoresSoftDeletes()
+ {
+ $rule = new Unique('table');
+ $rule->withoutTrashed();
+ $this->assertSame('unique:table,NULL,NULL,id,deleted_at,"NULL"', (string) $rule);
+
+ $rule = new Unique('table');
+ $rule->withoutTrashed('softdeleted_at');
+ $this->assertSame('unique:table,NULL,NULL,id,softdeleted_at,"NULL"', (string) $rule);
+ }
}
class EloquentModelStub extends Model | false |
Other | laravel | framework | 70490255a2249045699d0c9878f9fe847ad659b3.json | Add twiceDailyAt schedule frequency (#38174) | src/Illuminate/Console/Scheduling/ManagesFrequencies.php | @@ -262,10 +262,23 @@ public function dailyAt($time)
* @return $this
*/
public function twiceDaily($first = 1, $second = 13)
+ {
+ return $this->twiceDailyAt($first, $second, 0);
+ }
+
+ /**
+ * Schedule the event to run twice daily at a given offset.
+ *
+ * @param int $first
+ * @param int $second
+ * @param int $offset
+ * @return $this
+ */
+ public function twiceDailyAt($first = 1, $second = 13, $offset = 0)
{
$hours = $first.','.$second;
- return $this->spliceIntoPosition(1, 0)
+ return $this->spliceIntoPosition(1, $offset)
->spliceIntoPosition(2, $hours);
}
| true |
Other | laravel | framework | 70490255a2249045699d0c9878f9fe847ad659b3.json | Add twiceDailyAt schedule frequency (#38174) | tests/Console/Scheduling/FrequencyTest.php | @@ -57,6 +57,11 @@ public function testTwiceDaily()
$this->assertSame('0 3,15 * * *', $this->event->twiceDaily(3, 15)->getExpression());
}
+ public function testTwiceDailyAt()
+ {
+ $this->assertSame('5 3,15 * * *', $this->event->twiceDailyAt(3, 15, 5)->getExpression());
+ }
+
public function testWeekly()
{
$this->assertSame('0 0 * * 0', $this->event->weekly()->getExpression()); | true |
Other | laravel | framework | 6662f49fe83d0898cddb8d1beee5c1a507a92514.json | fix error message | src/Illuminate/Foundation/Console/VendorPublishCommand.php | @@ -169,7 +169,7 @@ protected function publishTag($tag)
}
if ($published === false) {
- $this->error('Unable to locate publishable resources.');
+ $this->comment('No publishable resources for tag ['.$tag.'].');
} else {
$this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish));
} | false |
Other | laravel | framework | eaacad4ad2a8e4cecdb1d98a344e1d16206415f4.json | Add cache_locks table to stub. (#38152) | src/Illuminate/Cache/Console/stubs/cache.stub | @@ -18,6 +18,12 @@ class CreateCacheTable extends Migration
$table->mediumText('value');
$table->integer('expiration');
});
+
+ Schema::create('cache_locks', function (Blueprint $table) {
+ $table->string('key')->primary();
+ $table->string('owner');
+ $table->integer('expiration');
+ });
}
/**
@@ -28,5 +34,6 @@ class CreateCacheTable extends Migration
public function down()
{
Schema::dropIfExists('cache');
+ Schema::dropIfExists('cache_locks');
}
} | false |
Other | laravel | framework | 7bd4e6dc547526d072374eb4846e31369987d66f.json | Apply fixes from StyleCI | src/Illuminate/Testing/TestResponse.php | @@ -17,7 +17,6 @@
use Illuminate\Testing\Assert as PHPUnit;
use Illuminate\Testing\Constraints\SeeInOrder;
use Illuminate\Testing\Fluent\AssertableJson;
-use Illuminate\Validation\ValidationException;
use LogicException;
use Symfony\Component\HttpFoundation\StreamedResponse;
| false |
Other | laravel | framework | 5ca5768db439887217c86031ff7dd3bdf56cc466.json | add hook to configure broadcastable model event | src/Illuminate/Database/Eloquent/BroadcastsEvents.php | @@ -124,7 +124,7 @@ protected function broadcastIfBroadcastChannelsExistForEvent($instance, $event,
*/
public function newBroadcastableModelEvent($event)
{
- return tap(new BroadcastableModelEventOccurred($this, $event), function ($event) {
+ return tap($this->withBroadcastableEvent(new BroadcastableModelEventOccurred($this, $event)), function ($event) {
$event->connection = property_exists($this, 'broadcastConnection')
? $this->broadcastConnection
: $this->broadcastConnection();
@@ -139,6 +139,17 @@ public function newBroadcastableModelEvent($event)
});
}
+ /**
+ * Configure the broadcastable model event for the model.
+ *
+ * @param \Illuminate\Database\Eloquent\BroadcastableModelEventOccurred $event
+ * @return \Illuminate\Database\Eloquent\BroadcastableModelEventOccurred
+ */
+ protected function withBroadcastableEvent(BroadcastableModelEventOccurred $event)
+ {
+ return $event;
+ }
+
/**
* Get the channels that model events should broadcast on.
* | false |
Other | laravel | framework | fed2a297b89b8dadf3a3d95c608dfc3b025be532.json | Remove PHPUnit\Util\InvalidArgumentHelper (#38081) | src/Illuminate/Testing/Assert.php | @@ -10,7 +10,6 @@
use PHPUnit\Framework\Constraint\LogicalNot;
use PHPUnit\Framework\Constraint\RegularExpression;
use PHPUnit\Framework\InvalidArgumentException;
-use PHPUnit\Util\InvalidArgumentHelper;
/**
* @internal This class is not meant to be used or overwritten outside the framework itself.
@@ -29,19 +28,11 @@ abstract class Assert extends PHPUnit
public static function assertArraySubset($subset, $array, bool $checkForIdentity = false, string $msg = ''): void
{
if (! (is_array($subset) || $subset instanceof ArrayAccess)) {
- if (class_exists(InvalidArgumentException::class)) {
- throw InvalidArgumentException::create(1, 'array or ArrayAccess');
- } else {
- throw InvalidArgumentHelper::factory(1, 'array or ArrayAccess');
- }
+ throw InvalidArgumentException::create(1, 'array or ArrayAccess');
}
if (! (is_array($array) || $array instanceof ArrayAccess)) {
- if (class_exists(InvalidArgumentException::class)) {
- throw InvalidArgumentException::create(2, 'array or ArrayAccess');
- } else {
- throw InvalidArgumentHelper::factory(2, 'array or ArrayAccess');
- }
+ throw InvalidArgumentException::create(2, 'array or ArrayAccess');
}
$constraint = new ArraySubset($subset, $checkForIdentity); | false |
Other | laravel | framework | ab5fd4bfc2a93283c26a4bfbc63f48355694bca4.json | update php8 string function (#38071) | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | @@ -702,8 +702,8 @@ protected function serializeClassCastableAttribute($key, $value)
*/
protected function isCustomDateTimeCast($cast)
{
- return strncmp($cast, 'date:', 5) === 0 ||
- strncmp($cast, 'datetime:', 9) === 0;
+ return str_starts_with($cast, 'date:') ||
+ str_starts_with($cast, 'datetime:');
}
/**
@@ -714,7 +714,7 @@ protected function isCustomDateTimeCast($cast)
*/
protected function isDecimalCast($cast)
{
- return strncmp($cast, 'decimal:', 8) === 0;
+ return str_starts_with($cast, 'decimal:');
}
/** | false |
Other | laravel | framework | 227c71b3011740987fab7cf317312bbfb02b562c.json | Fix PHPDocs for JSON resources (#38044) | src/Illuminate/Http/Resources/Json/JsonResource.php | @@ -109,7 +109,7 @@ public function resolve($request = null)
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
- * @return array
+ * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{ | true |
Other | laravel | framework | 227c71b3011740987fab7cf317312bbfb02b562c.json | Fix PHPDocs for JSON resources (#38044) | src/Illuminate/Http/Resources/Json/ResourceCollection.php | @@ -94,7 +94,7 @@ public function count()
* Transform the resource into a JSON array.
*
* @param \Illuminate\Http\Request $request
- * @return array
+ * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{ | true |
Other | laravel | framework | f3fad6c8d5c80c62839482be99851692ba4feb96.json | Fix PHPDocs of query builder (#38061) | src/Illuminate/Database/Query/Builder.php | @@ -407,7 +407,7 @@ public function addSelect($column)
/**
* Force the query to only return distinct results.
*
- * @param mixed $distinct,...
+ * @param mixed ...$distinct
* @return $this
*/
public function distinct() | false |
Other | laravel | framework | b1ed53e5a4cc11730ad5eda8d2d5adb6424421ce.json | allow eloquent model type in be/actingAs (#38055) | src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php | @@ -9,7 +9,7 @@ trait InteractsWithAuthentication
/**
* Set the currently logged in user for the application.
*
- * @param \Illuminate\Contracts\Auth\Authenticatable $user
+ * @param \Illuminate\Contracts\Auth\Authenticatable|\Illuminate\Database\Eloquent\Model $user
* @param string|null $guard
* @return $this
*/
@@ -21,7 +21,7 @@ public function actingAs(UserContract $user, $guard = null)
/**
* Set the currently logged in user for the application.
*
- * @param \Illuminate\Contracts\Auth\Authenticatable $user
+ * @param \Illuminate\Contracts\Auth\Authenticatable|\Illuminate\Database\Eloquent\Model $user
* @param string|null $guard
* @return $this
*/ | false |
Other | laravel | framework | 943ed618870ad525824693d2dc9a0db1a20c36d0.json | Add macroable trait to filesystem adapter (#38030) | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -11,6 +11,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
+use Illuminate\Support\Traits\Macroable;
use InvalidArgumentException;
use League\Flysystem\Adapter\Ftp;
use League\Flysystem\Adapter\Local as LocalAdapter;
@@ -32,6 +33,10 @@
*/
class FilesystemAdapter implements CloudFilesystemContract
{
+ use Macroable {
+ __call as macroCall;
+ }
+
/**
* The Flysystem filesystem implementation.
*
@@ -784,6 +789,10 @@ protected function parseVisibility($visibility)
*/
public function __call($method, array $parameters)
{
+ if (static::hasMacro($method)) {
+ return $this->macroCall($method, $parameters);
+ }
+
return $this->driver->{$method}(...array_values($parameters));
}
} | true |
Other | laravel | framework | 943ed618870ad525824693d2dc9a0db1a20c36d0.json | Add macroable trait to filesystem adapter (#38030) | tests/Filesystem/FilesystemAdapterTest.php | @@ -319,4 +319,16 @@ public function testPutFileWithAbsoluteFilePath()
'uploaded file content'
);
}
+
+ public function testMacroable()
+ {
+ $this->filesystem->write('foo.txt', 'Hello World');
+
+ $filesystemAdapter = new FilesystemAdapter($this->filesystem);
+ $filesystemAdapter->macro('getFoo', function () {
+ return $this->get('foo.txt');
+ });
+
+ $this->assertSame('Hello World', $filesystemAdapter->getFoo());
+ }
} | true |
Other | laravel | framework | 035a0b2e2da129bac2756b1ee3ee10bb8bcda569.json | accept closure for sleepMilliseconds (#38035) | src/Illuminate/Support/helpers.php | @@ -216,7 +216,7 @@ function preg_replace_array($pattern, array $replacements, $subject)
*
* @param int $times
* @param callable $callback
- * @param int $sleepMilliseconds
+ * @param int|\Closure $sleepMilliseconds
* @param callable|null $when
* @return mixed
*
@@ -238,7 +238,7 @@ function retry($times, callable $callback, $sleepMilliseconds = 0, $when = null)
}
if ($sleepMilliseconds) {
- usleep($sleepMilliseconds * 1000);
+ usleep(value($sleepMilliseconds, $attempts) * 1000);
}
goto beginning; | true |
Other | laravel | framework | 035a0b2e2da129bac2756b1ee3ee10bb8bcda569.json | accept closure for sleepMilliseconds (#38035) | tests/Support/SupportHelpersTest.php | @@ -555,6 +555,27 @@ public function testRetry()
$this->assertEqualsWithDelta(0.1, microtime(true) - $startTime, 0.02);
}
+ public function testRetryWithPassingSleepCallback()
+ {
+ $startTime = microtime(true);
+
+ $attempts = retry(3, function ($attempts) {
+ if ($attempts > 2) {
+ return $attempts;
+ }
+
+ throw new RuntimeException;
+ }, function ($attempt) {
+ return $attempt * 100;
+ });
+
+ // Make sure we made three attempts
+ $this->assertEquals(3, $attempts);
+
+ // Make sure we waited 300ms for the first two attempts
+ $this->assertEqualsWithDelta(0.3, microtime(true) - $startTime, 0.02);
+ }
+
public function testRetryWithPassingWhenCallback()
{
$startTime = microtime(true); | true |
Other | laravel | framework | 8059b393eb45749d7e8840a41f33c99b2f4acafd.json | Use string based accessor for Schema facade | src/Illuminate/Database/DatabaseServiceProvider.php | @@ -72,6 +72,10 @@ protected function registerConnectionServices()
return $app['db']->connection();
});
+ $this->app->bind('db.schema', function ($app) {
+ return $app['db']->connection()->getSchemaBuilder();
+ });
+
$this->app->singleton('db.transactions', function ($app) {
return new DatabaseTransactionsManager;
}); | true |
Other | laravel | framework | 8059b393eb45749d7e8840a41f33c99b2f4acafd.json | Use string based accessor for Schema facade | src/Illuminate/Foundation/Application.php | @@ -1304,6 +1304,7 @@ public function registerCoreContainerAliases()
'cookie' => [\Illuminate\Cookie\CookieJar::class, \Illuminate\Contracts\Cookie\Factory::class, \Illuminate\Contracts\Cookie\QueueingFactory::class],
'db' => [\Illuminate\Database\DatabaseManager::class, \Illuminate\Database\ConnectionResolverInterface::class],
'db.connection' => [\Illuminate\Database\Connection::class, \Illuminate\Database\ConnectionInterface::class],
+ 'db.schema' => [\Illuminate\Database\Schema\Builder::class],
'encrypter' => [\Illuminate\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\StringEncrypter::class],
'events' => [\Illuminate\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class],
'files' => [\Illuminate\Filesystem\Filesystem::class], | true |
Other | laravel | framework | 8059b393eb45749d7e8840a41f33c99b2f4acafd.json | Use string based accessor for Schema facade | src/Illuminate/Support/Facades/Facade.php | @@ -23,6 +23,13 @@ abstract class Facade
*/
protected static $resolvedInstance;
+ /**
+ * Determine if the resolved facade should be cached.
+ *
+ * @var bool
+ */
+ protected static $cached = true;
+
/**
* Run a Closure when the facade has been resolved.
*
@@ -84,8 +91,8 @@ public static function shouldReceive()
$name = static::getFacadeAccessor();
$mock = static::isMock()
- ? static::$resolvedInstance[$name]
- : static::createFreshMockInstance();
+ ? static::$resolvedInstance[$name]
+ : static::createFreshMockInstance();
return $mock->shouldReceive(...func_get_args());
}
@@ -197,21 +204,21 @@ protected static function getFacadeAccessor()
/**
* Resolve the facade root instance from the container.
*
- * @param object|string $name
+ * @param string $name
* @return mixed
*/
protected static function resolveFacadeInstance($name)
{
- if (is_object($name)) {
- return $name;
- }
-
if (isset(static::$resolvedInstance[$name])) {
return static::$resolvedInstance[$name];
}
-
+ dump(array_keys(static::$resolvedInstance));
if (static::$app) {
- return static::$resolvedInstance[$name] = static::$app[$name];
+ if (static::$cached) {
+ return static::$resolvedInstance[$name] = static::$app[$name];
+ }
+
+ return static::$app[$name];
}
}
| true |
Other | laravel | framework | 8059b393eb45749d7e8840a41f33c99b2f4acafd.json | Use string based accessor for Schema facade | src/Illuminate/Support/Facades/RateLimiter.php | @@ -24,6 +24,6 @@ class RateLimiter extends Facade
*/
protected static function getFacadeAccessor()
{
- return 'Illuminate\Cache\RateLimiter';
+ return \Illuminate\Cache\RateLimiter::class;
}
} | true |
Other | laravel | framework | 8059b393eb45749d7e8840a41f33c99b2f4acafd.json | Use string based accessor for Schema facade | src/Illuminate/Support/Facades/Schema.php | @@ -24,6 +24,13 @@
*/
class Schema extends Facade
{
+ /**
+ * Determine if the resolved facade should be cached.
+ *
+ * @var bool
+ */
+ protected static $cached = false;
+
/**
* Get a schema builder instance for a connection.
*
@@ -36,12 +43,12 @@ public static function connection($name)
}
/**
- * Get a schema builder instance for the default connection.
+ * Get the registered name of the component.
*
- * @return \Illuminate\Database\Schema\Builder
+ * @return string
*/
protected static function getFacadeAccessor()
{
- return static::$app['db']->connection()->getSchemaBuilder();
+ return 'db.schema';
}
} | true |
Other | laravel | framework | 8059b393eb45749d7e8840a41f33c99b2f4acafd.json | Use string based accessor for Schema facade | tests/Database/DatabaseMigratorIntegrationTest.php | @@ -41,6 +41,9 @@ protected function setUp(): void
$container = new Container;
$container->instance('db', $db->getDatabaseManager());
+ $container->bind('db.schema', function ($app) {
+ return $app['db']->connection()->getSchemaBuilder();
+ });
Facade::setFacadeApplication($container);
| true |
Other | laravel | framework | 7bfc3154dce4576aca44054e8c7359ee2346d6f6.json | Remove CursorPaginationException (#37995) | src/Illuminate/Pagination/CursorPaginationException.php | @@ -1,13 +0,0 @@
-<?php
-
-namespace Illuminate\Pagination;
-
-use RuntimeException;
-
-/**
- * @deprecated Will be removed in a future Laravel version.
- */
-class CursorPaginationException extends RuntimeException
-{
- //
-} | false |
Other | laravel | framework | b75203ef337c22bec4918c26dbfc529f8dbf13ba.json | Simplify Application.php (#37977) | src/Illuminate/Foundation/Application.php | @@ -638,7 +638,7 @@ public function runningUnitTests()
*/
public function registerConfiguredProviders()
{
- $providers = Collection::make($this->config['app.providers'])
+ $providers = Collection::make($this->make('config')->get('app.providers'))
->partition(function ($provider) {
return strpos($provider, 'Illuminate\\') === 0;
}); | false |
Other | laravel | framework | eefdaddbf78bd917e45519b0fedde000069b1048.json | return a 'boolean' rather than 'mixed' | src/Illuminate/Foundation/Console/stubs/policy.stub | @@ -14,7 +14,7 @@ class {{ class }}
* Determine whether the user can view any models.
*
* @param \{{ namespacedUserModel }} $user
- * @return mixed
+ * @return bool
*/
public function viewAny({{ user }} $user)
{
@@ -26,7 +26,7 @@ class {{ class }}
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
- * @return mixed
+ * @return bool
*/
public function view({{ user }} $user, {{ model }} ${{ modelVariable }})
{
@@ -37,7 +37,7 @@ class {{ class }}
* Determine whether the user can create models.
*
* @param \{{ namespacedUserModel }} $user
- * @return mixed
+ * @return bool
*/
public function create({{ user }} $user)
{
@@ -49,7 +49,7 @@ class {{ class }}
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
- * @return mixed
+ * @return bool
*/
public function update({{ user }} $user, {{ model }} ${{ modelVariable }})
{
@@ -61,7 +61,7 @@ class {{ class }}
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
- * @return mixed
+ * @return bool
*/
public function delete({{ user }} $user, {{ model }} ${{ modelVariable }})
{
@@ -73,7 +73,7 @@ class {{ class }}
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
- * @return mixed
+ * @return bool
*/
public function restore({{ user }} $user, {{ model }} ${{ modelVariable }})
{
@@ -85,7 +85,7 @@ class {{ class }}
*
* @param \{{ namespacedUserModel }} $user
* @param \{{ namespacedModel }} ${{ modelVariable }}
- * @return mixed
+ * @return bool
*/
public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }})
{ | false |
Other | laravel | framework | 3ade2155a2af35964ee99f583f0a30d8ce70cb23.json | Add missing params in docblocks | src/Illuminate/Database/PDO/Connection.php | @@ -110,7 +110,7 @@ public function lastInsertId($name = null)
/**
* Create a new statement instance.
*
- * @param \PDOStatement
+ * @param \PDOStatement $stmt
* @return \Doctrine\DBAL\Driver\PDO\Statement
*/
protected function createStatement(PDOStatement $stmt): Statement | true |
Other | laravel | framework | 3ade2155a2af35964ee99f583f0a30d8ce70cb23.json | Add missing params in docblocks | src/Illuminate/Database/Schema/SqliteSchemaState.php | @@ -9,7 +9,7 @@ class SqliteSchemaState extends SchemaState
/**
* Dump the database's schema into a file.
*
- * @param \Illuminate\Database\Connection
+ * @param \Illuminate\Database\Connection $connection
* @param string $path
* @return void
*/ | true |
Other | laravel | framework | 3ade2155a2af35964ee99f583f0a30d8ce70cb23.json | Add missing params in docblocks | src/Illuminate/Foundation/Http/Kernel.php | @@ -459,7 +459,7 @@ public function getApplication()
/**
* Set the Laravel application instance.
*
- * @param \Illuminate\Contracts\Foundation\Application
+ * @param \Illuminate\Contracts\Foundation\Application $app
* @return $this
*/
public function setApplication(Application $app) | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.