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 | a4c781ac40695051b2559d127e3d7595dcc5f904.json | remove stupid test | src/Illuminate/Foundation/helpers.php | @@ -809,34 +809,34 @@ function storage_path($path = '')
/**
* Translate the given message.
*
- * @param string $id
+ * @param string $key
* @param array $replace
* @param string $locale
* @return \Illuminate\Contracts\Translation\Translator|string|array|null
*/
- function trans($id = null, $replace = [], $locale = null)
+ function trans($key = null, $replace = [], $locale = null)
{
- if (is_null($id)) {
+ if (is_null($key)) {
return app('translator');
}
- return app('translator')->trans($id, $replace, $locale);
+ return app('translator')->trans($key, $replace, $locale);
}
}
if (! function_exists('trans_choice')) {
/**
* Translates the given message based on a count.
*
- * @param string $id
+ * @param string $key
* @param int|array|\Countable $number
* @param array $replace
* @param string $locale
* @return string
*/
- function trans_choice($id, $number, array $replace = [], $locale = null)
+ function trans_choice($key, $number, array $replace = [], $locale = null)
{
- return app('translator')->transChoice($id, $number, $replace, $locale);
+ return app('translator')->transChoice($key, $number, $replace, $locale);
}
}
| true |
Other | laravel | framework | a4c781ac40695051b2559d127e3d7595dcc5f904.json | remove stupid test | src/Illuminate/Support/Arr.php | @@ -458,27 +458,35 @@ public static function pull(&$array, $key, $default = null)
}
/**
- * Get a random value from an array.
+ * Get one or a specified number of random values from an array.
*
* @param array $array
- * @param int|null $amount
+ * @param int|null $number
* @return mixed
*
* @throws \InvalidArgumentException
*/
- public static function random($array, $amount = null)
+ public static function random($array, $number = null)
{
- if (($requested = $amount ?: 1) > ($count = count($array))) {
+ $requested = is_null($number) ? 1 : $number;
+
+ $count = count($array);
+
+ if ($requested > $count) {
throw new InvalidArgumentException(
- "You requested {$requested} items, but there are only {$count} items in the array."
+ "You requested {$requested} items, but there are only {$count} items available."
);
}
- if (is_null($amount)) {
+ if (is_null($number)) {
return $array[array_rand($array)];
}
- $keys = array_rand($array, $amount);
+ if ((int) $number === 0) {
+ return [];
+ }
+
+ $keys = array_rand($array, $number);
$results = [];
| true |
Other | laravel | framework | a4c781ac40695051b2559d127e3d7595dcc5f904.json | remove stupid test | src/Illuminate/Support/Collection.php | @@ -86,21 +86,21 @@ public static function unwrap($value)
/**
* Create a new collection by invoking the callback a given amount of times.
*
- * @param int $amount
- * @param callable|null $callback
+ * @param int $number
+ * @param callable $callback
* @return static
*/
- public static function times($amount, callable $callback = null)
+ public static function times($number, callable $callback = null)
{
- if ($amount < 1) {
+ if ($number < 1) {
return new static;
}
if (is_null($callback)) {
- return new static(range(1, $amount));
+ return new static(range(1, $number));
}
- return (new static(range(1, $amount)))->map($callback);
+ return (new static(range(1, $number)))->map($callback);
}
/**
@@ -1144,30 +1144,20 @@ public function put($key, $value)
}
/**
- * Get zero or more items randomly from the collection.
+ * Get one or a specified number of items randomly from the collection.
*
- * @param int|null $amount
+ * @param int|null $number
* @return mixed
*
* @throws \InvalidArgumentException
*/
- public function random($amount = null)
+ public function random($number = null)
{
- if ($amount === 0) {
- return new static;
- }
-
- if (($requested = $amount ?: 1) > ($count = $this->count())) {
- throw new InvalidArgumentException(
- "You requested {$requested} items, but there are only {$count} items in the collection."
- );
- }
-
- if (is_null($amount)) {
+ if (is_null($number)) {
return Arr::random($this->items);
}
- return new static(Arr::random($this->items, $amount));
+ return new static(Arr::random($this->items, $number));
}
/** | true |
Other | laravel | framework | a4c781ac40695051b2559d127e3d7595dcc5f904.json | remove stupid test | src/Illuminate/View/Compilers/Concerns/CompilesEchos.php | @@ -100,6 +100,6 @@ protected function compileEscapedEchos($value)
*/
public function compileEchoDefaults($value)
{
- return preg_replace('/^(?=\$)(.+?)(?:\s+or\s+)(.+?)$/s', 'isset($1) ? $1 : $2', $value);
+ return preg_replace('/^(?=\$)(.+?)(?:\s+or\s+)(.+?)$/si', 'isset($1) ? $1 : $2', $value);
}
} | true |
Other | laravel | framework | a4c781ac40695051b2559d127e3d7595dcc5f904.json | remove stupid test | src/Illuminate/View/Engines/EngineResolver.php | @@ -38,7 +38,7 @@ public function register($engine, Closure $resolver)
}
/**
- * Resolver an engine instance by name.
+ * Resolve an engine instance by name.
*
* @param string $engine
* @return \Illuminate\Contracts\View\Engine | true |
Other | laravel | framework | a4c781ac40695051b2559d127e3d7595dcc5f904.json | remove stupid test | tests/Database/DatabaseConcernsBuildsQueriesTraitTest.php | @@ -0,0 +1,17 @@
+<?php
+
+namespace Illuminate\Tests\Database;
+
+use PHPUnit\Framework\TestCase;
+use Illuminate\Database\Concerns\BuildsQueries;
+
+class DatabaseConcernsBuildsQueriesTraitTest extends TestCase
+{
+ public function testTapCallbackInstance()
+ {
+ $mock = $this->getMockForTrait(BuildsQueries::class);
+ $mock->tap(function ($builder) use ($mock) {
+ $this->assertEquals($mock, $builder);
+ });
+ }
+} | true |
Other | laravel | framework | a4c781ac40695051b2559d127e3d7595dcc5f904.json | remove stupid test | tests/Support/SupportArrTest.php | @@ -421,22 +421,74 @@ public function testPull()
public function testRandom()
{
- $randomValue = Arr::random(['foo', 'bar', 'baz']);
-
- $this->assertContains($randomValue, ['foo', 'bar', 'baz']);
-
- $randomValues = Arr::random(['foo', 'bar', 'baz'], 1);
+ $random = Arr::random(['foo', 'bar', 'baz']);
+ $this->assertContains($random, ['foo', 'bar', 'baz']);
+
+ $random = Arr::random(['foo', 'bar', 'baz'], 0);
+ $this->assertInternalType('array', $random);
+ $this->assertCount(0, $random);
+
+ $random = Arr::random(['foo', 'bar', 'baz'], 1);
+ $this->assertInternalType('array', $random);
+ $this->assertCount(1, $random);
+ $this->assertContains($random[0], ['foo', 'bar', 'baz']);
+
+ $random = Arr::random(['foo', 'bar', 'baz'], 2);
+ $this->assertInternalType('array', $random);
+ $this->assertCount(2, $random);
+ $this->assertContains($random[0], ['foo', 'bar', 'baz']);
+ $this->assertContains($random[1], ['foo', 'bar', 'baz']);
+
+ $random = Arr::random(['foo', 'bar', 'baz'], '0');
+ $this->assertInternalType('array', $random);
+ $this->assertCount(0, $random);
+
+ $random = Arr::random(['foo', 'bar', 'baz'], '1');
+ $this->assertInternalType('array', $random);
+ $this->assertCount(1, $random);
+ $this->assertContains($random[0], ['foo', 'bar', 'baz']);
+
+ $random = Arr::random(['foo', 'bar', 'baz'], '2');
+ $this->assertInternalType('array', $random);
+ $this->assertCount(2, $random);
+ $this->assertContains($random[0], ['foo', 'bar', 'baz']);
+ $this->assertContains($random[1], ['foo', 'bar', 'baz']);
+ }
- $this->assertInternalType('array', $randomValues);
- $this->assertCount(1, $randomValues);
- $this->assertContains($randomValues[0], ['foo', 'bar', 'baz']);
+ public function testRandomOnEmptyArray()
+ {
+ $random = Arr::random([], 0);
+ $this->assertInternalType('array', $random);
+ $this->assertCount(0, $random);
- $randomValues = Arr::random(['foo', 'bar', 'baz'], 2);
+ $random = Arr::random([], '0');
+ $this->assertInternalType('array', $random);
+ $this->assertCount(0, $random);
+ }
- $this->assertInternalType('array', $randomValues);
- $this->assertCount(2, $randomValues);
- $this->assertContains($randomValues[0], ['foo', 'bar', 'baz']);
- $this->assertContains($randomValues[1], ['foo', 'bar', 'baz']);
+ public function testRandomThrowsAnErrorWhenRequestingMoreItemsThanAreAvailable()
+ {
+ $exceptions = 0;
+
+ try {
+ Arr::random([]);
+ } catch (\InvalidArgumentException $e) {
+ ++$exceptions;
+ }
+
+ try {
+ Arr::random([], 1);
+ } catch (\InvalidArgumentException $e) {
+ ++$exceptions;
+ }
+
+ try {
+ Arr::random([], 2);
+ } catch (\InvalidArgumentException $e) {
+ ++$exceptions;
+ }
+
+ $this->assertSame(3, $exceptions);
}
public function testSet() | true |
Other | laravel | framework | a4c781ac40695051b2559d127e3d7595dcc5f904.json | remove stupid test | tests/Support/SupportCollectionTest.php | @@ -922,6 +922,10 @@ public function testRandom()
{
$data = new Collection([1, 2, 3, 4, 5, 6]);
+ $random = $data->random();
+ $this->assertInternalType('integer', $random);
+ $this->assertContains($random, $data->all());
+
$random = $data->random(0);
$this->assertInstanceOf(Collection::class, $random);
$this->assertCount(0, $random);
@@ -930,9 +934,21 @@ public function testRandom()
$this->assertInstanceOf(Collection::class, $random);
$this->assertCount(1, $random);
- $random = $data->random(3);
+ $random = $data->random(2);
+ $this->assertInstanceOf(Collection::class, $random);
+ $this->assertCount(2, $random);
+
+ $random = $data->random('0');
+ $this->assertInstanceOf(Collection::class, $random);
+ $this->assertCount(0, $random);
+
+ $random = $data->random('1');
+ $this->assertInstanceOf(Collection::class, $random);
+ $this->assertCount(1, $random);
+
+ $random = $data->random('2');
$this->assertInstanceOf(Collection::class, $random);
- $this->assertCount(3, $random);
+ $this->assertCount(2, $random);
}
public function testRandomOnEmptyCollection()
@@ -942,23 +958,10 @@ public function testRandomOnEmptyCollection()
$random = $data->random(0);
$this->assertInstanceOf(Collection::class, $random);
$this->assertCount(0, $random);
- }
- public function testRandomWithoutArgument()
- {
- $data = new Collection([1, 2, 3, 4, 5, 6]);
-
- $random = $data->random();
- $this->assertInternalType('integer', $random);
- $this->assertContains($random, $data->all());
- }
-
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testRandomThrowsAnErrorWhenRequestingMoreItemsThanAreAvailable()
- {
- (new Collection)->random();
+ $random = $data->random('0');
+ $this->assertInstanceOf(Collection::class, $random);
+ $this->assertCount(0, $random);
}
public function testTakeLast() | true |
Other | laravel | framework | b8ba38ff9a432ca8be42e2b7581bddb3456300da.json | add assertQueuedTimes method | src/Illuminate/Support/Testing/Fakes/MailFake.php | @@ -86,17 +86,36 @@ public function assertNothingSent()
* Assert if a mailable was queued based on a truth-test callback.
*
* @param string $mailable
- * @param callable|null $callback
+ * @param callable|int|null $callback
* @return void
*/
public function assertQueued($mailable, $callback = null)
{
+ if (is_numeric($callback)) {
+ return $this->assertQueuedTimes($mailable, $callback);
+ }
+
PHPUnit::assertTrue(
$this->queued($mailable, $callback)->count() > 0,
"The expected [{$mailable}] mailable was not queued."
);
}
+ /**
+ * Assert if a mailable was queued a number of times.
+ *
+ * @param string $mailable
+ * @param int $times
+ * @return void
+ */
+ protected function assertQueuedTimes($mailable, $times = 1)
+ {
+ PHPUnit::assertTrue(
+ ($count = $this->queued($mailable)->count()) === $times,
+ "The expected [{$mailable}] mailable was queued {$count} times instead of {$times} times."
+ );
+ }
+
/**
* Determine if a mailable was not queued based on a truth-test callback.
* | false |
Other | laravel | framework | 24ceb0b6b0f8eb61d748ddb746bfb02377ce6c61.json | remove useless import | src/Illuminate/Support/Testing/Fakes/MailFake.php | @@ -2,7 +2,6 @@
namespace Illuminate\Support\Testing\Fakes;
-use InvalidArgumentException;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Contracts\Mail\Mailable;
use PHPUnit\Framework\Assert as PHPUnit; | false |
Other | laravel | framework | 55b9ee34dfbb83576c09b4bb7d1ac286dfa7bd7e.json | add assertPushedTimes and assertSentTimes methods | src/Illuminate/Support/Testing/Fakes/MailFake.php | @@ -30,6 +30,22 @@ public function assertSent($mailable, $callback = null)
);
}
+ /**
+ * Assert if a mailable was sent a number of times based on a truth-test callback.
+ *
+ * @param string $mailable
+ * @param integer $times
+ * @param callable|null $callback
+ * @return void
+ */
+ public function assertSentTimes($mailable, $times = 1, $callback = null)
+ {
+ PHPUnit::assertTrue(
+ ($count = $this->sent($mailable, $callback)->count()) === $times,
+ "The expected [{$mailable}] mailable was sent {$count} times instead of {$times} times."
+ );
+ }
+
/**
* Determine if a mailable was not sent based on a truth-test callback.
* | true |
Other | laravel | framework | 55b9ee34dfbb83576c09b4bb7d1ac286dfa7bd7e.json | add assertPushedTimes and assertSentTimes methods | src/Illuminate/Support/Testing/Fakes/QueueFake.php | @@ -30,6 +30,22 @@ public function assertPushed($job, $callback = null)
);
}
+ /**
+ * Assert if a job was pushed a number of times based on a truth-test callback.
+ *
+ * @param string $job
+ * @param integer $times
+ * @param callable|null $callback
+ * @return void
+ */
+ public function assertPushed($job, $times, $callback = null)
+ {
+ PHPUnit::assertTrue(
+ ($count = $this->pushed($job, $callback)->count()) === $times,
+ "The expected [{$job}] job was pushed {$count} times instead of {$times} times."
+ );
+ }
+
/**
* Assert if a job was pushed based on a truth-test callback.
* | true |
Other | laravel | framework | f0d417bfa7a2e78d70c7382bfc51fe02321f0a3e.json | update v5.4 changelog | CHANGELOG-5.4.md | @@ -1,5 +1,16 @@
# Release Notes for 5.4.x
+## [Unreleased]
+
+### Changed
+- Moved `tap()` method from `Builder` to `BuildsQueries` ([#20384](https://github.com/laravel/framework/pull/20384))
+- Made Blade `or` operator case-insensitive ([#20425](https://github.com/laravel/framework/pull/20425))
+- Support `$amount = 0` in `Arr::random()` ([#20439](https://github.com/laravel/framework/pull/20439))
+
+### Fixed
+- Fixed bug when using empty values in `SQLiteGrammar::compileInsert()` ([#20424](https://github.com/laravel/framework/pull/20424))
+
+
## v5.4.32 (2017-08-03)
### Added | false |
Other | laravel | framework | 442ea4d4dc8f4035da8adb23ee16e3caefee6f68.json | Move loader to Contracts. (#20460) | src/Illuminate/Contracts/Translation/Loader.php | @@ -1,8 +1,8 @@
<?php
-namespace Illuminate\Translation;
+namespace Illuminate\Contracts\Translation;
-interface LoaderInterface
+interface Loader
{
/**
* Load the messages for the given locale. | true |
Other | laravel | framework | 442ea4d4dc8f4035da8adb23ee16e3caefee6f68.json | Move loader to Contracts. (#20460) | src/Illuminate/Translation/ArrayLoader.php | @@ -2,7 +2,9 @@
namespace Illuminate\Translation;
-class ArrayLoader implements LoaderInterface
+use Illuminate\Contracts\Translation\Loader;
+
+class ArrayLoader implements Loader
{
/**
* All of the translation messages. | true |
Other | laravel | framework | 442ea4d4dc8f4035da8adb23ee16e3caefee6f68.json | Move loader to Contracts. (#20460) | src/Illuminate/Translation/FileLoader.php | @@ -3,8 +3,9 @@
namespace Illuminate\Translation;
use Illuminate\Filesystem\Filesystem;
+use Illuminate\Contracts\Translation\Loader;
-class FileLoader implements LoaderInterface
+class FileLoader implements Loader
{
/**
* The filesystem instance. | true |
Other | laravel | framework | 442ea4d4dc8f4035da8adb23ee16e3caefee6f68.json | Move loader to Contracts. (#20460) | src/Illuminate/Translation/Translator.php | @@ -7,6 +7,7 @@
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
use Illuminate\Support\Traits\Macroable;
+use Illuminate\Contracts\Translation\Loader;
use Illuminate\Support\NamespacedItemResolver;
use Illuminate\Contracts\Translation\Translator as TranslatorContract;
@@ -17,7 +18,7 @@ class Translator extends NamespacedItemResolver implements TranslatorContract
/**
* The loader implementation.
*
- * @var \Illuminate\Translation\LoaderInterface
+ * @var \Illuminate\Contracts\Translation\Loader
*/
protected $loader;
@@ -52,11 +53,11 @@ class Translator extends NamespacedItemResolver implements TranslatorContract
/**
* Create a new translator instance.
*
- * @param \Illuminate\Translation\LoaderInterface $loader
+ * @param \Illuminate\Contracts\Translation\Loader $loader
* @param string $locale
* @return void
*/
- public function __construct(LoaderInterface $loader, $locale)
+ public function __construct(Loader $loader, $locale)
{
$this->loader = $loader;
$this->locale = $locale;
@@ -406,7 +407,7 @@ public function setSelector(MessageSelector $selector)
/**
* Get the language line loader implementation.
*
- * @return \Illuminate\Translation\LoaderInterface
+ * @return \Illuminate\Contracts\Translation\Loader
*/
public function getLoader()
{ | true |
Other | laravel | framework | 442ea4d4dc8f4035da8adb23ee16e3caefee6f68.json | Move loader to Contracts. (#20460) | tests/Translation/TranslationTranslatorTest.php | @@ -159,6 +159,6 @@ public function testGetJsonForNonExistingReturnsSameKeyAndReplaces()
protected function getLoader()
{
- return m::mock('Illuminate\Translation\LoaderInterface');
+ return m::mock(\Illuminate\Contracts\Translation\Loader::class);
}
} | true |
Other | laravel | framework | 86b67fa1982736a87a935ef1b33f471ffff5b5e7.json | remove redundant class import | src/Illuminate/Support/Testing/Fakes/MailFake.php | @@ -3,9 +3,8 @@
namespace Illuminate\Support\Testing\Fakes;
use InvalidArgumentException;
-use Illuminate\Contracts\Mail\Mailable;
use Illuminate\Contracts\Mail\Mailer;
-use Illuminate\Contracts\Mail\Mailable as MailableContract;
+use Illuminate\Contracts\Mail\Mailable;
use PHPUnit\Framework\Assert as PHPUnit;
class MailFake implements Mailer
@@ -18,7 +17,7 @@ class MailFake implements Mailer
protected $mailables = [];
/**
- * All of the mailables that have been queued;
+ * All of the mailables that have been queued.
*
* @var array
*/
@@ -247,10 +246,10 @@ public function send($view, array $data = [], $callback = null)
*/
public function queue($view, array $data = [], $callback = null, $queue = null)
{
- if (! $view instanceof MailableContract) {
+ if (! $view instanceof Mailable) {
throw new InvalidArgumentException('Only mailables may be queued.');
}
-
+
$this->queuedMailables[] = $view;
}
| false |
Other | laravel | framework | 1b4762d2f034cb0cad0776cb31535815260639b5.json | implement mail fake queue method | src/Illuminate/Support/Testing/Fakes/MailFake.php | @@ -2,8 +2,10 @@
namespace Illuminate\Support\Testing\Fakes;
-use Illuminate\Contracts\Mail\Mailer;
+use InvalidArgumentException;
use Illuminate\Contracts\Mail\Mailable;
+use Illuminate\Contracts\Mail\Mailer;
+use Illuminate\Mail\MailableContract;
use PHPUnit\Framework\Assert as PHPUnit;
class MailFake implements Mailer
@@ -15,6 +17,12 @@ class MailFake implements Mailer
*/
protected $mailables = [];
+ /**
+ * All of the mailables that have been queued;
+ * @var array
+ */
+ protected $queuedMailables = [];
+
/**
* Assert if a mailable was sent based on a truth-test callback.
*
@@ -55,6 +63,46 @@ public function assertNothingSent()
PHPUnit::assertEmpty($this->mailables, 'Mailables were sent unexpectedly.');
}
+ /**
+ * Assert if a mailable was queued based on a truth-test callback.
+ *
+ * @param string $mailable
+ * @param callable|null $callback
+ * @return void
+ */
+ public function assertQueued($mailable, $callback = null)
+ {
+ PHPUnit::assertTrue(
+ $this->queued($mailable, $callback)->count() > 0,
+ "The expected [{$mailable}] mailable was not queued."
+ );
+ }
+
+ /**
+ * Determine if a mailable was not queued based on a truth-test callback.
+ *
+ * @param string $mailable
+ * @param callable|null $callback
+ * @return void
+ */
+ public function assertNotSent($mailable, $callback = null)
+ {
+ PHPUnit::assertTrue(
+ $this->queued($mailable, $callback)->count() === 0,
+ "The unexpected [{$mailable}] mailable was queued."
+ );
+ }
+
+ /**
+ * Assert that no mailables were queued.
+ *
+ * @return void
+ */
+ public function assertNothingQueued()
+ {
+ PHPUnit::assertEmpty($this->mailables, 'Mailables were queued unexpectedly.');
+ }
+
/**
* Get all of the mailables matching a truth-test callback.
*
@@ -88,15 +136,50 @@ public function hasSent($mailable)
return $this->mailablesOf($mailable)->count() > 0;
}
+ /**
+ * Get all of the queued mailables matching a truth-test callback.
+ *
+ * @param string $mailable
+ * @param callable|null $callback
+ * @return \Illuminate\Support\Collection
+ */
+ public function queued($mailable, $callback = null)
+ {
+ if (! $this->hasQueued($mailable)) {
+ return collect();
+ }
+
+ $callback = $callback ?: function () {
+ return true;
+ };
+
+ return $this->mailablesOf($mailable, true)->filter(function ($mailable) use ($callback) {
+ return $callback($mailable);
+ });
+ }
+
+ /**
+ * Determine if the given mailable has been queued.
+ *
+ * @param string $mailable
+ * @return bool
+ */
+ public function hasQueued($mailable)
+ {
+ return $this->mailablesOf($mailable, true)->count() > 0;
+ }
+
/**
* Get all of the mailed mailables for a given type.
*
* @param string $type
* @return \Illuminate\Support\Collection
*/
- protected function mailablesOf($type)
+ protected function mailablesOf($type, $queued = false)
{
- return collect($this->mailables)->filter(function ($mailable) use ($type) {
+ $mailables = $queued ? $this->queuedMailables : $this->mailables;
+
+ return collect($mailables)->filter(function ($mailable) use ($type) {
return $mailable instanceof $type;
});
}
@@ -163,7 +246,11 @@ public function send($view, array $data = [], $callback = null)
*/
public function queue($view, array $data = [], $callback = null, $queue = null)
{
- $this->send($view);
+ if (! $view instanceof MailableContract) {
+ throw new InvalidArgumentException('Only mailables may be queued.');
+ }
+
+ $this->queuedMailables[] = $view;
}
/** | false |
Other | laravel | framework | 2b676191b1688b8edc9d43317a2989642fe95b5d.json | add new report helper | src/Illuminate/Foundation/helpers.php | @@ -6,6 +6,7 @@
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Foundation\Bus\PendingDispatch;
+use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Contracts\Auth\Factory as AuthFactory;
use Illuminate\Contracts\View\Factory as ViewFactory;
@@ -641,6 +642,19 @@ function redirect($to = null, $status = 302, $headers = [], $secure = null)
}
}
+if (! function_exists('report')) {
+ /**
+ * Report an exception.
+ *
+ * @param \Exception $e
+ * @return void
+ */
+ function report($exception)
+ {
+ app(ExceptionHandler::class)->report($exception);
+ }
+}
+
if (! function_exists('request')) {
/**
* Get an instance of the current request or an input item from the request. | false |
Other | laravel | framework | f20a5ea8d106c8796aa5622e1bb3718b90833fe6.json | Apply fixes from StyleCI (#20401) | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -394,7 +394,7 @@ public function temporaryUrl($path, $expiration, array $options = [])
if (method_exists($adapter, 'getTemporaryUrl')) {
return $adapter->getTemporaryUrl($path, $expiration, $options);
- } else if (! $adapter instanceof AwsS3Adapter) {
+ } elseif (! $adapter instanceof AwsS3Adapter) {
throw new RuntimeException('This driver does not support creating temporary URLs.');
}
| false |
Other | laravel | framework | e0755231de6c1f05720fd763a6e782b3f25d8237.json | Update FilesystemAdapter.php (#20398)
* Update FilesystemAdapter.php
The current implementation does not allow other adapters a chance to implement a `temporaryUrl()` as the `$adapter->getClient()` gets called in first which is not how it works in all cases (in openstack for eg, there is no `getClient()` on the adapter).
This PR allows for this to be possible.
* Fix parameters to the adapter call
* Fix
(I've gotta read sometimes...) | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -392,12 +392,14 @@ public function temporaryUrl($path, $expiration, array $options = [])
{
$adapter = $this->driver->getAdapter();
- $client = $adapter->getClient();
-
- if (! $adapter instanceof AwsS3Adapter) {
+ if (method_exists($adapter, 'getTemporaryUrl')) {
+ return $adapter->getTemporaryUrl($path, $expiration, $options);
+ } else if (! $adapter instanceof AwsS3Adapter) {
throw new RuntimeException('This driver does not support creating temporary URLs.');
}
+ $client = $adapter->getClient();
+
$command = $client->getCommand('GetObject', array_merge([
'Bucket' => $adapter->getBucket(),
'Key' => $adapter->getPathPrefix().$path, | false |
Other | laravel | framework | a7931c396a2545bd4fd2ba2d73d0d8d5fbd16874.json | Fix Route facade docblock (#20397) | src/Illuminate/Support/Facades/Route.php | @@ -3,18 +3,18 @@
namespace Illuminate\Support\Facades;
/**
- * @method static \Illuminate\Routing\Route get(string $uri, \Closure|array|string $action)
- * @method static \Illuminate\Routing\Route post(string $uri, \Closure|array|string $action)
- * @method static \Illuminate\Routing\Route put(string $uri, \Closure|array|string $action)
- * @method static \Illuminate\Routing\Route delete(string $uri, \Closure|array|string $action)
- * @method static \Illuminate\Routing\Route patch(string $uri, \Closure|array|string $action)
- * @method static \Illuminate\Routing\Route options(string $uri, \Closure|array|string $action)
- * @method static \Illuminate\Routing\Route any(string $uri, \Closure|array|string $action)
- * @method static \Illuminate\Routing\Route match(array|string $methods, string $uri, \Closure|array|string $action)
+ * @method static \Illuminate\Routing\Route get(string $uri, \Closure|array|string|null $action = null)
+ * @method static \Illuminate\Routing\Route post(string $uri, \Closure|array|string|null $action = null)
+ * @method static \Illuminate\Routing\Route put(string $uri, \Closure|array|string|null $action = null)
+ * @method static \Illuminate\Routing\Route delete(string $uri, \Closure|array|string|null $action = null)
+ * @method static \Illuminate\Routing\Route patch(string $uri, \Closure|array|string|null $action = null)
+ * @method static \Illuminate\Routing\Route options(string $uri, \Closure|array|string|null $action = null)
+ * @method static \Illuminate\Routing\Route any(string $uri, \Closure|array|string|null $action = null)
+ * @method static \Illuminate\Routing\Route match(array|string $methods, string $uri, \Closure|array|string|null $action = null)
* @method static \Illuminate\Routing\Route prefix(string $prefix)
* @method static void resource(string $name, string $controller, array $options = [])
* @method static void apiResource(string $name, string $controller, array $options = [])
- * @method static void group(array $attributes, \Closure $callback)
+ * @method static void group(array $attributes, \Closure|string $callback)
* @method static \Illuminate\Routing\Route middleware(array|string|null $middleware)
* @method static \Illuminate\Routing\Route substituteBindings(\Illuminate\Routing\Route $route)
* @method static void substituteImplicitBindings(\Illuminate\Routing\Route $route) | false |
Other | laravel | framework | 868d6dc59b5512eddc9bceb9a81abadf1672366b.json | add options argument to temporaryUrl() (#20394)
This allows users to specify additions command arguments such as: `ResponseContentDisposition`. | src/Illuminate/Filesystem/FilesystemAdapter.php | @@ -385,9 +385,10 @@ protected function getLocalUrl($path)
*
* @param string $path
* @param \DateTimeInterface $expiration
+ * @param array $options
* @return string
*/
- public function temporaryUrl($path, $expiration)
+ public function temporaryUrl($path, $expiration, array $options = [])
{
$adapter = $this->driver->getAdapter();
@@ -397,10 +398,10 @@ public function temporaryUrl($path, $expiration)
throw new RuntimeException('This driver does not support creating temporary URLs.');
}
- $command = $client->getCommand('GetObject', [
+ $command = $client->getCommand('GetObject', array_merge([
'Bucket' => $adapter->getBucket(),
'Key' => $adapter->getPathPrefix().$path,
- ]);
+ ], $options));
return (string) $client->createPresignedRequest(
$command, $expiration | false |
Other | laravel | framework | 0d7ca93b5647792c2882b3fc96ad8f3d5cf35f1f.json | Remove useless condition. (#20345) | src/Illuminate/Broadcasting/BroadcastManager.php | @@ -83,9 +83,7 @@ public function socket($request = null)
$request = $request ?: $this->app['request'];
- if ($request->hasHeader('X-Socket-ID')) {
- return $request->header('X-Socket-ID');
- }
+ return $request->header('X-Socket-ID');
}
/** | false |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Database/Query/Builder.php | @@ -536,7 +536,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
// where null clause to the query. So, we will allow a short-cut here to
// that method for convenience so the developer doesn't have to check.
if (is_null($value)) {
- return $this->whereNull($column, $boolean, $operator != '=');
+ return $this->whereNull($column, $boolean, $operator !== '=');
}
// If the column is making a JSON reference we'll check to see if the value
@@ -1265,7 +1265,7 @@ public function dynamicWhere($method, $parameters)
// If the segment is not a boolean connector, we can assume it is a column's name
// and we will add it to the query as a new constraint as a where clause, then
// we can keep iterating through the dynamic method string's segments again.
- if ($segment != 'And' && $segment != 'Or') {
+ if ($segment !== 'And' && $segment !== 'Or') {
$this->addDynamic($segment, $connector, $parameters, $index);
$index++; | true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Database/Schema/SQLiteBuilder.php | @@ -11,7 +11,7 @@ class SQLiteBuilder extends Builder
*/
public function dropAllTables()
{
- if ($this->connection->getDatabaseName() != ':memory:') {
+ if ($this->connection->getDatabaseName() !== ':memory:') {
return $this->refreshDatabaseFile();
}
| true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php | @@ -295,7 +295,7 @@ protected function transformHeadersToServerVars(array $headers)
*/
protected function formatServerHeaderKey($name)
{
- if (! Str::startsWith($name, 'HTTP_') && $name != 'CONTENT_TYPE') {
+ if (! Str::startsWith($name, 'HTTP_') && $name !== 'CONTENT_TYPE') {
return 'HTTP_'.$name;
}
| true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Http/Concerns/InteractsWithInput.php | @@ -331,7 +331,7 @@ public function hasFile($key)
*/
protected function isValidFile($file)
{
- return $file instanceof SplFileInfo && $file->getPath() != '';
+ return $file instanceof SplFileInfo && $file->getPath() !== '';
}
/** | true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Http/Request.php | @@ -172,7 +172,7 @@ public function segments()
$segments = explode('/', $this->decodedPath());
return array_values(array_filter($segments, function ($v) {
- return $v != '';
+ return $v !== '';
}));
}
| true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Pagination/LengthAwarePaginator.php | @@ -47,7 +47,7 @@ public function __construct($items, $total, $perPage, $currentPage = null, array
$this->total = $total;
$this->perPage = $perPage;
$this->lastPage = max((int) ceil($total / $perPage), 1);
- $this->path = $this->path != '/' ? rtrim($this->path, '/') : $this->path;
+ $this->path = $this->path !== '/' ? rtrim($this->path, '/') : $this->path;
$this->currentPage = $this->setCurrentPage($currentPage, $this->pageName);
$this->items = $items instanceof Collection ? $items : Collection::make($items);
} | true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Pagination/Paginator.php | @@ -38,7 +38,7 @@ public function __construct($items, $perPage, $currentPage = null, array $option
$this->perPage = $perPage;
$this->currentPage = $this->setCurrentPage($currentPage);
- $this->path = $this->path != '/' ? rtrim($this->path, '/') : $this->path;
+ $this->path = $this->path !== '/' ? rtrim($this->path, '/') : $this->path;
$this->setItems($items);
} | true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Support/Str.php | @@ -100,7 +100,7 @@ public static function camel($value)
public static function contains($haystack, $needles)
{
foreach ((array) $needles as $needle) {
- if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
+ if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
return true;
}
}
@@ -452,7 +452,7 @@ public static function snake($value, $delimiter = '_')
public static function startsWith($haystack, $needles)
{
foreach ((array) $needles as $needle) {
- if ($needle != '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
+ if ($needle !== '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
return true;
}
} | true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | @@ -917,7 +917,7 @@ public function validateMimes($attribute, $value, $parameters)
return false;
}
- return $value->getPath() != '' && in_array($value->guessExtension(), $parameters);
+ return $value->getPath() !== '' && in_array($value->guessExtension(), $parameters);
}
/**
@@ -934,7 +934,7 @@ public function validateMimetypes($attribute, $value, $parameters)
return false;
}
- return $value->getPath() != '' &&
+ return $value->getPath() !== '' &&
(in_array($value->getMimeType(), $parameters) ||
in_array(explode('/', $value->getMimeType())[0].'/*', $parameters));
}
@@ -1038,7 +1038,7 @@ public function validateRequired($attribute, $value)
} elseif ((is_array($value) || $value instanceof Countable) && count($value) < 1) {
return false;
} elseif ($value instanceof File) {
- return (string) $value->getPath() != '';
+ return (string) $value->getPath() !== '';
}
return true; | true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Validation/DatabasePresenceVerifier.php | @@ -48,7 +48,7 @@ public function getCount($collection, $column, $value, $excludeId = null, $idCol
{
$query = $this->table($collection)->where($column, '=', $value);
- if (! is_null($excludeId) && $excludeId != 'NULL') {
+ if (! is_null($excludeId) && $excludeId !== 'NULL') {
$query->where($idColumn ?: 'id', '<>', $excludeId);
}
| true |
Other | laravel | framework | 54b406891d0e6081e2d766ec25bc64ea0f05f4ba.json | Prefer stricter negative comparisons. (#20346) | src/Illuminate/Validation/ValidationData.php | @@ -82,7 +82,7 @@ public static function extractDataFromPath($attribute, $masterData)
$value = Arr::get($masterData, $attribute, '__missing__');
- if ($value != '__missing__') {
+ if ($value !== '__missing__') {
Arr::set($results, $attribute, $value);
}
| true |
Other | laravel | framework | 9f7d96b8de5e4ed2634e963cff26f0d69ce80705.json | Use proper assertions. (#20343) | tests/Database/DatabaseEloquentIntegrationTest.php | @@ -1118,7 +1118,7 @@ public function testFreshMethodOnModel()
$this->assertInstanceOf(EloquentTestUser::class, $storedUser2);
$this->assertEquals(['id' => 3, 'email' => 'taylorotwell@gmail.com'], $notStoredUser->toArray());
- $this->assertEquals(null, $freshNotStoredUser);
+ $this->assertNull($freshNotStoredUser);
}
public function testFreshMethodOnCollection() | true |
Other | laravel | framework | 9f7d96b8de5e4ed2634e963cff26f0d69ce80705.json | Use proper assertions. (#20343) | tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php | @@ -600,7 +600,7 @@ public function testMorphToWithConstraints()
$q->where('email', 'taylorotwell@gmail.com');
}])->first();
- $this->assertEquals(null, $comment->owner);
+ $this->assertNull($comment->owner);
}
public function testMorphToWithoutConstraints()
@@ -622,7 +622,7 @@ public function testMorphToWithoutConstraints()
$abigail->delete();
$comment = SoftDeletesTestCommentWithTrashed::with('owner')->first();
- $this->assertEquals(null, $comment->owner);
+ $this->assertNull($comment->owner);
}
public function testMorphToNonSoftDeletingModel()
@@ -642,7 +642,7 @@ public function testMorphToNonSoftDeletingModel()
$taylor->delete();
$comment = SoftDeletesTestCommentWithTrashed::with('owner')->first();
- $this->assertEquals(null, $comment->owner);
+ $this->assertNull($comment->owner);
}
/** | true |
Other | laravel | framework | 9f7d96b8de5e4ed2634e963cff26f0d69ce80705.json | Use proper assertions. (#20343) | tests/Support/SupportArrTest.php | @@ -415,7 +415,7 @@ public function testPull()
// Does not work for nested keys
$array = ['emails' => ['joe@example.com' => 'Joe', 'jane@localhost' => 'Jane']];
$name = Arr::pull($array, 'emails.joe@example.com');
- $this->assertEquals(null, $name);
+ $this->assertNull($name);
$this->assertEquals(['emails' => ['joe@example.com' => 'Joe', 'jane@localhost' => 'Jane']], $array);
}
| true |
Other | laravel | framework | 9f7d96b8de5e4ed2634e963cff26f0d69ce80705.json | Use proper assertions. (#20343) | tests/Validation/ValidationValidatorTest.php | @@ -3301,7 +3301,7 @@ public function testValidateImplicitEachWithAsterisksBeforeAndAfter()
public function testGetLeadingExplicitAttributePath()
{
- $this->assertEquals(null, \Illuminate\Validation\ValidationData::getLeadingExplicitAttributePath('*.email'));
+ $this->assertNull(\Illuminate\Validation\ValidationData::getLeadingExplicitAttributePath('*.email'));
$this->assertEquals('foo', \Illuminate\Validation\ValidationData::getLeadingExplicitAttributePath('foo.*'));
$this->assertEquals('foo.bar', \Illuminate\Validation\ValidationData::getLeadingExplicitAttributePath('foo.bar.*.baz'));
$this->assertEquals('foo.bar.1', \Illuminate\Validation\ValidationData::getLeadingExplicitAttributePath('foo.bar.1')); | true |
Other | laravel | framework | 5a649288b9be7ff12256c3042dce0982900137b2.json | Add errors to Validator interface. (#20337) | src/Illuminate/Contracts/Validation/Validator.php | @@ -37,4 +37,11 @@ public function sometimes($attribute, $rules, callable $callback);
* @return $this
*/
public function after($callback);
+
+ /**
+ * Get all of the validation error messages.
+ *
+ * @return array
+ */
+ public function errors();
} | false |
Other | laravel | framework | de438fb381df02ea048daa732fb3773618514ecb.json | Add getStore to Repository interface. (#20338) | src/Illuminate/Contracts/Cache/Repository.php | @@ -115,4 +115,11 @@ public function rememberForever($key, Closure $callback);
* @return bool
*/
public function forget($key);
+
+ /**
+ * Get the cache store implementation.
+ *
+ * @return \Illuminate\Contracts\Cache\Store
+ */
+ public function getStore();
} | false |
Other | laravel | framework | c20de0861c2bbf8c894d510aca29d62220c18cf6.json | Add getMessages to MessageBag interface. (#20334) | src/Illuminate/Contracts/Support/MessageBag.php | @@ -62,6 +62,13 @@ public function get($key, $format = null);
*/
public function all($format = null);
+ /**
+ * Get the raw messages in the container.
+ *
+ * @return array
+ */
+ public function getMessages();
+
/**
* Get the default message format.
* | false |
Other | laravel | framework | 545c30d9158fd79126b3d336a97f4c7a07739fac.json | Add command output to the Finished event. | src/Illuminate/Console/Application.php | @@ -82,7 +82,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
$exitCode = parent::run($input, $output);
$this->events->fire(
- new Events\CommandFinished($commandName, $input, $exitCode)
+ new Events\CommandFinished($commandName, $input, $output, $exitCode)
);
return $exitCode; | true |
Other | laravel | framework | 545c30d9158fd79126b3d336a97f4c7a07739fac.json | Add command output to the Finished event. | src/Illuminate/Console/Events/CommandFinished.php | @@ -3,6 +3,7 @@
namespace Illuminate\Console\Events;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
class CommandFinished
{
@@ -27,18 +28,26 @@ class CommandFinished
*/
public $exitCode;
+ /**
+ * The command output.
+ *
+ * @var \Symfony\Component\Console\Output\OutputInterface
+ */
+ protected $output;
+
/**
* Create a new event instance.
*
* @param string $command
* @param \Symfony\Component\Console\Input\InputInterface $input
+ * @param \Symfony\Component\Console\Output\OutputInterface $output
* @param int $exitCode
- * @return void
*/
- public function __construct($command, InputInterface $input, $exitCode)
+ public function __construct($command, InputInterface $input, OutputInterface $output, $exitCode)
{
$this->command = $command;
$this->input = $input;
+ $this->output = $output;
$this->exitCode = $exitCode;
}
} | true |
Other | laravel | framework | b26a9faacc933f5c56dd1b72cc5e443627317aa4.json | Add console events | src/Illuminate/Console/Application.php | @@ -9,7 +9,9 @@
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Process\PhpExecutableFinder;
+use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\BufferedOutput;
+use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Illuminate\Contracts\Console\Application as ApplicationContract;
@@ -37,6 +39,13 @@ class Application extends SymfonyApplication implements ApplicationContract
*/
protected static $bootstrappers = [];
+ /**
+ * The Event Dispatcher.
+ *
+ * @var \Illuminate\Contracts\Events\Dispatcher
+ */
+ protected $events;
+
/**
* Create a new Artisan console application.
*
@@ -50,14 +59,35 @@ public function __construct(Container $laravel, Dispatcher $events, $version)
parent::__construct('Laravel Framework', $version);
$this->laravel = $laravel;
+ $this->events = $events;
$this->setAutoExit(false);
$this->setCatchExceptions(false);
- $events->dispatch(new Events\ArtisanStarting($this));
+ $this->events->dispatch(new Events\ArtisanStarting($this));
$this->bootstrap();
}
+ /**
+ * {@inheritdoc}
+ */
+ public function run(InputInterface $input = null, OutputInterface $output = null)
+ {
+ $commandName = $this->getCommandName($input);
+
+ $this->events->fire(
+ new Events\CommandStarting($commandName, $input)
+ );
+
+ $exitCode = parent::run($input, $output);
+
+ $this->events->fire(
+ new Events\CommandTerminating($commandName, $input, $exitCode)
+ );
+
+ return $exitCode;
+ }
+
/**
* Determine the proper PHP executable.
* | true |
Other | laravel | framework | b26a9faacc933f5c56dd1b72cc5e443627317aa4.json | Add console events | src/Illuminate/Console/Events/CommandStarting.php | @@ -0,0 +1,35 @@
+<?php
+
+namespace Illuminate\Console\Events;
+
+use Symfony\Component\Console\Input\InputInterface;
+
+class CommandStarting
+{
+ /**
+ * The command name.
+ *
+ * @var string
+ */
+ public $command;
+
+ /**
+ * The console input.
+ *
+ * @var string
+ */
+ public $input;
+
+ /**
+ * Create a new event instance.
+ *
+ * @param string $command
+ * @param \Symfony\Component\Console\Input\InputInterface $input
+ * @return void
+ */
+ public function __construct($command, InputInterface $input)
+ {
+ $this->command = $command;
+ $this->input = $input;
+ }
+} | true |
Other | laravel | framework | b26a9faacc933f5c56dd1b72cc5e443627317aa4.json | Add console events | src/Illuminate/Console/Events/CommandTerminating.php | @@ -0,0 +1,44 @@
+<?php
+
+namespace Illuminate\Console\Events;
+
+use Symfony\Component\Console\Input\InputInterface;
+
+class CommandTerminating
+{
+ /**
+ * The command name.
+ *
+ * @var string
+ */
+ public $command;
+
+ /**
+ * The console input.
+ *
+ * @var string
+ */
+ public $input;
+
+ /**
+ * The command exit code.
+ *
+ * @var int
+ */
+ public $exitCode;
+
+ /**
+ * Create a new event instance.
+ *
+ * @param string $command
+ * @param \Symfony\Component\Console\Input\InputInterface $input
+ * @param int $exitCode
+ * @return void
+ */
+ public function __construct($command, InputInterface $input, $exitCode)
+ {
+ $this->command = $command;
+ $this->input = $input;
+ $this->exitCode = $exitCode;
+ }
+} | true |
Other | laravel | framework | e4108ee1ae35e76fd6dd896c67e4768a1f0e5c63.json | Update WorkCommand.php (#20306) | src/Illuminate/Queue/Console/WorkCommand.php | @@ -45,7 +45,7 @@ class WorkCommand extends Command
protected $worker;
/**
- * Create a new queue listen command.
+ * Create a new queue work command.
*
* @param \Illuminate\Queue\Worker $worker
* @return void | false |
Other | laravel | framework | 94e6a0f38d12c8b9a84e125a102268dd72e8ca15.json | remove factory comment (#20290)
this comment seems like overkill, because it’ll show up in *every*
generated factory.
people can read the docs to learn about factories | src/Illuminate/Database/Console/Factories/stubs/factory.stub | @@ -2,17 +2,6 @@
use Faker\Generator as Faker;
-/*
-|--------------------------------------------------------------------------
-| Model Factories
-|--------------------------------------------------------------------------
-|
-| This directory should contain each of the model factory definitions for
-| your application. Factories provide a convenient way to generate new
-| model instances for testing / seeding your application's database.
-|
-*/
-
$factory->define(DummyModel::class, function (Faker $faker) {
return [
// | false |
Other | laravel | framework | 06dcaaafe3add4a1bd2a41610278fc7f3d8c43df.json | remove unneeded variable | tests/Database/DatabaseSchemaBlueprintTest.php | @@ -79,7 +79,7 @@ public function testDefaultCurrentTimestamp()
public function testUnsignedDecimalTable()
{
$base = new Blueprint('users', function ($table) {
- $table->unsignedDecimal('money', 10, 2, true)->useCurrent();
+ $table->unsignedDecimal('money', 10, 2)->useCurrent();
});
$connection = m::mock('Illuminate\Database\Connection'); | false |
Other | laravel | framework | ef0e37d44182ac5043b5459bb25b1861e8e036df.json | pass request to responsable | src/Illuminate/Contracts/Support/Responsable.php | @@ -7,7 +7,8 @@ interface Responsable
/**
* Create an HTTP response that represents the object.
*
+ * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
- public function toResponse();
+ public function toResponse($request);
} | true |
Other | laravel | framework | ef0e37d44182ac5043b5459bb25b1861e8e036df.json | pass request to responsable | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -168,7 +168,7 @@ public function render($request, Exception $e)
if (method_exists($e, 'render') && $response = $e->render($request)) {
return Router::prepareResponse($request, $response);
} elseif ($e instanceof Responsable) {
- return $e->toResponse();
+ return $e->toResponse($request);
}
$e = $this->prepareException($e); | true |
Other | laravel | framework | ef0e37d44182ac5043b5459bb25b1861e8e036df.json | pass request to responsable | src/Illuminate/Routing/Router.php | @@ -650,7 +650,7 @@ protected function sortMiddleware(Collection $middlewares)
public static function prepareResponse($request, $response)
{
if ($response instanceof Responsable) {
- $response = $response->toResponse();
+ $response = $response->toResponse($request);
}
if ($response instanceof PsrResponseInterface) { | true |
Other | laravel | framework | ef0e37d44182ac5043b5459bb25b1861e8e036df.json | pass request to responsable | tests/Foundation/FoundationExceptionsHandlerTest.php | @@ -128,7 +128,7 @@ public function testReturnsJsonWithoutStackTraceWhenAjaxRequestAndDebugFalseAndA
class CustomException extends Exception implements Responsable
{
- public function toResponse()
+ public function toResponse($request)
{
return response()->json(['response' => 'My custom exception response']);
} | true |
Other | laravel | framework | ef0e37d44182ac5043b5459bb25b1861e8e036df.json | pass request to responsable | tests/Integration/Routing/ResponsableTest.php | @@ -27,7 +27,7 @@ public function test_responsable_objects_are_rendered()
class TestResponsableResponse implements Responsable
{
- public function toResponse()
+ public function toResponse($request)
{
return response('hello world', 201, ['X-Test-Header' => 'Taylor']);
} | true |
Other | laravel | framework | 5f71c09c2a079e865ec8420e2abe52633d57d310.json | Add guest directive (#20257)
* Add guest directive
* Modify endauth | src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub | @@ -42,7 +42,7 @@
<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
- @if (Auth::guest())
+ @guest
<li><a href="{{ route('login') }}">Login</a></li>
<li><a href="{{ route('register') }}">Register</a></li>
@else
@@ -65,7 +65,7 @@
</li>
</ul>
</li>
- @endif
+ @endguest
</ul>
</div>
</div> | false |
Other | laravel | framework | 7f7eb7cd089e72743702e02c278b2bf532d650b6.json | update v5.4 changelog | CHANGELOG-5.4.md | @@ -1,5 +1,17 @@
# Release Notes for 5.4.x
+## [Unreleased]
+
+### Changed
+- Renamed `MakeAuthCommand` to `AuthMakeCommand` ([#20216](https://github.com/laravel/framework/pull/20216))
+- Don't use `asset()` helper inside `mix()` ([#20197](https://github.com/laravel/framework/pull/20197))
+
+### Fixed
+- Make sure `Model::getDates()` returns unique columns ([#20193](https://github.com/laravel/framework/pull/20193))
+- Fixed pulled `doctrine/inflector` version ([#20227](https://github.com/laravel/framework/pull/20227))
+- Fixed issue with `chunkById()` when `orderByRaw()` is used ([#20236](https://github.com/laravel/framework/pull/20236))
+
+
## v5.4.30 (2017-07-19)
### Fixed | false |
Other | laravel | framework | feec50bc19f7861ac9792ccb04bdc9d4d7d46468.json | Apply fixes from StyleCI (#20230) | src/Illuminate/Cache/Repository.php | @@ -17,7 +17,7 @@
use Illuminate\Contracts\Cache\Repository as CacheContract;
/**
- * @mixin \Illuminate\Contracts\Cache\Store
+ * @mixin \Illuminate\Contracts\Cache\Store
*/
class Repository implements CacheContract, ArrayAccess
{ | false |
Other | laravel | framework | 6a69a09f256690c04c3e1b6eb0043ff5501169f7.json | Add test for mix() return value (#20219) | tests/Foundation/FoundationHelpersTest.php | @@ -56,4 +56,25 @@ public function testUnversionedElixir()
unlink(public_path($file));
}
+
+ public function testMixDoesNotIncludeHost()
+ {
+ $file = 'unversioned.css';
+
+ app()->singleton('path.public', function () {
+ return __DIR__;
+ });
+
+ touch(public_path('mix-manifest.json'));
+
+ file_put_contents(public_path('mix-manifest.json'), json_encode([
+ '/unversioned.css' => '/versioned.css',
+ ]));
+
+ $result = mix($file);
+
+ $this->assertEquals('/versioned.css', $result);
+
+ unlink(public_path('mix-manifest.json'));
+ }
} | false |
Other | laravel | framework | f336c75b2c3c8e49e13154c9029d4816fd341639.json | Allow easy ViewFactory override | src/Illuminate/View/ViewServiceProvider.php | @@ -40,7 +40,7 @@ public function registerFactory()
$finder = $app['view.finder'];
- $env = new Factory($resolver, $finder, $app['events']);
+ $env = $this->newFactory($resolver, $finder, $app['events']);
// We will also set the container instance on this view environment since the
// view composers may be classes registered in the container, which allows
@@ -133,4 +133,17 @@ public function registerBladeEngine($resolver)
return new CompilerEngine($this->app['blade.compiler']);
});
}
+
+ /**
+ * Create a new Factory Instance.
+ *
+ * @param EngineResolver $resolver
+ * @param FileViewFinder $finder
+ * @param $events
+ * @return Factory
+ */
+ protected function newFactory($resolver, $finder, $events)
+ {
+ return new Factory($resolver, $finder, $events);
+ }
} | false |
Other | laravel | framework | 785a7582564450e9f963cb6669553914695c7be1.json | Apply fixes from StyleCI (#20199) | src/Illuminate/Console/Scheduling/Event.php | @@ -532,7 +532,7 @@ public function withoutOverlapping()
/**
* Register a callback to further filter the schedule.
*
- * @param \Closure|boolean $callback
+ * @param \Closure|bool $callback
* @return $this
*/
public function when($callback)
@@ -547,7 +547,7 @@ public function when($callback)
/**
* Register a callback to further filter the schedule.
*
- * @param \Closure|boolean $callback
+ * @param \Closure|bool $callback
* @return $this
*/
public function skip($callback) | false |
Other | laravel | framework | 1d1a96e405fec58fd287940f005bd8e40d4e546b.json | allow plain boolean into when and skip | src/Illuminate/Console/Scheduling/Event.php | @@ -532,25 +532,29 @@ public function withoutOverlapping()
/**
* Register a callback to further filter the schedule.
*
- * @param \Closure $callback
+ * @param \Closure|boolean $callback
* @return $this
*/
- public function when(Closure $callback)
+ public function when($callback)
{
- $this->filters[] = $callback;
+ $this->filters[] = is_callable($callback) ? $callback : function () use ($callback) {
+ return $callback;
+ };
return $this;
}
/**
* Register a callback to further filter the schedule.
*
- * @param \Closure $callback
+ * @param \Closure|boolean $callback
* @return $this
*/
- public function skip(Closure $callback)
+ public function skip($callback)
{
- $this->rejects[] = $callback;
+ $this->rejects[] = is_callable($callback) ? $callback : function () use ($callback) {
+ return $callback;
+ };
return $this;
} | true |
Other | laravel | framework | 1d1a96e405fec58fd287940f005bd8e40d4e546b.json | allow plain boolean into when and skip | tests/Console/ConsoleScheduledEventTest.php | @@ -55,6 +55,10 @@ public function testBasicCronCompilation()
return false;
})->filtersPass($app));
+ $event = new Event(m::mock('Illuminate\Console\Scheduling\Mutex'), 'php foo');
+ $this->assertEquals('* * * * * *', $event->getExpression());
+ $this->assertFalse($event->when(false)->filtersPass($app));
+
// chained rules should be commutative
$eventA = new Event(m::mock('Illuminate\Console\Scheduling\Mutex'), 'php foo');
$eventB = new Event(m::mock('Illuminate\Console\Scheduling\Mutex'), 'php foo'); | true |
Other | laravel | framework | 3658477a86175c5537674dc968e580aba823525d.json | Apply fixes from StyleCI (#20192) | tests/Integration/Database/EloquentBelongsToManyTest.php | @@ -3,8 +3,8 @@
namespace Illuminate\Tests\Integration\Database\EloquentBelongsToManyTest;
use Carbon\Carbon;
-use Illuminate\Support\Facades\DB;
use Orchestra\Testbench\TestCase;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Eloquent\Model;
@@ -64,7 +64,6 @@ public function test_can_retrieve_related_ids()
['post_id' => $post->id, 'tag_id' => 400, 'flag' => ''],
]);
-
$this->assertEquals([200, 400], $post->tags()->allRelatedIds()->toArray());
}
| false |
Other | laravel | framework | 11b0de0485632d5712f7fb59071a4acbc4af2bdc.json | add default unauthenticated stub method | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -205,6 +205,20 @@ protected function prepareException(Exception $e)
return $e;
}
+ /**
+ * Convert an authentication exception into a response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Auth\AuthenticationException $exception
+ * @return \Illuminate\Http\Response
+ */
+ protected function unauthenticated($request, AuthenticationException $exception)
+ {
+ return $request->expectsJson()
+ ? response()->json(['message' => 'Unauthenticated.'], 401)
+ : redirect()->guest(route('login'));
+ }
+
/**
* Create a response object from the given validation exception.
* | false |
Other | laravel | framework | be360a77cc4d3d9d49ac1144cb651ee7d038f9a3.json | unify more validation exceptions (#20177)
* unify more validation exceptions
* use given status
* add factory
* Apply fixes from StyleCI (#20178)
* try php 7.0.21
* tweak travis file | .travis.yml | @@ -1,7 +1,7 @@
language: php
php:
- - 7.0
+ - 7.0.21
- 7.1
env:
@@ -11,9 +11,9 @@ env:
matrix:
fast_finish: true
include:
- - php: 7.0
+ - php: 7.0.21
env: setup=lowest
- - php: 7.0
+ - php: 7.0.21
env: setup=stable
- php: 7.1
env: setup=lowest | true |
Other | laravel | framework | be360a77cc4d3d9d49ac1144cb651ee7d038f9a3.json | unify more validation exceptions (#20177)
* unify more validation exceptions
* use given status
* add factory
* Apply fixes from StyleCI (#20178)
* try php 7.0.21
* tweak travis file | src/Illuminate/Foundation/Auth/AuthenticatesUsers.php | @@ -4,6 +4,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
+use Illuminate\Validation\ValidationException;
trait AuthenticatesUsers
{
@@ -124,17 +125,9 @@ protected function authenticated(Request $request, $user)
*/
protected function sendFailedLoginResponse(Request $request)
{
- if ($request->expectsJson()) {
- return response()->json([
- 'message' => 'Authentication failed.', 'errors' => [
- $this->username() => [trans('auth.failed')],
- ],
- ], 422);
- }
-
- return redirect()->back()
- ->withInput($request->only($this->username(), 'remember'))
- ->withErrors([$this->username() => trans('auth.failed')]);
+ throw ValidationException::fromMessages([
+ $this->username() => [trans('auth.failed')],
+ ]);
}
/** | true |
Other | laravel | framework | be360a77cc4d3d9d49ac1144cb651ee7d038f9a3.json | unify more validation exceptions (#20177)
* unify more validation exceptions
* use given status
* add factory
* Apply fixes from StyleCI (#20178)
* try php 7.0.21
* tweak travis file | src/Illuminate/Foundation/Auth/ThrottlesLogins.php | @@ -7,6 +7,7 @@
use Illuminate\Cache\RateLimiter;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Support\Facades\Lang;
+use Illuminate\Validation\ValidationException;
trait ThrottlesLogins
{
@@ -46,17 +47,9 @@ protected function sendLockoutResponse(Request $request)
$this->throttleKey($request)
);
- $message = Lang::get('auth.throttle', ['seconds' => $seconds]);
-
- $errors = [$this->username() => $message];
-
- if ($request->expectsJson()) {
- return response()->json($errors, 423);
- }
-
- return redirect()->back()
- ->withInput($request->only($this->username(), 'remember'))
- ->withErrors($errors);
+ throw ValidationException::fromMessages([
+ $this->username => [Lang::get('auth.throttle', ['seconds' => $seconds])],
+ ])->status(423);
}
/** | true |
Other | laravel | framework | be360a77cc4d3d9d49ac1144cb651ee7d038f9a3.json | unify more validation exceptions (#20177)
* unify more validation exceptions
* use given status
* add factory
* Apply fixes from StyleCI (#20178)
* try php 7.0.21
* tweak travis file | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -254,7 +254,7 @@ protected function invalidJson($request, ValidationException $exception)
return response()->json([
'message' => $exception->getMessage(),
'errors' => $exception->errors(),
- ], 422);
+ ], $exception->status);
}
/** | true |
Other | laravel | framework | be360a77cc4d3d9d49ac1144cb651ee7d038f9a3.json | unify more validation exceptions (#20177)
* unify more validation exceptions
* use given status
* add factory
* Apply fixes from StyleCI (#20178)
* try php 7.0.21
* tweak travis file | src/Illuminate/Routing/Middleware/ThrottleRequests.php | @@ -95,7 +95,9 @@ protected function resolveRequestSignature($request)
return sha1($route->getDomain().'|'.$request->ip());
}
- throw new RuntimeException('Unable to generate the request signature. Route unavailable.');
+ throw new RuntimeException(
+ 'Unable to generate the request signature. Route unavailable.'
+ );
}
/**
@@ -115,7 +117,9 @@ protected function buildException($key, $maxAttempts)
$retryAfter
);
- return new HttpException(429, 'Too Many Attempts.', null, $headers);
+ return new HttpException(
+ 429, 'Too Many Attempts.', null, $headers
+ );
}
/** | true |
Other | laravel | framework | be360a77cc4d3d9d49ac1144cb651ee7d038f9a3.json | unify more validation exceptions (#20177)
* unify more validation exceptions
* use given status
* add factory
* Apply fixes from StyleCI (#20178)
* try php 7.0.21
* tweak travis file | src/Illuminate/Validation/ValidationException.php | @@ -3,6 +3,7 @@
namespace Illuminate\Validation;
use Exception;
+use Illuminate\Support\Facades\Validator as ValidatorFacade;
class ValidationException extends Exception
{
@@ -20,6 +21,13 @@ class ValidationException extends Exception
*/
public $response;
+ /**
+ * The status code to use for the response.
+ *
+ * @var int
+ */
+ public $status = 422;
+
/**
* The name of the error bag.
*
@@ -51,6 +59,23 @@ public function __construct($validator, $response = null, $errorBag = 'default')
$this->validator = $validator;
}
+ /**
+ * Create a new validation exception from a plain array of messages.
+ *
+ * @param array $messages
+ * @return static
+ */
+ public static function fromMessages(array $messages)
+ {
+ return new static(tap(ValidatorFacade::make([], []), function ($validator) use ($messages) {
+ foreach ($messages as $key => $value) {
+ foreach ($value as $message) {
+ $validator->errors()->add($key, $message);
+ }
+ }
+ }));
+ }
+
/**
* Get all of the validation error messages.
*
@@ -61,6 +86,19 @@ public function errors()
return $this->validator->errors()->messages();
}
+ /**
+ * Set the HTTP status code to be used for the response.
+ *
+ * @param int $status
+ * @return $this
+ */
+ public function status($status)
+ {
+ $this->status = $status;
+
+ return $this;
+ }
+
/**
* Set the error bag on the exception.
* | true |
Other | laravel | framework | 0b54f945bafc0185a7959901772cae6c9b36646f.json | Add docblock methods in schema facade (#20172) | src/Illuminate/Support/Facades/Schema.php | @@ -3,6 +3,11 @@
namespace Illuminate\Support\Facades;
/**
+ * @method static \Illuminate\Database\Schema\Builder create(string $table, \Closure $callback)
+ * @method static \Illuminate\Database\Schema\Builder drop(string $table)
+ * @method static \Illuminate\Database\Schema\Builder dropIfExists(string $table)
+ * @method static \Illuminate\Database\Schema\Builder table(string $table, \Closure $callback)
+ *
* @see \Illuminate\Database\Schema\Builder
*/
class Schema extends Facade | false |
Other | laravel | framework | e73fed36f4091ab0c84ef66d217a2d7d45560b61.json | Unify validation exception formatting. (#20173)
* Unify validation exception formatting.
This unifies all validation error formatting into the exception handler
and out of Form Request. “Don’t Flash” is typically a global concept
that always applies to a list of fields for all pages in the
applications, so seemed to make sense to specify in one place instead
of each form.
Total control of the Form Request error response can still be gained by
overriding failedValidation and throwing a HttpResponseException with
whatever response you want.
* Apply fixes from StyleCI (#20174)
* shorten method call
* remove old test
* Apply fixes from StyleCI (#20175) | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -41,7 +41,7 @@ class Handler implements ExceptionHandlerContract
protected $container;
/**
- * A list of the exception types that should not be reported.
+ * A list of the exception types that are not reported.
*
* @var array
*/
@@ -62,6 +62,16 @@ class Handler implements ExceptionHandlerContract
\Illuminate\Validation\ValidationException::class,
];
+ /**
+ * A list of the inputs that are never flashed for validation exceptions.
+ *
+ * @var array
+ */
+ protected $dontFlash = [
+ 'password',
+ 'password_confirmation',
+ ];
+
/**
* Create a new exception handler instance.
*
@@ -222,27 +232,28 @@ protected function convertValidationExceptionToResponse(ValidationException $e,
*/
protected function invalid($request, ValidationException $exception)
{
- return redirect()->back()->withInput($request->except([
- 'password',
- 'password_confirmation',
- ]))->withErrors(
- $exception->validator->errors()->messages(),
- $exception->errorBag
- );
+ $url = $exception->redirectTo ?? url()->previous();
+
+ return redirect($url)
+ ->withInput($request->except($this->dontFlash))
+ ->withErrors(
+ $exception->errors(),
+ $exception->errorBag
+ );
}
/**
* Convert a validation exception into a JSON response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Validation\ValidationException $exception
- * @return \Illuminate\Http\Response
+ * @return \Illuminate\Http\JsonResponse
*/
protected function invalidJson($request, ValidationException $exception)
{
return response()->json([
'message' => $exception->getMessage(),
- 'errors' => $exception->validator->errors()->messages(),
+ 'errors' => $exception->errors(),
], 422);
}
| true |
Other | laravel | framework | e73fed36f4091ab0c84ef66d217a2d7d45560b61.json | Unify validation exception formatting. (#20173)
* Unify validation exception formatting.
This unifies all validation error formatting into the exception handler
and out of Form Request. “Don’t Flash” is typically a global concept
that always applies to a list of fields for all pages in the
applications, so seemed to make sense to specify in one place instead
of each form.
Total control of the Form Request error response can still be gained by
overriding failedValidation and throwing a HttpResponseException with
whatever response you want.
* Apply fixes from StyleCI (#20174)
* shorten method call
* remove old test
* Apply fixes from StyleCI (#20175) | src/Illuminate/Foundation/Http/FormRequest.php | @@ -3,7 +3,6 @@
namespace Illuminate\Foundation\Http;
use Illuminate\Http\Request;
-use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Redirector;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Validation\Validator;
@@ -59,13 +58,6 @@ class FormRequest extends Request implements ValidatesWhenResolved
*/
protected $errorBag = 'default';
- /**
- * The input keys that should not be flashed on redirect.
- *
- * @var array
- */
- protected $dontFlash = ['password', 'password_confirmation'];
-
/**
* Get the validator instance for the request.
*
@@ -122,51 +114,9 @@ protected function validationData()
*/
protected function failedValidation(Validator $validator)
{
- throw new ValidationException($validator, $this->response(
- $this->formatErrors($validator)
- ));
- }
-
- /**
- * Get the proper failed validation response for the request.
- *
- * @param array $errors
- * @return \Symfony\Component\HttpFoundation\Response
- */
- public function response(array $errors)
- {
- if ($this->expectsJson()) {
- return $this->jsonResponse($errors);
- }
-
- return $this->redirector->to($this->getRedirectUrl())
- ->withInput($this->except($this->dontFlash))
- ->withErrors($errors, $this->errorBag);
- }
-
- /**
- * Get the proper failed validation JSON response for the request.
- *
- * @param array $errors
- * @return \Illuminate\Http\JsonResponse
- */
- public function jsonResponse(array $errors)
- {
- return new JsonResponse([
- 'message' => 'The given data was invalid.',
- 'errors' => $errors,
- ], 422);
- }
-
- /**
- * Format the errors from the given Validator instance.
- *
- * @param \Illuminate\Contracts\Validation\Validator $validator
- * @return array
- */
- protected function formatErrors(Validator $validator)
- {
- return $validator->getMessageBag()->toArray();
+ throw (new ValidationException($validator))
+ ->errorBag($this->errorBag)
+ ->redirectTo($this->getRedirectUrl());
}
/** | true |
Other | laravel | framework | e73fed36f4091ab0c84ef66d217a2d7d45560b61.json | Unify validation exception formatting. (#20173)
* Unify validation exception formatting.
This unifies all validation error formatting into the exception handler
and out of Form Request. “Don’t Flash” is typically a global concept
that always applies to a list of fields for all pages in the
applications, so seemed to make sense to specify in one place instead
of each form.
Total control of the Form Request error response can still be gained by
overriding failedValidation and throwing a HttpResponseException with
whatever response you want.
* Apply fixes from StyleCI (#20174)
* shorten method call
* remove old test
* Apply fixes from StyleCI (#20175) | src/Illuminate/Validation/ValidationException.php | @@ -27,6 +27,13 @@ class ValidationException extends Exception
*/
public $errorBag;
+ /**
+ * The path the client should be redirected to.
+ *
+ * @var string
+ */
+ public $redirectTo;
+
/**
* Create a new exception instance.
*
@@ -44,6 +51,42 @@ public function __construct($validator, $response = null, $errorBag = 'default')
$this->validator = $validator;
}
+ /**
+ * Get all of the validation error messages.
+ *
+ * @return array
+ */
+ public function errors()
+ {
+ return $this->validator->errors()->messages();
+ }
+
+ /**
+ * Set the error bag on the exception.
+ *
+ * @param string $errorBag
+ * @return $this
+ */
+ public function errorBag($errorBag)
+ {
+ $this->errorBag = $errorBag;
+
+ return $this;
+ }
+
+ /**
+ * Set the URL to redirect to on a validation error.
+ *
+ * @param string $url
+ * @return string
+ */
+ public function redirectTo($url)
+ {
+ $this->redirectTo = $url;
+
+ return $this;
+ }
+
/**
* Get the underlying response instance.
* | true |
Other | laravel | framework | e73fed36f4091ab0c84ef66d217a2d7d45560b61.json | Unify validation exception formatting. (#20173)
* Unify validation exception formatting.
This unifies all validation error formatting into the exception handler
and out of Form Request. “Don’t Flash” is typically a global concept
that always applies to a list of fields for all pages in the
applications, so seemed to make sense to specify in one place instead
of each form.
Total control of the Form Request error response can still be gained by
overriding failedValidation and throwing a HttpResponseException with
whatever response you want.
* Apply fixes from StyleCI (#20174)
* shorten method call
* remove old test
* Apply fixes from StyleCI (#20175) | tests/Foundation/FoundationFormRequestTest.php | @@ -10,7 +10,6 @@
use Illuminate\Routing\UrlGenerator;
use Illuminate\Http\RedirectResponse;
use Illuminate\Foundation\Http\FormRequest;
-use Illuminate\Validation\ValidationException;
use Illuminate\Contracts\Translation\Translator;
use Illuminate\Validation\Factory as ValidationFactory;
use Illuminate\Contracts\Validation\Factory as ValidationFactoryContract;
@@ -56,24 +55,6 @@ public function test_validate_method_throws_when_authorization_fails()
$this->createRequest([], FoundationTestFormRequestForbiddenStub::class)->validate();
}
- public function test_redirect_response_is_properly_created_with_given_errors()
- {
- $request = $this->createRequest();
-
- $this->mocks['redirect']->shouldReceive('withInput')->andReturnSelf();
-
- $this->mocks['redirect']
- ->shouldReceive('withErrors')
- ->with(['name' => ['error']], 'default')
- ->andReturnSelf();
-
- $e = $this->catchException(ValidationException::class, function () use ($request) {
- $request->validate();
- });
-
- $this->assertInstanceOf(RedirectResponse::class, $e->getResponse());
- }
-
public function test_prepare_for_validation_runs_before_validation()
{
$this->createRequest([], FoundationTestFormRequestHooks::class)->validate(); | true |
Other | laravel | framework | b7e231b99aecb95a26ec89e5fe73346d4fad7fdc.json | fix validation errors | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -209,8 +209,8 @@ protected function convertValidationExceptionToResponse(ValidationException $e,
}
return $request->expectsJson()
- ? $this->invalid($request, $exception)
- : $this->invalidJson($request, $exception);
+ ? $this->invalidJson($request, $e)
+ : $this->invalid($request, $e);
}
/**
@@ -222,8 +222,12 @@ protected function convertValidationExceptionToResponse(ValidationException $e,
*/
protected function invalid($request, ValidationException $exception)
{
- return redirect()->back()->withInput()->withErrors(
- $exception->validator->errors()->messages(), $exception->errorBag
+ return redirect()->back()->withInput($request->except([
+ 'password',
+ 'password_confirmation',
+ ]))->withErrors(
+ $exception->validator->errors()->messages(),
+ $exception->errorBag
);
}
| false |
Other | laravel | framework | 23f0c68b392613587b263b00b64476c9ba8d9dcc.json | Apply fixes from StyleCI (#20170) | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -238,7 +238,7 @@ protected function invalidJson($request, ValidationException $exception)
{
return response()->json([
'message' => $exception->getMessage(),
- 'errors' => $exception->validator->errors()->messages()
+ 'errors' => $exception->validator->errors()->messages(),
], 422);
}
| false |
Other | laravel | framework | c2a7721606a290d54f2f063c1782b1e4fc11a00b.json | remove asset helper (#20165) | src/Illuminate/Foundation/helpers.php | @@ -560,7 +560,7 @@ function mix($path, $manifestDirectory = '')
);
}
- return new HtmlString(asset($manifestDirectory.$manifest[$path]));
+ return new HtmlString($manifestDirectory.$manifest[$path]);
}
}
| false |
Other | laravel | framework | 29ac0866beaf5fdf4946e05ef3d2af930d3a371e.json | remove extra parenthesis | CHANGELOG-5.4.md | @@ -10,7 +10,7 @@
- Added `--force` option to `make:mail`, `make:model` and `make:notification` ([#19932](https://github.com/laravel/framework/pull/19932))
- Added support for PostgreSQL deletes with `USES` clauses ([#20062](https://github.com/laravel/framework/pull/20062), [f94fc02](https://github.com/laravel/framework/commit/f94fc026c64471ca5a5b42919c9b5795021d783c))
- Added support for CC and BBC on mail notifications ([#20093](https://github.com/laravel/framework/pull/20093))
-- Added Blade `@auth` and `@guest` directive ([#20087](https://github.com/laravel/framework/pull/20087), ([#20114](https://github.com/laravel/framework/pull/20114)))
+- Added Blade `@auth` and `@guest` directive ([#20087](https://github.com/laravel/framework/pull/20087), [#20114](https://github.com/laravel/framework/pull/20114))
- Added option to configure MARS on SqlServer connections ([#20113](https://github.com/laravel/framework/pull/20113), [c2c917c](https://github.com/laravel/framework/commit/c2c917c5f773d3df7f59242768f921af95309bcc))
### Changed | false |
Other | laravel | framework | f6bdc032f79e3fc3dcc517b245935aa6cd77642a.json | Apply fixes from StyleCI (#20135) | src/Illuminate/Log/LogServiceProvider.php | @@ -48,7 +48,7 @@ protected function channel()
{
if ($this->app->bound('config') &&
$channel = $this->app->make('config')->get('app.log_channel')) {
- return $channel;
+ return $channel;
}
return $this->app->bound('env') ? $this->app->environment() : 'production'; | false |
Other | laravel | framework | 9fade488f9f427fe140cef4e59f5d6d257fd00bd.json | Remove unused "Closure" class import (#20132) | src/Illuminate/Validation/Validator.php | @@ -2,7 +2,6 @@
namespace Illuminate\Validation;
-use Closure;
use RuntimeException;
use BadMethodCallException;
use Illuminate\Support\Arr; | false |
Other | laravel | framework | 81a0b9f667a288ce6bf2472c9783407367e15ca6.json | Apply fixes from StyleCI (#20128) | src/Illuminate/View/Compilers/Concerns/CompilesConditionals.php | @@ -119,7 +119,7 @@ protected function compileEndAuth()
{
return '<?php endif; ?>';
}
-
+
/**
* Compile the if-guest statements into valid PHP.
* | false |
Other | laravel | framework | 4feb8477bab424da4ff9f34cba7afaed875db42d.json | support no provider | src/Illuminate/Auth/CreatesUserProviders.php | @@ -17,18 +17,17 @@ trait CreatesUserProviders
* Create the user provider implementation for the driver.
*
* @param string|null $provider
- * @return \Illuminate\Contracts\Auth\UserProvider
+ * @return \Illuminate\Contracts\Auth\UserProvider|null
*
* @throws \InvalidArgumentException
*/
public function createUserProvider($provider = null)
{
- $provider = $provider ?: $this->getDefaultUserProvider();
-
- $config = $this->app['config']['auth.providers.'.$provider];
- $driver = $config['driver'] ?? null;
+ if (is_null($config = $this->getProviderConfiguration($provider))) {
+ return;
+ }
- if (isset($this->customProviderCreators[$driver])) {
+ if (isset($this->customProviderCreators[$driver = ($config['driver'] ?? null)])) {
return call_user_func(
$this->customProviderCreators[$driver], $this->app, $config
);
@@ -40,7 +39,22 @@ public function createUserProvider($provider = null)
case 'eloquent':
return $this->createEloquentProvider($config);
default:
- throw new InvalidArgumentException("Authentication user provider [{$driver}] is not defined.");
+ throw new InvalidArgumentException(
+ "Authentication user provider [{$driver}] is not defined."
+ );
+ }
+ }
+
+ /**
+ * Get the user provider configuration.
+ *
+ * @param string|null $provider
+ * @return array|null
+ */
+ protected function getProviderConfiguration($provider)
+ {
+ if ($provider = $provider ?: $this->getDefaultUserProvider()) {
+ return $this->app['config']['auth.providers.'.$provider];
}
}
| false |
Other | laravel | framework | e878807f77bb1cc3b3c428e5d6a6b98b32a6baea.json | Fix doblocks and use Carbon. (#20103) | src/Illuminate/Bus/Queueable.php | @@ -61,7 +61,7 @@ public function onQueue($queue)
/**
* Set the desired delay for the job.
*
- * @param \DateTimeInterface|\Da|int|null $delay
+ * @param \DateTimeInterface|\DateInterval|int|null $delay
* @return $this
*/
public function delay($delay) | true |
Other | laravel | framework | e878807f77bb1cc3b3c428e5d6a6b98b32a6baea.json | Fix doblocks and use Carbon. (#20103) | src/Illuminate/Queue/InteractsWithTime.php | @@ -2,7 +2,6 @@
namespace Illuminate\Queue;
-use DateTime;
use DateInterval;
use DateTimeInterface;
use Illuminate\Support\Carbon;
@@ -12,7 +11,7 @@ trait InteractsWithTime
/**
* Get the number of seconds until the given DateTime.
*
- * @param \DateTimeInterface|\DateInterval $delay
+ * @param \DateTimeInterface|\DateInterval|int $delay
* @return int
*/
protected function secondsUntil($delay)
@@ -43,12 +42,12 @@ protected function availableAt($delay = 0)
* If the given value is an interval, convert it to a DateTime instance.
*
* @param \DateTimeInterface|\DateInterval|int
- * @return \DateTime
+ * @return \DateTimeInterface|int
*/
protected function parseDateInterval($delay)
{
if ($delay instanceof DateInterval) {
- $delay = (new DateTime)->add($delay);
+ $delay = Carbon::now()->add($delay);
}
return $delay; | true |
Other | laravel | framework | 63944bbb8be65c61b5de2c1f43287bbb3af192e1.json | Use json_last_error() (#20099) | src/Illuminate/Encryption/Encrypter.php | @@ -102,7 +102,7 @@ public function encrypt($value, $serialize = true)
$json = json_encode(compact('iv', 'value', 'mac'));
- if (! is_string($json)) {
+ if (json_last_error() !== JSON_ERROR_NONE) {
throw new EncryptException('Could not encrypt the data.');
}
| false |
Other | laravel | framework | 6ce2f5a6bc7046be8cf3813f2f1894ecaf4f4761.json | Add @auth blade component (#20087)
* Add @auth blade component
* Add tests
* cs
* Escape var
* Fix tests | src/Illuminate/View/Compilers/Concerns/CompilesConditionals.php | @@ -98,4 +98,25 @@ protected function compileEndIsset()
{
return '<?php endif; ?>';
}
+
+ /**
+ * Compile the if-auth statements into valid PHP.
+ *
+ * @param string|null $guard
+ * @return string
+ */
+ protected function compileAuth($guard = null)
+ {
+ return "<?php if(auth()->guard({$guard})->check()): ?>";
+ }
+
+ /**
+ * Compile the end-auth statements into valid PHP.
+ *
+ * @return string
+ */
+ protected function compileEndAuth()
+ {
+ return '<?php endif; ?>';
+ }
} | true |
Other | laravel | framework | 6ce2f5a6bc7046be8cf3813f2f1894ecaf4f4761.json | Add @auth blade component (#20087)
* Add @auth blade component
* Add tests
* cs
* Escape var
* Fix tests | tests/View/Blade/BladeIfAuthStatementsTest.php | @@ -0,0 +1,32 @@
+<?php
+
+namespace Illuminate\Tests\Blade;
+
+use Mockery as m;
+use PHPUnit\Framework\TestCase;
+use Illuminate\View\Compilers\BladeCompiler;
+
+class BladeIfAuthStatementsTest extends TestCase
+{
+ public function tearDown()
+ {
+ m::close();
+ }
+
+ public function testIfStatementsAreCompiled()
+ {
+ $compiler = new BladeCompiler($this->getFiles(), __DIR__);
+ $string = '@auth ("api")
+breeze
+@endisset';
+ $expected = '<?php if(auth()->guard("api")->check()): ?>
+breeze
+<?php endif; ?>';
+ $this->assertEquals($expected, $compiler->compileString($string));
+ }
+
+ protected function getFiles()
+ {
+ return m::mock('Illuminate\Filesystem\Filesystem');
+ }
+} | true |
Other | laravel | framework | 72de89c32d3b2ccca51008807d10e698e897d5db.json | Use migrate:fresh in DatabaseMigrations (#20090)
#20089 | src/Illuminate/Foundation/Testing/DatabaseMigrations.php | @@ -13,7 +13,7 @@ trait DatabaseMigrations
*/
public function runDatabaseMigrations()
{
- $this->artisan('migrate');
+ $this->artisan('migrate:fresh');
$this->app[Kernel::class]->setArtisan(null);
| false |
Other | laravel | framework | c80508e7e9b452fdad6577f79d88badb24c9690e.json | Fix visibility of testing helper (#20086)
This `protected` method isn’t used anywhere in the codebase, which seems to indicate it is supposed to be public and called by external code, similarly to the `withoutMiddleware()` method. | src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php | @@ -24,7 +24,7 @@ trait MakesHttpRequests
* @param array $server
* @return $this
*/
- protected function withServerVariables(array $server)
+ public function withServerVariables(array $server)
{
$this->serverVariables = $server;
| false |
Other | laravel | framework | f57b9e23ad4f8552bd5c2c958b9fbed4d2478389.json | Add Collection::wrap method (#20055)
If the given value is not a collection, wrap it in one.
If you pass a collection or an array as the value you get a collection with data in the collection or array back. If you pass in anything else you get a collection of one containing that value. | src/Illuminate/Support/Collection.php | @@ -59,6 +59,19 @@ public static function make($items = [])
return new static($items);
}
+ /**
+ * If the given value is not a collection, wrap it in one.
+ *
+ * @param mixed $value
+ * @return static
+ */
+ public static function wrap($value)
+ {
+ return $value instanceof self
+ ? new static($value)
+ : new static(Arr::wrap($value));
+ }
+
/**
* Create a new collection by invoking the callback a given amount of times.
* | true |
Other | laravel | framework | f57b9e23ad4f8552bd5c2c958b9fbed4d2478389.json | Add Collection::wrap method (#20055)
If the given value is not a collection, wrap it in one.
If you pass a collection or an array as the value you get a collection with data in the collection or array back. If you pass in anything else you get a collection of one containing that value. | tests/Support/SupportCollectionTest.php | @@ -1014,6 +1014,49 @@ public function testMakeMethodFromArray()
$this->assertEquals(['foo' => 'bar'], $collection->all());
}
+ public function testWrapWithScalar()
+ {
+ $collection = Collection::wrap('foo');
+ $this->assertEquals(['foo'], $collection->all());
+ }
+
+ public function testWrapWithArray()
+ {
+ $collection = Collection::wrap(['foo']);
+ $this->assertEquals(['foo'], $collection->all());
+ }
+
+ public function testWrapWithArrayable()
+ {
+ $collection = Collection::wrap($o = new TestArrayableObject);
+ $this->assertEquals([$o], $collection->all());
+ }
+
+ public function testWrapWithJsonable()
+ {
+ $collection = Collection::wrap($o = new TestJsonableObject);
+ $this->assertEquals([$o], $collection->all());
+ }
+
+ public function testWrapWithJsonSerialize()
+ {
+ $collection = Collection::wrap($o = new TestJsonSerializeObject);
+ $this->assertEquals([$o], $collection->all());
+ }
+
+ public function testWrapWithCollectionClass()
+ {
+ $collection = Collection::wrap(Collection::make(['foo']));
+ $this->assertEquals(['foo'], $collection->all());
+ }
+
+ public function testWrapWithCollectionSubclass()
+ {
+ $collection = TestCollectionSubclass::wrap(Collection::make(['foo']));
+ $this->assertEquals(['foo'], $collection->all());
+ $this->assertInstanceOf(TestCollectionSubclass::class, $collection);
+ }
+
public function testTimesMethod()
{
$two = Collection::times(2, function ($number) {
@@ -2287,3 +2330,8 @@ public function __construct($value)
$this->value = $value;
}
}
+
+class TestCollectionSubclass extends Collection
+{
+ //
+} | true |
Other | laravel | framework | 9b41936163a4e7c6e647491ce4d718157cea9a64.json | Return the API resource. (#20029) | src/Illuminate/Routing/Router.php | @@ -297,11 +297,11 @@ public function resource($name, $controller, array $options = [])
* @param string $name
* @param string $controller
* @param array $options
- * @return void
+ * @return \Illuminate\Routing\PendingResourceRegistration
*/
public function apiResource($name, $controller, array $options = [])
{
- $this->resource($name, $controller, array_merge([
+ return $this->resource($name, $controller, array_merge([
'only' => ['index', 'show', 'store', 'update', 'destroy'],
], $options));
} | false |
Other | laravel | framework | ac9f29da4785c8b942ced8c4ab308214d618a22b.json | Update Command.php (#20024) | src/Illuminate/Console/Command.php | @@ -177,9 +177,7 @@ public function run(InputInterface $input, OutputInterface $output)
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $method = method_exists($this, 'handle') ? 'handle' : 'fire';
-
- return $this->laravel->call([$this, $method]);
+ return $this->laravel->call([$this, 'handle']);
}
/** | false |
Other | laravel | framework | e37d48720bea14c3ca4fff7f53bd2273481258ef.json | Retrieve the real original content. (#20002) | src/Illuminate/Http/ResponseTrait.php | @@ -49,7 +49,9 @@ public function content()
*/
public function getOriginalContent()
{
- return $this->original;
+ $original = $this->original;
+
+ return $original instanceof self ? $original->{__FUNCTION__}() : $original;
}
/** | true |
Other | laravel | framework | e37d48720bea14c3ca4fff7f53bd2273481258ef.json | Retrieve the real original content. (#20002) | tests/Http/HttpResponseTest.php | @@ -91,6 +91,14 @@ public function testGetOriginalContent()
$this->assertSame($arr, $response->getOriginalContent());
}
+ public function testGetOriginalContentRetrievesTheFirstOriginalContent()
+ {
+ $previousResponse = new \Illuminate\Http\Response(['foo' => 'bar']);
+ $response = new \Illuminate\Http\Response($previousResponse);
+
+ $this->assertSame(['foo' => 'bar'], $response->getOriginalContent());
+ }
+
public function testSetAndRetrieveStatusCode()
{
$response = new \Illuminate\Http\Response('foo'); | true |
Other | laravel | framework | a9f00e68699001a46c7655dfd35c0fd3dcd5e0e2.json | Apply fixes from StyleCI (#20010) | src/Illuminate/Foundation/Console/EventGenerateCommand.php | @@ -4,7 +4,6 @@
use Illuminate\Support\Str;
use Illuminate\Console\Command;
-use Illuminate\Foundation\Support\Providers\EventServiceProvider;
class EventGenerateCommand extends Command
{ | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.