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 | df87ba5aad0629c47b4a22845081bdf9bfa55d54.json | Remove .php_cs (#20001) | .gitattributes | @@ -5,7 +5,6 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
-.php_cs export-ignore
.travis.yml export-ignore
phpunit.xml.dist export-ignore
CHANGELOG-* export-ignore | true |
Other | laravel | framework | df87ba5aad0629c47b4a22845081bdf9bfa55d54.json | Remove .php_cs (#20001) | .gitignore | @@ -1,7 +1,6 @@
/vendor
composer.phar
composer.lock
-.php_cs.cache
.DS_Store
Thumbs.db
/phpunit.xml | true |
Other | laravel | framework | df87ba5aad0629c47b4a22845081bdf9bfa55d54.json | Remove .php_cs (#20001) | .php_cs | @@ -1,77 +0,0 @@
-<?php
-
-use Symfony\CS\Finder;
-use Symfony\CS\Config\Config;
-use Symfony\CS\FixerInterface;
-
-$fixers = [
- 'blankline_after_open_tag',
- 'braces',
- 'concat_without_spaces',
- 'double_arrow_multiline_whitespaces',
- 'duplicate_semicolon',
- 'elseif',
- 'empty_return',
- 'encoding',
- 'eof_ending',
- 'extra_empty_lines',
- 'function_call_space',
- 'function_declaration',
- 'include',
- 'indentation',
- 'join_function',
- 'line_after_namespace',
- 'linefeed',
- 'list_commas',
- 'logical_not_operators_with_successor_space',
- 'lowercase_constants',
- 'lowercase_keywords',
- 'method_argument_space',
- 'multiline_array_trailing_comma',
- 'multiline_spaces_before_semicolon',
- 'multiple_use',
- 'namespace_no_leading_whitespace',
- 'no_blank_lines_after_class_opening',
- 'no_empty_lines_after_phpdocs',
- 'object_operator',
- 'operators_spaces',
- 'parenthesis',
- 'phpdoc_indent',
- 'phpdoc_inline_tag',
- 'phpdoc_no_access',
- 'phpdoc_no_package',
- 'phpdoc_scalar',
- 'phpdoc_short_description',
- 'phpdoc_to_comment',
- 'phpdoc_trim',
- 'phpdoc_type_to_var',
- 'phpdoc_var_without_name',
- 'remove_leading_slash_use',
- 'remove_lines_between_uses',
- 'return',
- 'self_accessor',
- 'short_array_syntax',
- 'short_echo_tag',
- 'short_tag',
- 'single_array_no_trailing_comma',
- 'single_blank_line_before_namespace',
- 'single_line_after_imports',
- 'single_quote',
- 'spaces_before_semicolon',
- 'spaces_cast',
- 'standardize_not_equal',
- 'ternary_spaces',
- 'trailing_spaces',
- 'trim_array_spaces',
- 'unalign_equals',
- 'unary_operators_spaces',
- 'unused_use',
- 'visibility',
- 'whitespacy_lines',
-];
-
-return Config::create()
- ->finder(Finder::create()->in(__DIR__))
- ->fixers($fixers)
- ->level(FixerInterface::NONE_LEVEL)
- ->setUsingCache(true); | true |
Other | laravel | framework | 247e96b7adb8fb92f32a5420dcf0fbb33e6a2475.json | Apply fixes from StyleCI (#19996) | src/Illuminate/Support/Str.php | @@ -38,7 +38,7 @@ class Str
*/
public static function after($subject, $search)
{
- return $search == "" ? $subject : array_reverse(explode($search, $subject, 2))[0];
+ return $search == '' ? $subject : array_reverse(explode($search, $subject, 2))[0];
}
/**
@@ -72,7 +72,7 @@ public static function ascii($value, $language = 'en')
*/
public static function before($subject, $search)
{
- return $search == "" ? $subject : explode($search, $subject)[0];
+ return $search == '' ? $subject : explode($search, $subject)[0];
}
/** | false |
Other | laravel | framework | 4087ab34e16eb4ba35512b9d2d68ad184b2a0fc5.json | Apply StyleCI fixes | src/Illuminate/Database/Console/Factories/FactoryMakeCommand.php | @@ -76,9 +76,7 @@ protected function getArguments()
{
return [
parent::getArguments()[0],
- ['model', InputArgument::OPTIONAL, 'The name of the model to create']
+ ['model', InputArgument::OPTIONAL, 'The name of the model to create'],
];
}
-
-
} | true |
Other | laravel | framework | 4087ab34e16eb4ba35512b9d2d68ad184b2a0fc5.json | Apply StyleCI fixes | src/Illuminate/Foundation/Console/ModelMakeCommand.php | @@ -69,7 +69,7 @@ protected function createFactory()
{
$this->call('make:factory', [
'name' => $this->argument('name').'Factory',
- 'model' => $this->argument('name')
+ 'model' => $this->argument('name'),
]);
}
| true |
Other | laravel | framework | c21c87defcf412c48c8b0cfe3eb8af89c8132ad5.json | Use single quotes | src/Illuminate/Database/Console/Factories/FactoryMakeCommand.php | @@ -49,7 +49,7 @@ protected function buildClass($name)
$model = $this->qualifyClass($this->argument('name'));
if ($this->argument('model')) {
- $model = $this->qualifyClass($this->argument("model"));
+ $model = $this->qualifyClass($this->argument('model'));
}
return str_replace( | false |
Other | laravel | framework | 948666108a51a906ad6787897e8f957ffbc5f833.json | Fix cache in mix method. (#19968) | src/Illuminate/Foundation/helpers.php | @@ -537,32 +537,30 @@ function mix($path, $manifestDirectory = '')
$manifestDirectory = "/{$manifestDirectory}";
}
- $manifestKey = $manifestDirectory ? $manifestDirectory : '/';
-
if (file_exists(public_path($manifestDirectory.'/hot'))) {
return new HtmlString("//localhost:8080{$path}");
}
- if (in_array($manifestKey, $manifests)) {
- $manifest = $manifests[$manifestKey];
- } else {
- if (! file_exists($manifestPath = public_path($manifestDirectory.'/mix-manifest.json'))) {
+ $manifestPath = public_path($manifestDirectory.'/mix-manifest.json');
+
+ if (! isset($manifests[$manifestPath])) {
+ if (! file_exists($manifestPath)) {
throw new Exception('The Mix manifest does not exist.');
}
- $manifests[$manifestKey] = $manifest = json_decode(
- file_get_contents($manifestPath), true
- );
+ $manifests[$manifestPath] = json_decode(file_get_contents($manifestPath), true);
}
- if (! array_key_exists($path, $manifest)) {
+ $manifest = $manifests[$manifestPath];
+
+ if (! isset($manifest[$path])) {
throw new Exception(
"Unable to locate Mix file: {$path}. Please check your ".
'webpack.mix.js output paths and try again.'
);
}
- return new HtmlString($manifestDirectory.$manifest[$path]);
+ return new HtmlString(asset($manifestDirectory.$manifest[$path]));
}
}
| false |
Other | laravel | framework | 37d429d485b3dc36536e08e0b8b01d7941f73248.json | Add comprovation before replacing the namespace | src/Illuminate/Foundation/Console/PolicyMakeCommand.php | @@ -38,7 +38,7 @@ class PolicyMakeCommand extends GeneratorCommand
protected function buildClass($name)
{
$stub = parent::buildClass($name);
-
+
$stub = $this->replaceUserModelNamespace($stub);
$model = $this->option('model');
@@ -47,14 +47,38 @@ protected function buildClass($name)
}
/**
- * Replace the user model for the given stub.
+ * Replace the user model namespace for the given stub.
*
* @param string $stub
* @return string
*/
protected function replaceUserModelNamespace($stub)
{
- return str_replace($this->rootNamespace().'User', config('auth.providers.users.model'), $stub);
+ if ($this->getDefaultUserNamespace() != $this->getRealUserNamespace()) {
+ return str_replace($this->getDefaultUserNamespace(), $this->getRealUserNamespace(), $stub);
+ }
+
+ return $stub;
+ }
+
+ /**
+ * Get the default namespace for the user model
+ *
+ * @return string
+ */
+ public function getDefaultUserNamespace()
+ {
+ return $this->rootNamespace() . 'User';
+ }
+
+ /**
+ * Get the real namespace for the user model
+ *
+ * @return string
+ */
+ public function getRealUserNamespace()
+ {
+ return config('auth.providers.users.model');
}
/** | false |
Other | laravel | framework | 50a0be8ad3de589bc7be08eae71d31945dacda0f.json | Fix return comment | src/Illuminate/Foundation/Console/PolicyMakeCommand.php | @@ -50,7 +50,7 @@ protected function buildClass($name)
* Replace the user model for the given stub.
*
* @param string $stub
- * @return string mixed
+ * @return string
*/
protected function replaceUserModelNamespace($stub)
{ | false |
Other | laravel | framework | 361992f1578bc1db37936845cdedf58af1047bf9.json | remove temporary variable (#19935)
* remove temporary variable
remove the temporary `$aliases` variable and refactor the array into the `foreach` loop.
is this crazy? unecessary?
I think technically it should be **less memory usage** (much much less), but it's still something
and I don't think we lose readability on it.
curious what people think.
* styleCI fix | src/Illuminate/Foundation/Application.php | @@ -1091,7 +1091,7 @@ public function isLocale($locale)
*/
public function registerCoreContainerAliases()
{
- $aliases = [
+ foreach ([
'app' => [\Illuminate\Foundation\Application::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class],
'auth' => [\Illuminate\Auth\AuthManager::class, \Illuminate\Contracts\Auth\Factory::class],
'auth.driver' => [\Illuminate\Contracts\Auth\Guard::class],
@@ -1126,10 +1126,8 @@ public function registerCoreContainerAliases()
'url' => [\Illuminate\Routing\UrlGenerator::class, \Illuminate\Contracts\Routing\UrlGenerator::class],
'validator' => [\Illuminate\Validation\Factory::class, \Illuminate\Contracts\Validation\Factory::class],
'view' => [\Illuminate\View\Factory::class, \Illuminate\Contracts\View\Factory::class],
- ];
-
- foreach ($aliases as $key => $classes) {
- foreach ($classes as $alias) {
+ ] as $key => $aliases) {
+ foreach ($aliases as $alias) {
$this->alias($key, $alias);
}
} | false |
Other | laravel | framework | 897e48d14860db18c9285187ca6c29e150b9ff30.json | add `force` option to some generators
this will allow the user to continue execution of the command even if the class already exists. | src/Illuminate/Foundation/Console/MailMakeCommand.php | @@ -35,7 +35,7 @@ class MailMakeCommand extends GeneratorCommand
*/
public function fire()
{
- if (parent::fire() === false) {
+ if (parent::fire() === false && !$this->option('force')) {
return;
}
@@ -109,6 +109,8 @@ protected function getOptions()
{
return [
['markdown', 'm', InputOption::VALUE_OPTIONAL, 'Create a new Markdown template for the mailable.'],
+
+ ['force', 'f', InputOption::VALUE_NONE, 'Force the generator to continue execution even if the mail already exists.'],
];
}
} | true |
Other | laravel | framework | 897e48d14860db18c9285187ca6c29e150b9ff30.json | add `force` option to some generators
this will allow the user to continue execution of the command even if the class already exists. | src/Illuminate/Foundation/Console/ModelMakeCommand.php | @@ -36,7 +36,7 @@ class ModelMakeCommand extends GeneratorCommand
*/
public function fire()
{
- if (parent::fire() === false) {
+ if (parent::fire() === false && !$this->option('force')) {
return;
}
@@ -114,7 +114,9 @@ protected function getOptions()
['controller', 'c', InputOption::VALUE_NONE, 'Create a new controller for the model.'],
- ['resource', 'r', InputOption::VALUE_NONE, 'Indicates if the generated controller should be a resource controller'],
+ ['resource', 'r', InputOption::VALUE_NONE, 'Indicates if the generated controller should be a resource controller.'],
+
+ ['force', 'f', InputOption::VALUE_NONE, 'Force the generator to continue execution even if the model already exists.'],
];
}
} | true |
Other | laravel | framework | 897e48d14860db18c9285187ca6c29e150b9ff30.json | add `force` option to some generators
this will allow the user to continue execution of the command even if the class already exists. | src/Illuminate/Foundation/Console/NotificationMakeCommand.php | @@ -35,7 +35,7 @@ class NotificationMakeCommand extends GeneratorCommand
*/
public function fire()
{
- if (parent::fire() === false) {
+ if (parent::fire() === false && !$this->option('force')) {
return;
}
@@ -109,6 +109,8 @@ protected function getOptions()
{
return [
['markdown', 'm', InputOption::VALUE_OPTIONAL, 'Create a new Markdown template for the notification.'],
+
+ ['force', 'f', InputOption::VALUE_NONE, 'Force the generator to continue execution even if the notification already exists.'],
];
}
} | true |
Other | laravel | framework | ec88362ee06ad418db93eb0e19f6d285eed7e701.json | fix status code | src/Illuminate/Foundation/Exceptions/Handler.php | @@ -214,7 +214,7 @@ protected function convertValidationExceptionToResponse(ValidationException $e,
if ($request->expectsJson()) {
return response()->json(
- $this->formatValidationResponse($e)
+ $this->formatValidationResponse($e), 422
);
}
| false |
Other | laravel | framework | 1692b839089a0e5ae65815dd59c82cee9afca9df.json | Add new methods to mailer contract (#19928) | src/Illuminate/Contracts/Mail/Mailer.php | @@ -4,15 +4,77 @@
interface Mailer
{
+ /**
+ * Set the global from address and name.
+ *
+ * @param string $address
+ * @param string|null $name
+ * @return void
+ */
+ public function alwaysFrom($address, $name = null);
+
+ /**
+ * Set the global reply-to address and name.
+ *
+ * @param string $address
+ * @param string|null $name
+ * @return void
+ */
+ public function alwaysReplyTo($address, $name = null);
+
+ /**
+ * Set the global to address and name.
+ *
+ * @param string $address
+ * @param string|null $name
+ * @return void
+ */
+ public function alwaysTo($address, $name = null);
+
+ /**
+ * Begin the process of mailing a mailable class instance.
+ *
+ * @param mixed $users
+ * @return \Illuminate\Mail\PendingMail
+ */
+ public function to($users);
+
+ /**
+ * Begin the process of mailing a mailable class instance.
+ *
+ * @param mixed $users
+ * @return \Illuminate\Mail\PendingMail
+ */
+ public function bcc($users);
+
/**
* Send a new message when only a raw text part.
*
* @param string $text
- * @param \Closure|string $callback
- * @return int
+ * @param mixed $callback
+ * @return void
*/
public function raw($text, $callback);
+ /**
+ * Send a new message when only a plain part.
+ *
+ * @param string $view
+ * @param array $data
+ * @param mixed $callback
+ * @return void
+ */
+ public function plain($view, array $data, $callback);
+
+ /**
+ * Render the given message as a view.
+ *
+ * @param string|array $view
+ * @param array $data
+ * @return \Illuminate\View\View
+ */
+ public function render($view, array $data = []);
+
/**
* Send a new message using a view.
* | false |
Other | laravel | framework | 231119b846aa975988d39707b5d404d36be710f2.json | Apply fixes from StyleCI (#19925) | src/Illuminate/Support/Facades/Storage.php | @@ -34,7 +34,7 @@ public static function fake($disk)
public static function persistentFake($disk)
{
static::set($disk, self::createLocalDriver([
- 'root' => storage_path('framework/testing/disks/' . $disk)
+ 'root' => storage_path('framework/testing/disks/'.$disk),
]));
}
| false |
Other | laravel | framework | e64f5b195626f8e88f2afbd201cc48060ca9cd45.json | Add test for getRoutesByName() (#19913) | tests/Routing/RouteCollectionTest.php | @@ -166,6 +166,30 @@ public function testRouteCollectionCanGetAllRoutes()
$this->assertEquals($allRoutes, $this->routeCollection->getRoutes());
}
+ public function testRouteCollectionCanGetRoutesByName()
+ {
+ $routesByName = [
+ 'foo_index' => new Route('GET', 'foo/index', [
+ 'uses' => 'FooController@index',
+ 'as' => 'foo_index',
+ ]),
+ 'foo_show' => new Route('GET', 'foo/show', [
+ 'uses' => 'FooController@show',
+ 'as' => 'foo_show',
+ ]),
+ 'bar_create' => new Route('POST', 'bar', [
+ 'uses' => 'BarController@create',
+ 'as' => 'bar_create',
+ ]),
+ ];
+
+ $this->routeCollection->add($routesByName['foo_index']);
+ $this->routeCollection->add($routesByName['foo_show']);
+ $this->routeCollection->add($routesByName['bar_create']);
+
+ $this->assertSame($routesByName, $this->routeCollection->getRoutesByName());
+ }
+
public function testRouteCollectionCleansUpOverwrittenRoutes()
{
// Create two routes with the same path and method. | false |
Other | laravel | framework | 01e398030bd894fb5c8996a6a9dd3d60794d1a74.json | Fix minore typo | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | @@ -176,7 +176,7 @@ protected function addCastAttributesToArray(array $attributes, array $mutatedAtt
);
// If the attribute cast was a date or a datetime, we will serialize the date as
- // a string. This allows the developers to customize hwo dates are serialized
+ // a string. This allows the developers to customize how dates are serialized
// into an array without affecting how they are persisted into the storage.
if ($attributes[$key] &&
($value === 'date' || $value === 'datetime')) { | false |
Other | laravel | framework | 45bfce0955372a5c613f305178465937628a1332.json | Return exception instead. | src/Illuminate/Routing/Middleware/ThrottleRequests.php | @@ -38,6 +38,7 @@ public function __construct(RateLimiter $limiter)
* @param int|string $maxAttempts
* @param float|int $decayMinutes
* @return mixed
+ * @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes = 1)
{
@@ -46,7 +47,7 @@ public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes
$maxAttempts = $this->resolveMaxAttempts($request, $maxAttempts);
if ($this->limiter->tooManyAttempts($key, $maxAttempts, $decayMinutes)) {
- $this->buildException($key, $maxAttempts);
+ throw $this->buildException($key, $maxAttempts);
}
$this->limiter->hit($key, $decayMinutes);
@@ -100,8 +101,7 @@ protected function resolveRequestSignature($request)
*
* @param string $key
* @param int $maxAttempts
- * @return void
- * @throws \Symfony\Component\HttpKernel\Exception\HttpException
+ * @return \Symfony\Component\HttpKernel\Exception\HttpException
*/
protected function buildException($key, $maxAttempts)
{
@@ -113,7 +113,7 @@ protected function buildException($key, $maxAttempts)
$retryAfter
);
- throw new HttpException(429, 'Too Many Attempts.', null, $headers);
+ return new HttpException(429, 'Too Many Attempts.', null, $headers);
}
/** | false |
Other | laravel | framework | 990326c988f3b9a844cd6cf47d067bc1dad2173f.json | Throw a 429 HTTP exception. | src/Illuminate/Routing/Middleware/ThrottleRequests.php | @@ -8,6 +8,7 @@
use Illuminate\Support\Carbon;
use Illuminate\Cache\RateLimiter;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\Exception\HttpException;
class ThrottleRequests
{
@@ -45,7 +46,7 @@ public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes
$maxAttempts = $this->resolveMaxAttempts($request, $maxAttempts);
if ($this->limiter->tooManyAttempts($key, $maxAttempts, $decayMinutes)) {
- return $this->buildResponse($key, $maxAttempts);
+ $this->buildException($key, $maxAttempts);
}
$this->limiter->hit($key, $decayMinutes);
@@ -95,23 +96,24 @@ protected function resolveRequestSignature($request)
}
/**
- * Create a 'too many attempts' response.
+ * Create a 'too many attempts' exception.
*
* @param string $key
* @param int $maxAttempts
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return void
+ * @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
- protected function buildResponse($key, $maxAttempts)
+ protected function buildException($key, $maxAttempts)
{
- $response = new Response('Too Many Attempts.', 429);
-
$retryAfter = $this->limiter->availableIn($key);
- return $this->addHeaders(
- $response, $maxAttempts,
+ $headers = $this->getHeaders(
+ $maxAttempts,
$this->calculateRemainingAttempts($key, $maxAttempts, $retryAfter),
$retryAfter
);
+
+ throw new HttpException(429, 'Too Many Attempts.', null, $headers);
}
/**
@@ -124,6 +126,23 @@ protected function buildResponse($key, $maxAttempts)
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function addHeaders(Response $response, $maxAttempts, $remainingAttempts, $retryAfter = null)
+ {
+ $response->headers->add(
+ $this->getHeaders($maxAttempts, $remainingAttempts, $retryAfter)
+ );
+
+ return $response;
+ }
+
+ /**
+ * Get the limit headers information.
+ *
+ * @param int $maxAttempts
+ * @param int $remainingAttempts
+ * @param int|null $retryAfter
+ * @return array
+ */
+ protected function getHeaders($maxAttempts, $remainingAttempts, $retryAfter = null)
{
$headers = [
'X-RateLimit-Limit' => $maxAttempts,
@@ -135,9 +154,7 @@ protected function addHeaders(Response $response, $maxAttempts, $remainingAttemp
$headers['X-RateLimit-Reset'] = Carbon::now()->getTimestamp() + $retryAfter;
}
- $response->headers->add($headers);
-
- return $response;
+ return $headers;
}
/** | false |
Other | laravel | framework | 6623996212b3d59aa31a374b70311f03fd158075.json | extract key generation | src/Illuminate/Encryption/Encrypter.php | @@ -59,6 +59,17 @@ public static function supported($key, $cipher)
($cipher === 'AES-256-CBC' && $length === 32);
}
+ /**
+ * Create a new encryption key for the given cipher.
+ *
+ * @param string $cipher
+ * @return string
+ */
+ public static function generateKey($cipher)
+ {
+ return random_bytes($cipher == 'AES-128-CBC' ? 16 : 32);
+ }
+
/**
* Encrypt the given value.
* | true |
Other | laravel | framework | 6623996212b3d59aa31a374b70311f03fd158075.json | extract key generation | src/Illuminate/Foundation/Console/KeyGenerateCommand.php | @@ -3,6 +3,7 @@
namespace Illuminate\Foundation\Console;
use Illuminate\Console\Command;
+use Illuminate\Encryption\Encrypter;
use Illuminate\Console\ConfirmableTrait;
class KeyGenerateCommand extends Command
@@ -57,9 +58,9 @@ public function handle()
*/
protected function generateRandomKey()
{
- return 'base64:'.base64_encode(random_bytes(
- $this->laravel['config']['app.cipher'] == 'AES-128-CBC' ? 16 : 32
- ));
+ return 'base64:'.base64_encode(
+ Encrypter::generateKey($this->laravel['config']['app.cipher'])
+ );
}
/** | true |
Other | laravel | framework | 72c92621d946ef01e1b4258f0f4b4769f4d58ddd.json | Apply fixes from StyleCI (#19876) | tests/Auth/AuthAccessGateTest.php | @@ -3,7 +3,6 @@
namespace Illuminate\Tests\Auth;
use stdClass;
-use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Illuminate\Auth\Access\Gate;
use Illuminate\Container\Container; | true |
Other | laravel | framework | 72c92621d946ef01e1b4258f0f4b4769f4d58ddd.json | Apply fixes from StyleCI (#19876) | tests/Container/ContainerTest.php | @@ -3,7 +3,6 @@
namespace Illuminate\Tests\Container;
use stdClass;
-use ReflectionException;
use PHPUnit\Framework\TestCase;
use Illuminate\Container\Container;
| true |
Other | laravel | framework | 72c92621d946ef01e1b4258f0f4b4769f4d58ddd.json | Apply fixes from StyleCI (#19876) | tests/Database/DatabaseConnectionFactoryTest.php | @@ -4,7 +4,6 @@
use Mockery as m;
use ReflectionProperty;
-use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Connectors\ConnectionFactory; | true |
Other | laravel | framework | 72c92621d946ef01e1b4258f0f4b4769f4d58ddd.json | Apply fixes from StyleCI (#19876) | tests/Database/DatabaseEloquentModelTest.php | @@ -6,7 +6,6 @@
use stdClass;
use Exception;
use Mockery as m;
-use LogicException;
use ReflectionClass;
use DateTimeImmutable;
use DateTimeInterface; | true |
Other | laravel | framework | 72c92621d946ef01e1b4258f0f4b4769f4d58ddd.json | Apply fixes from StyleCI (#19876) | tests/Http/HttpRedirectResponseTest.php | @@ -3,7 +3,6 @@
namespace Illuminate\Tests\Http;
use Mockery as m;
-use BadMethodCallException;
use Illuminate\Http\Request;
use PHPUnit\Framework\TestCase;
use Illuminate\Http\RedirectResponse; | true |
Other | laravel | framework | 72c92621d946ef01e1b4258f0f4b4769f4d58ddd.json | Apply fixes from StyleCI (#19876) | tests/Routing/RoutingRouteTest.php | @@ -7,7 +7,6 @@
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
-use UnexpectedValueException;
use Illuminate\Routing\Router;
use PHPUnit\Framework\TestCase;
use Illuminate\Events\Dispatcher; | true |
Other | laravel | framework | 72c92621d946ef01e1b4258f0f4b4769f4d58ddd.json | Apply fixes from StyleCI (#19876) | tests/View/ViewEngineResolverTest.php | @@ -3,7 +3,6 @@
namespace Illuminate\Tests\View;
use stdClass;
-use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
class ViewEngineResolverTest extends TestCase | true |
Other | laravel | framework | d29f5eb315b330b0e0be3591f032acf016797b5a.json | Add Macroable trait to Blueprint class (#19862)
* Add Macroable trait to Blueprint class
See https://github.com/laravel/internals/issues/662
* cs
* Update Blueprint.php | src/Illuminate/Database/Schema/Blueprint.php | @@ -5,10 +5,13 @@
use Closure;
use Illuminate\Support\Fluent;
use Illuminate\Database\Connection;
+use Illuminate\Support\Traits\Macroable;
use Illuminate\Database\Schema\Grammars\Grammar;
class Blueprint
{
+ use Macroable;
+
/**
* The table the blueprint describes.
* | false |
Other | laravel | framework | c3c789b35fb0c3673a48dc400dd5cc4688776cb4.json | Allow passing of data to the view | src/Illuminate/Routing/Router.php | @@ -234,12 +234,14 @@ public function redirect($uri, $destination, $status = 301)
*
* @param string $uri
* @param string $view
+ * @param array $data
* @return \Illuminate\Routing\Route
*/
- public function view($uri, $view)
+ public function view($uri, $view, $data = [])
{
return $this->get($uri, '\Illuminate\Routing\ViewController')
- ->defaults('view', $view);
+ ->defaults('view', $view)
+ ->defaults('data', $data);
}
/** | true |
Other | laravel | framework | c3c789b35fb0c3673a48dc400dd5cc4688776cb4.json | Allow passing of data to the view | src/Illuminate/Routing/ViewController.php | @@ -27,10 +27,11 @@ public function __construct(ViewFactory $view)
* Invoke the controller method.
*
* @param string $view
+ * @param array $data
* @return \Illuminate\Contracts\View\View
*/
- public function __invoke($view)
+ public function __invoke($view, $data)
{
- return $this->view->make($view);
+ return $this->view->make($view, $data);
}
} | true |
Other | laravel | framework | c3c789b35fb0c3673a48dc400dd5cc4688776cb4.json | Allow passing of data to the view | tests/Routing/RoutingRouteTest.php | @@ -1384,7 +1384,7 @@ public function testRouteView()
{
$container = new Container;
$factory = m::mock('Illuminate\View\Factory');
- $factory->shouldReceive('make')->once()->with('pages.contact')->andReturn('Contact us');
+ $factory->shouldReceive('make')->once()->with('pages.contact', ['foo' => 'bar'])->andReturn('Contact us');
$router = new Router(new Dispatcher, $container);
$container->bind(ViewFactory::class, function () use ($factory) {
return $factory;
@@ -1393,7 +1393,7 @@ public function testRouteView()
return $router;
});
- $router->view('contact', 'pages.contact');
+ $router->view('contact', 'pages.contact', ['foo' => 'bar']);
$this->assertEquals('Contact us', $router->dispatch(Request::create('contact', 'GET'))->getContent());
} | true |
Other | laravel | framework | 57faddf069d2a47f5774ae107c457388db1fd17f.json | Apply fixes from StyleCI (#19852) | tests/Support/SupportCollectionTest.php | @@ -313,17 +313,19 @@ public function testHigherOrderFilter()
new class {
public $name = 'Alex';
- public function active() {
+ public function active()
+ {
return true;
}
},
new class {
public $name = 'John';
- public function active() {
+ public function active()
+ {
return false;
}
- }
+ },
]);
$this->assertCount(1, $c->filter->active()); | false |
Other | laravel | framework | 5b65863336fe08e3bbdf5a00336530d9d6304094.json | Call parent::handle command (#19839) | src/Illuminate/Database/Console/Seeds/SeederMakeCommand.php | @@ -57,7 +57,7 @@ public function __construct(Filesystem $files, Composer $composer)
*/
public function handle()
{
- parent::fire();
+ parent::handle();
$this->composer->dumpAutoloads();
} | true |
Other | laravel | framework | 5b65863336fe08e3bbdf5a00336530d9d6304094.json | Call parent::handle command (#19839) | src/Illuminate/Foundation/Console/ListenerMakeCommand.php | @@ -40,7 +40,7 @@ public function handle()
return $this->error('Missing required option: --event');
}
- parent::fire();
+ parent::handle();
}
/** | true |
Other | laravel | framework | 5b65863336fe08e3bbdf5a00336530d9d6304094.json | Call parent::handle command (#19839) | src/Illuminate/Foundation/Console/MailMakeCommand.php | @@ -35,7 +35,7 @@ class MailMakeCommand extends GeneratorCommand
*/
public function handle()
{
- if (parent::fire() === false) {
+ if (parent::handle() === false) {
return;
}
| true |
Other | laravel | framework | 5b65863336fe08e3bbdf5a00336530d9d6304094.json | Call parent::handle command (#19839) | src/Illuminate/Foundation/Console/ModelMakeCommand.php | @@ -36,7 +36,7 @@ class ModelMakeCommand extends GeneratorCommand
*/
public function handle()
{
- if (parent::fire() === false) {
+ if (parent::handle() === false) {
return;
}
| true |
Other | laravel | framework | 5b65863336fe08e3bbdf5a00336530d9d6304094.json | Call parent::handle command (#19839) | src/Illuminate/Foundation/Console/NotificationMakeCommand.php | @@ -35,7 +35,7 @@ class NotificationMakeCommand extends GeneratorCommand
*/
public function handle()
{
- if (parent::fire() === false) {
+ if (parent::handle() === false) {
return;
}
| true |
Other | laravel | framework | 8af5a280bc9dc0450adde93a6399c006b8fa5386.json | Apply fixes from StyleCI (#19836) | src/Illuminate/Console/Scheduling/CallbackEvent.php | @@ -101,7 +101,7 @@ public function withoutOverlapping()
"A scheduled event name is required to prevent overlapping. Use the 'name' method before 'withoutOverlapping'."
);
}
-
+
$this->withoutOverlapping = true;
return $this->skip(function () { | false |
Other | laravel | framework | 1d6ad39f84b5fa677b049e68b86ddbd12cf674eb.json | Add Route::view() helper | src/Illuminate/Routing/Router.php | @@ -229,6 +229,19 @@ public function redirect($uri, $destination, $status = 301)
->defaults('status', $status);
}
+ /**
+ * Register a new route that returns a view.
+ *
+ * @param string $uri
+ * @param string $view
+ * @return \Illuminate\Routing\Route
+ */
+ public function view($uri, $view)
+ {
+ return $this->get($uri, '\Illuminate\Routing\ViewController')
+ ->defaults('view', $view);
+ }
+
/**
* Register a new route with the given verbs.
* | true |
Other | laravel | framework | 1d6ad39f84b5fa677b049e68b86ddbd12cf674eb.json | Add Route::view() helper | src/Illuminate/Routing/ViewController.php | @@ -0,0 +1,36 @@
+<?php
+
+namespace Illuminate\Routing;
+
+use Illuminate\Contracts\View\Factory as ViewFactory;
+
+class ViewController extends Controller
+{
+ /**
+ * The view factory instance.
+ *
+ * @var \Illuminate\Contracts\View\Factory
+ */
+ protected $view;
+
+ /**
+ * Create a new view controller instance.
+ *
+ * @param \Illuminate\Contracts\View\Factory $view
+ */
+ public function __construct(ViewFactory $view)
+ {
+ $this->view = $view;
+ }
+
+ /**
+ * Invoke the controller method.
+ *
+ * @param string $view
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function __invoke($view)
+ {
+ return $this->view->make($view);
+ }
+} | true |
Other | laravel | framework | 1d6ad39f84b5fa677b049e68b86ddbd12cf674eb.json | Add Route::view() helper | tests/Routing/RoutingRouteTest.php | @@ -3,6 +3,7 @@
namespace Illuminate\Tests\Routing;
use stdClass;
+use Mockery as m;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
@@ -19,6 +20,7 @@
use Illuminate\Contracts\Routing\Registrar;
use Illuminate\Auth\Middleware\Authenticate;
use Symfony\Component\HttpFoundation\Response;
+use Illuminate\Contracts\View\Factory as ViewFactory;
use Illuminate\Routing\Middleware\SubstituteBindings;
class RoutingRouteTest extends TestCase
@@ -1378,6 +1380,24 @@ public function testRouteRedirect()
$this->assertEquals(302, $response->getStatusCode());
}
+ public function testRouteView()
+ {
+ $container = new Container;
+ $factory = m::mock('Illuminate\View\Factory');
+ $factory->shouldReceive('make')->once()->with('pages.contact')->andReturn('Contact us');
+ $router = new Router(new Dispatcher, $container);
+ $container->bind(ViewFactory::class, function () use ($factory) {
+ return $factory;
+ });
+ $container->singleton(Registrar::class, function () use ($router) {
+ return $router;
+ });
+
+ $router->view('contact', 'pages.contact');
+
+ $this->assertEquals('Contact us', $router->dispatch(Request::create('contact', 'GET'))->getContent());
+ }
+
protected function getRouter()
{
$container = new Container; | true |
Other | laravel | framework | 21cc812403d343f46dc6ebe34b12a98fa99a7246.json | Use proper assertions. (#19831) | tests/Container/ContainerTest.php | @@ -974,7 +974,7 @@ public function testContainerKnowsEntry()
{
$container = new Container;
$container->bind('Illuminate\Tests\Container\IContainerContractStub', 'Illuminate\Tests\Container\ContainerImplementationStub');
- $this->assertEquals(true, $container->has('Illuminate\Tests\Container\IContainerContractStub'));
+ $this->assertTrue($container->has('Illuminate\Tests\Container\IContainerContractStub'));
}
public function testContainerCanBindAnyWord() | false |
Other | laravel | framework | 67dca8689cf5cfc85e0a2a95432f2249c9ef96d4.json | Reuse Arr::random() in Collection::random() | src/Illuminate/Support/Collection.php | @@ -1083,15 +1083,11 @@ public function random($amount = 1)
throw new InvalidArgumentException("You requested {$amount} items, but there are only {$count} items in the collection.");
}
- $keys = array_rand($this->items, $amount);
-
if (count(func_get_args()) == 0) {
- return $this->items[$keys];
+ return Arr::random($this->items);
}
- $keys = array_wrap($keys);
-
- return new static(array_intersect_key($this->items, array_flip($keys)));
+ return new static(Arr::random($this->items, $amount));
}
/** | false |
Other | laravel | framework | 66325c2c5768a5b10376e1838288c5212e3c9c40.json | add container alias | src/Illuminate/Foundation/Application.php | @@ -1095,7 +1095,7 @@ public function isLocale($locale)
public function registerCoreContainerAliases()
{
$aliases = [
- 'app' => [\Illuminate\Foundation\Application::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class],
+ 'app' => [\Illuminate\Foundation\Application::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
'auth' => [\Illuminate\Auth\AuthManager::class, \Illuminate\Contracts\Auth\Factory::class],
'auth.driver' => [\Illuminate\Contracts\Auth\Guard::class],
'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class], | false |
Other | laravel | framework | 294eac84b5d268fd39004a46037c0a2d2623ba97.json | Apply fixes from StyleCI (#19809) | src/Illuminate/Database/Query/Grammars/PostgresGrammar.php | @@ -66,7 +66,7 @@ protected function compileLock(Builder $query, $value)
}
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
public function compileInsert(Builder $query, array $values)
{ | false |
Other | laravel | framework | 4cfbd5716115ec2e6497302badb34f581f8dc4d7.json | Apply fixes from StyleCI (#19808) | src/Illuminate/Database/Query/Grammars/PostgresGrammar.php | @@ -66,7 +66,7 @@ protected function compileLock(Builder $query, $value)
}
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
public function compileInsert(Builder $query, array $values)
{ | false |
Other | laravel | framework | 55bee118c323c7b1deec8da081eafd2e649cbd41.json | Add Route::redirect() helper method | src/Illuminate/Routing/RedirectController.php | @@ -0,0 +1,13 @@
+<?php
+
+namespace Illuminate\Routing;
+
+use Illuminate\Http\RedirectResponse;
+
+class RedirectController extends Controller
+{
+ public function __invoke($destination, $status = 301)
+ {
+ return new RedirectResponse($destination, $status);
+ }
+} | true |
Other | laravel | framework | 55bee118c323c7b1deec8da081eafd2e649cbd41.json | Add Route::redirect() helper method | src/Illuminate/Routing/Router.php | @@ -295,6 +295,21 @@ public function group(array $attributes, $routes)
array_pop($this->groupStack);
}
+ /**
+ * Create a redirect from one route to another.
+ *
+ * @param string $url
+ * @param string $destination
+ * @param int $status
+ * @return Route
+ */
+ public function redirect($url, $destination, $status = 301)
+ {
+ return $this->any($url, '\Illuminate\Routing\RedirectController')
+ ->defaults('destination', $destination)
+ ->defaults('status', $status);
+ }
+
/**
* Update the group stack with the given attributes.
* | true |
Other | laravel | framework | 55bee118c323c7b1deec8da081eafd2e649cbd41.json | Add Route::redirect() helper method | tests/Routing/RoutingRouteTest.php | @@ -1365,6 +1365,19 @@ public function testJsonResponseIsReturned()
$this->assertInstanceOf(\Illuminate\Http\JsonResponse::class, $response);
}
+ public function testRouteRedirect()
+ {
+ $router = $this->getRouter();
+ $router->get('contact_us', function () {
+ throw new \Exception('Route should not be reachable.');
+ });
+ $router->redirect('contact_us', 'contact', 302);
+
+ $response = $router->dispatch(Request::create('contact_us', 'GET'));
+ $this->assertTrue($response->isRedirect('contact'));
+ $this->assertEquals(302, $response->getStatusCode());
+ }
+
protected function getRouter()
{
$container = new Container; | true |
Other | laravel | framework | bceded6fef79760b9907dbe105829f7d2d62f899.json | allow silent deletion on failed model retrieval | src/Illuminate/Queue/CallQueuedHandler.php | @@ -2,6 +2,8 @@
namespace Illuminate\Queue;
+use Exception;
+use ReflectionClass;
use Illuminate\Contracts\Queue\Job;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Database\Eloquent\ModelNotFoundException;
@@ -40,9 +42,7 @@ public function call(Job $job, array $data)
$job, unserialize($data['command'])
);
} catch (ModelNotFoundException $e) {
- return FailingJob::handle(
- $job->getConnectionName(), $job, $e
- );
+ return $this->handleModelNotFound($job, $e);
}
$this->dispatcher->dispatchNow(
@@ -105,6 +105,33 @@ protected function ensureNextJobInChainIsDispatched($command)
}
}
+ /**
+ * Handle a model not found exception.
+ *
+ * @param \Illuminate\Contracts\Queue\Job $job
+ * @param \Exception $e
+ * @return void
+ */
+ protected function handleModelNotFound(Job $job, $e)
+ {
+ $class = $job->resolveName();
+
+ try {
+ $shouldDelete = (new ReflectionClass($class))
+ ->getDefaultProperties()['deleteWhenMissingModels'] ?? false;
+ } catch (Exception $e) {
+ $shouldDelete = false;
+ }
+
+ if ($shouldDelete) {
+ return $job->delete();
+ }
+
+ return FailingJob::handle(
+ $job->getConnectionName(), $job, $e
+ );
+ }
+
/**
* Call the failed method on the job instance.
* | true |
Other | laravel | framework | bceded6fef79760b9907dbe105829f7d2d62f899.json | allow silent deletion on failed model retrieval | tests/Integration/Queue/CallQueuedHandlerTest.php | @@ -37,6 +37,7 @@ public function test_job_is_marked_as_failed_if_model_not_found_exception_is_thr
$job = Mockery::mock('Illuminate\Contracts\Queue\Job');
$job->shouldReceive('getConnectionName')->andReturn('connection');
+ $job->shouldReceive('resolveName')->andReturn(__CLASS__);
$job->shouldReceive('markAsFailed')->once();
$job->shouldReceive('isDeleted')->andReturn(false);
$job->shouldReceive('delete')->once();
@@ -48,6 +49,27 @@ public function test_job_is_marked_as_failed_if_model_not_found_exception_is_thr
Event::assertDispatched(JobFailed::class);
}
+
+ public function test_job_is_deleted_if_has_delete_property()
+ {
+ Event::fake();
+
+ $instance = new Illuminate\Queue\CallQueuedHandler(new Illuminate\Bus\Dispatcher(app()));
+
+ $job = Mockery::mock('Illuminate\Contracts\Queue\Job');
+ $job->shouldReceive('getConnectionName')->andReturn('connection');
+ $job->shouldReceive('resolveName')->andReturn(CallQueuedHandlerExceptionThrower::class);
+ $job->shouldReceive('markAsFailed')->never();
+ $job->shouldReceive('isDeleted')->andReturn(false);
+ $job->shouldReceive('delete')->once();
+ $job->shouldReceive('failed')->never();
+
+ $instance->call($job, [
+ 'command' => serialize(new CallQueuedHandlerExceptionThrower),
+ ]);
+
+ Event::assertNotDispatched(JobFailed::class);
+ }
}
class CallQueuedHandlerTestJob
@@ -64,6 +86,8 @@ public function handle()
class CallQueuedHandlerExceptionThrower
{
+ public $deleteWhenMissingModels = true;
+
public function handle()
{
// | true |
Other | laravel | framework | 5b4b02e9d9494b91fece6b6cc29bb50edca5ee2a.json | Apply fixes from StyleCI (#19789) | src/Illuminate/Foundation/Auth/ThrottlesLogins.php | @@ -109,7 +109,7 @@ protected function limiter()
*/
public function maxAttempts()
{
- return property_exists($this,'maxAttempts') ? $this->maxAttempts : 5;
+ return property_exists($this, 'maxAttempts') ? $this->maxAttempts : 5;
}
/**
@@ -119,6 +119,6 @@ public function maxAttempts()
*/
public function decayMinutes()
{
- return property_exists($this,'decayMinutes') ? $this->decayMinutes : 1;
+ return property_exists($this, 'decayMinutes') ? $this->decayMinutes : 1;
}
} | false |
Other | laravel | framework | ff00aa9e02634b94ec2b6572a3dcdb90d4349071.json | Add withDefault to MorphOne relations. | src/Illuminate/Database/Eloquent/Relations/BelongsTo.php | @@ -5,17 +5,11 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Database\Eloquent\Relations\Concerns\HasDefault;
class BelongsTo extends Relation
{
- /**
- * Indicates if a default model instance should be used.
- *
- * Alternatively, may be a Closure or array.
- *
- * @var \Closure|array|bool
- */
- protected $withDefault;
+ use HasDefault;
/**
* The child model instance of the relation.
@@ -164,31 +158,6 @@ public function initRelation(array $models, $relation)
return $models;
}
- /**
- * Get the default value for this relation.
- *
- * @param \Illuminate\Database\Eloquent\Model $model
- * @return \Illuminate\Database\Eloquent\Model|null
- */
- protected function getDefaultFor(Model $model)
- {
- if (! $this->withDefault) {
- return;
- }
-
- $instance = $this->related->newInstance();
-
- if (is_callable($this->withDefault)) {
- return call_user_func($this->withDefault, $instance) ?: $instance;
- }
-
- if (is_array($this->withDefault)) {
- $instance->forceFill($this->withDefault);
- }
-
- return $instance;
- }
-
/**
* Match the eagerly loaded results to their parents.
*
@@ -327,19 +296,6 @@ protected function relationHasIncrementingId()
$this->related->getKeyType() === 'int';
}
- /**
- * Return a new model instance in case the relationship does not exist.
- *
- * @param \Closure|array|bool $callback
- * @return $this
- */
- public function withDefault($callback = true)
- {
- $this->withDefault = $callback;
-
- return $this;
- }
-
/**
* Get the foreign key of the relationship.
*
@@ -389,4 +345,15 @@ public function getRelation()
{
return $this->relation;
}
+
+ /**
+ * Make a new related instance for the given model.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @return \Illuminate\Database\Eloquent\Model
+ */
+ protected function newRelatedInstanceFor(Model $parent)
+ {
+ return $this->related->newInstance();
+ }
} | true |
Other | laravel | framework | ff00aa9e02634b94ec2b6572a3dcdb90d4349071.json | Add withDefault to MorphOne relations. | src/Illuminate/Database/Eloquent/Relations/Concerns/HasDefault.php | @@ -0,0 +1,63 @@
+<?php
+
+namespace Illuminate\Database\Eloquent\Relations\Concerns;
+
+use Illuminate\Database\Eloquent\Model;
+
+trait HasDefault
+{
+ /**
+ * Indicates if a default model instance should be used.
+ *
+ * Alternatively, may be a Closure or array.
+ *
+ * @var \Closure|array|bool
+ */
+ protected $withDefault;
+
+ /**
+ * Return a new model instance in case the relationship does not exist.
+ *
+ * @param \Closure|array|bool $callback
+ * @return $this
+ */
+ public function withDefault($callback = true)
+ {
+ $this->withDefault = $callback;
+
+ return $this;
+ }
+
+ /**
+ * Get the default value for this relation.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @return \Illuminate\Database\Eloquent\Model|null
+ */
+ protected function getDefaultFor(Model $parent)
+ {
+ if (! $this->withDefault) {
+ return;
+ }
+
+ $instance = $this->newRelatedInstanceFor($parent);
+
+ if (is_callable($this->withDefault)) {
+ return call_user_func($this->withDefault, $instance) ?: $instance;
+ }
+
+ if (is_array($this->withDefault)) {
+ $instance->forceFill($this->withDefault);
+ }
+
+ return $instance;
+ }
+
+ /**
+ * Make a new related instance for the given model.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @return \Illuminate\Database\Eloquent\Model
+ */
+ abstract protected function newRelatedInstanceFor(Model $parent);
+} | true |
Other | laravel | framework | ff00aa9e02634b94ec2b6572a3dcdb90d4349071.json | Add withDefault to MorphOne relations. | src/Illuminate/Database/Eloquent/Relations/HasOne.php | @@ -4,17 +4,11 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Database\Eloquent\Relations\Concerns\HasDefault;
class HasOne extends HasOneOrMany
{
- /**
- * Indicates if a default model instance should be used.
- *
- * Alternatively, may be a Closure or array.
- *
- * @var \Closure|array|bool
- */
- protected $withDefault;
+ use HasDefault;
/**
* Get the results of the relationship.
@@ -42,33 +36,6 @@ public function initRelation(array $models, $relation)
return $models;
}
- /**
- * Get the default value for this relation.
- *
- * @param \Illuminate\Database\Eloquent\Model $model
- * @return \Illuminate\Database\Eloquent\Model|null
- */
- protected function getDefaultFor(Model $model)
- {
- if (! $this->withDefault) {
- return;
- }
-
- $instance = $this->related->newInstance()->setAttribute(
- $this->getForeignKeyName(), $model->getAttribute($this->localKey)
- );
-
- if (is_callable($this->withDefault)) {
- return call_user_func($this->withDefault, $instance) ?: $instance;
- }
-
- if (is_array($this->withDefault)) {
- $instance->forceFill($this->withDefault);
- }
-
- return $instance;
- }
-
/**
* Match the eagerly loaded results to their parents.
*
@@ -83,15 +50,14 @@ public function match(array $models, Collection $results, $relation)
}
/**
- * Return a new model instance in case the relationship does not exist.
+ * Make a new related instance for the given model.
*
- * @param \Closure|array|bool $callback
- * @return $this
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @return \Illuminate\Database\Eloquent\Model
*/
- public function withDefault($callback = true)
+ public function newRelatedInstanceFor(Model $parent)
{
- $this->withDefault = $callback;
-
- return $this;
+ return $this->related->newInstance()
+ ->setAttribute($this->getForeignKeyName(), $parent->{$this->localKey});
}
} | true |
Other | laravel | framework | ff00aa9e02634b94ec2b6572a3dcdb90d4349071.json | Add withDefault to MorphOne relations. | src/Illuminate/Database/Eloquent/Relations/MorphOne.php | @@ -2,18 +2,22 @@
namespace Illuminate\Database\Eloquent\Relations;
+use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Database\Eloquent\Relations\Concerns\HasDefault;
class MorphOne extends MorphOneOrMany
{
+ use HasDefault;
+
/**
* Get the results of the relationship.
*
* @return mixed
*/
public function getResults()
{
- return $this->query->first();
+ return $this->query->first() ?: $this->getDefaultFor($this->parent);
}
/**
@@ -26,7 +30,7 @@ public function getResults()
public function initRelation(array $models, $relation)
{
foreach ($models as $model) {
- $model->setRelation($relation, null);
+ $model->setRelation($relation, $this->getDefaultFor($model));
}
return $models;
@@ -44,4 +48,17 @@ public function match(array $models, Collection $results, $relation)
{
return $this->matchOne($models, $results, $relation);
}
+
+ /**
+ * Make a new related instance for the given model.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $parent
+ * @return \Illuminate\Database\Eloquent\Model
+ */
+ public function newRelatedInstanceFor(Model $parent)
+ {
+ return $this->related->newInstance()
+ ->setAttribute($this->getForeignKeyName(), $parent->{$this->localKey})
+ ->setAttribute($this->getMorphType(), $this->morphClass);
+ }
} | true |
Other | laravel | framework | bb5a955c2e146d8cf198ae5ac4c50bb28a194f58.json | Add dump method to Collection class (#19755)
* Add dump method
* cs fix
* add support for labels | src/Illuminate/Support/Collection.php | @@ -11,6 +11,7 @@
use JsonSerializable;
use IteratorAggregate;
use InvalidArgumentException;
+use Illuminate\Support\Debug\Dumper;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Support\Arrayable;
@@ -253,6 +254,22 @@ public function dd()
dd($this->all());
}
+ /**
+ * Dump the collection.
+ *
+ * @return void
+ */
+ public function dump()
+ {
+ (new static(func_get_args()))
+ ->push($this)
+ ->each(function ($item) {
+ (new Dumper)->dump($item);
+ });
+
+ return $this;
+ }
+
/**
* Get the items in the collection that are not present in the given items.
* | false |
Other | laravel | framework | f5fafad80dbb08353824483f5b849031693cc477.json | Add dd() to collection. | src/Illuminate/Support/Collection.php | @@ -243,6 +243,16 @@ public function crossJoin(...$lists)
));
}
+ /**
+ * Dump the collection and end the script.
+ *
+ * @return void
+ */
+ public function dd()
+ {
+ dd($this->all());
+ }
+
/**
* Get the items in the collection that are not present in the given items.
* | false |
Other | laravel | framework | 91543c185366dbef4749aa3552e186ce9190c78c.json | Apply fixes from StyleCI (#19753) | src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php | @@ -14,10 +14,10 @@
use Illuminate\Queue\Console\FailedTableCommand;
use Illuminate\Foundation\Console\AppNameCommand;
use Illuminate\Foundation\Console\JobMakeCommand;
-use Illuminate\Foundation\Console\RuleMakeCommand;
use Illuminate\Database\Console\Seeds\SeedCommand;
use Illuminate\Foundation\Console\MailMakeCommand;
use Illuminate\Foundation\Console\OptimizeCommand;
+use Illuminate\Foundation\Console\RuleMakeCommand;
use Illuminate\Foundation\Console\TestMakeCommand;
use Illuminate\Foundation\Console\EventMakeCommand;
use Illuminate\Foundation\Console\ModelMakeCommand; | false |
Other | laravel | framework | bc0f60b00b8c2c2fba2cc2c48b8a83a0d18f9c0d.json | detect lock wait timeout as deadlock (#19749) | src/Illuminate/Database/DetectsDeadlocks.php | @@ -25,6 +25,7 @@ protected function causedByDeadlock(Exception $e)
'database table is locked',
'A table in the database is locked',
'has been chosen as the deadlock victim',
+ 'Lock wait timeout exceeded; try restarting transaction',
]);
}
} | false |
Other | laravel | framework | ed1ede2a14e0db78d8172a596ac0acab38de03a1.json | initialize conditions property and fix docblock | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -37,6 +37,14 @@ class BladeCompiler extends Compiler implements CompilerInterface
*/
protected $customDirectives = [];
+ /**
+ * All custom directives conditions, used
+ * by the "if" and "check" methods
+ *
+ * @var array
+ */
+ protected $conditions = [];
+
/**
* The file currently being compiled.
*
@@ -350,7 +358,7 @@ public function getExtensions()
* Register an "if" statement directive.
*
* @param string $name
- * @param \Closrue $callback
+ * @param \Closure $callback
* @return void
*/
public function if($name, Closure $callback) | false |
Other | laravel | framework | 1f1540ab92effba1025b2e74b358c3e75ecf2ac6.json | Apply fixes from StyleCI (#19742) | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -364,7 +364,7 @@ public function if($name, Closure $callback)
});
$this->directive('end'.$name, function () {
- return "<?php endif; ?>";
+ return '<?php endif; ?>';
});
}
| false |
Other | laravel | framework | 71dfe0f0824412f106b80df8dedd7708e66dfb00.json | add if method | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -2,6 +2,7 @@
namespace Illuminate\View\Compilers;
+use Closure;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
@@ -345,6 +346,40 @@ public function getExtensions()
return $this->extensions;
}
+ /**
+ * Register an "if" statement directive.
+ *
+ * @param string $name
+ * @param \Closrue $callback
+ * @return void
+ */
+ public function if($name, Closure $callback)
+ {
+ $this->conditions[$name] = $callback;
+
+ $this->directive($name, function ($expression) use ($name) {
+ return $expression
+ ? "<?php if (\Illuminate\Support\Facades\Blade::check('{$name}', {$expression})): ?>"
+ : "<?php if (\Illuminate\Support\Facades\Blade::check('{$name}')): ?>";
+ });
+
+ $this->directive('end'.$name, function () {
+ return "<?php endif; ?>";
+ });
+ }
+
+ /**
+ * Check the result of a condition.
+ *
+ * @param string $name
+ * @param array $parameters
+ * @return bool
+ */
+ public function check($name, ...$parameters)
+ {
+ return call_user_func($this->conditions[$name], ...$parameters);
+ }
+
/**
* Register a handler for custom directives.
* | true |
Other | laravel | framework | 71dfe0f0824412f106b80df8dedd7708e66dfb00.json | add if method | tests/View/Blade/BladeCustomTest.php | @@ -60,4 +60,17 @@ public function testCustomExtensionOverwritesCore()
$expected = '<?php custom(); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
+
+ public function testCustomConditions()
+ {
+ $this->compiler->if('custom', function ($user) {
+ return true;
+ });
+
+ $string = '@custom($user)
+@endcustom';
+ $expected = '<?php if (\Illuminate\Support\Facades\Blade::check(\'custom\', $user)): ?>
+<?php endif; ?>';
+ $this->assertEquals($expected, $this->compiler->compileString($string));
+ }
} | true |
Other | laravel | framework | 346d352d15802b4fdbd692595235e23e2e12ba6c.json | Update ListenerMakeCommand.php (#19660)
* Update ListenerMakeCommand.php
Allow to make listeners for the events outside of App or Illuminate namespaces
* Update ListenerMakeCommand.php
Pass all prefixes to `Str::startWith()` in anonymous array. instead of calling it 3 times (even more useful if more prefixes will be added later on).
* Update ListenerMakeCommand.php
Typo :( | src/Illuminate/Foundation/Console/ListenerMakeCommand.php | @@ -53,8 +53,11 @@ protected function buildClass($name)
{
$event = $this->option('event');
- if (! Str::startsWith($event, $this->laravel->getNamespace()) &&
- ! Str::startsWith($event, 'Illuminate')) {
+ if (! Str::startsWith($event, [
+ $this->laravel->getNamespace(),
+ 'Illuminate',
+ '\\',
+ ])) {
$event = $this->laravel->getNamespace().'Events\\'.$event;
}
| false |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | src/Illuminate/Foundation/Application.php | @@ -520,7 +520,7 @@ public function detectEnvironment(Closure $callback)
{
$args = isset($_SERVER['argv']) ? $_SERVER['argv'] : null;
- return $this['env'] = (new EnvironmentDetector())->detect($callback, $args);
+ return $this['env'] = (new EnvironmentDetector)->detect($callback, $args);
}
/** | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | src/Illuminate/Mail/TransportManager.php | @@ -104,7 +104,7 @@ protected function addSesCredentials(array $config)
*/
protected function createMailDriver()
{
- return new MailTransport();
+ return new MailTransport;
}
/** | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | src/Illuminate/Routing/RoutingServiceProvider.php | @@ -133,7 +133,7 @@ protected function registerPsrRequest()
protected function registerPsrResponse()
{
$this->app->bind(ResponseInterface::class, function ($app) {
- return new PsrResponse();
+ return new PsrResponse;
});
}
| true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Auth/AuthorizesResourcesTest.php | @@ -13,42 +13,42 @@ class AuthorizesResourcesTest extends TestCase
{
public function testCreateMethod()
{
- $controller = new AuthorizesResourcesController();
+ $controller = new AuthorizesResourcesController;
$this->assertHasMiddleware($controller, 'create', 'can:create,App\User');
}
public function testStoreMethod()
{
- $controller = new AuthorizesResourcesController();
+ $controller = new AuthorizesResourcesController;
$this->assertHasMiddleware($controller, 'store', 'can:create,App\User');
}
public function testShowMethod()
{
- $controller = new AuthorizesResourcesController();
+ $controller = new AuthorizesResourcesController;
$this->assertHasMiddleware($controller, 'show', 'can:view,user');
}
public function testEditMethod()
{
- $controller = new AuthorizesResourcesController();
+ $controller = new AuthorizesResourcesController;
$this->assertHasMiddleware($controller, 'edit', 'can:update,user');
}
public function testUpdateMethod()
{
- $controller = new AuthorizesResourcesController();
+ $controller = new AuthorizesResourcesController;
$this->assertHasMiddleware($controller, 'update', 'can:update,user');
}
public function testDestroyMethod()
{
- $controller = new AuthorizesResourcesController();
+ $controller = new AuthorizesResourcesController;
$this->assertHasMiddleware($controller, 'destroy', 'can:delete,user');
} | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Broadcasting/BroadcasterTest.php | @@ -18,7 +18,7 @@ public function tearDown()
public function testExtractingParametersWhileCheckingForUserAccess()
{
- $broadcaster = new FakeBroadcaster();
+ $broadcaster = new FakeBroadcaster;
$callback = function ($user, BroadcasterTestEloquentModelStub $model, $nonModel) {
};
@@ -62,7 +62,7 @@ public function testExtractingParametersWhileCheckingForUserAccess()
*/
public function testNotFoundThrowsHttpException()
{
- $broadcaster = new FakeBroadcaster();
+ $broadcaster = new FakeBroadcaster;
$callback = function ($user, BroadcasterTestEloquentModelNotFoundStub $model) {
};
$broadcaster->extractAuthParameters('asd.{model}', 'asd.1', $callback); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Cache/CacheEventsTest.php | @@ -182,7 +182,7 @@ protected function getDispatcher()
protected function getRepository($dispatcher)
{
- $repository = new \Illuminate\Cache\Repository(new \Illuminate\Cache\ArrayStore());
+ $repository = new \Illuminate\Cache\Repository(new \Illuminate\Cache\ArrayStore);
$repository->put('baz', 'qux', 99);
$repository->tags('taylor')->put('baz', 'qux', 99);
$repository->setEventDispatcher($dispatcher); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Cache/CacheFileStoreTest.php | @@ -26,7 +26,7 @@ public function tearDown()
public function testNullIsReturnedIfFileDoesntExist()
{
$files = $this->mockFilesystem();
- $files->expects($this->once())->method('get')->will($this->throwException(new FileNotFoundException()));
+ $files->expects($this->once())->method('get')->will($this->throwException(new FileNotFoundException));
$store = new FileStore($files, __DIR__);
$value = $store->get('foo');
$this->assertNull($value); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Cache/CacheMemcachedStoreTest.php | @@ -138,7 +138,7 @@ public function testGetAndSetPrefix()
$this->markTestSkipped('Memcached module not installed');
}
- $store = new MemcachedStore(new Memcached(), 'bar');
+ $store = new MemcachedStore(new Memcached, 'bar');
$this->assertEquals('bar:', $store->getPrefix());
$store->setPrefix('foo');
$this->assertEquals('foo:', $store->getPrefix()); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Cache/CacheTableCommandTest.php | @@ -22,7 +22,7 @@ public function testCreateMakesMigration()
);
$creator = m::mock('Illuminate\Database\Migrations\MigrationCreator')->shouldIgnoreMissing();
- $app = new Application();
+ $app = new Application;
$app->useDatabasePath(__DIR__);
$app['migration.creator'] = $creator;
$command->setLaravel($app); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Cache/CacheTaggedCacheTest.php | @@ -27,7 +27,7 @@ public function testCacheCanBeSetWithDatetimeArgument()
{
$store = new ArrayStore;
$tags = ['bop', 'zap'];
- $duration = new DateTime();
+ $duration = new DateTime;
$duration->add(new DateInterval('PT10M'));
$store->tags($tags)->put('foo', 'bar', $duration);
$this->assertEquals('bar', $store->tags($tags)->get('foo')); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Cache/ClearCommandTest.php | @@ -22,7 +22,7 @@ public function testClearWithNoStoreArgument()
$cacheRepository = m::mock('Illuminate\Contracts\Cache\Repository');
- $app = new Application();
+ $app = new Application;
$command->setLaravel($app);
$cacheManager->shouldReceive('store')->once()->with(null)->andReturn($cacheRepository);
@@ -39,7 +39,7 @@ public function testClearWithStoreArgument()
$cacheRepository = m::mock('Illuminate\Contracts\Cache\Repository');
- $app = new Application();
+ $app = new Application;
$command->setLaravel($app);
$cacheManager->shouldReceive('store')->once()->with('foo')->andReturn($cacheRepository);
@@ -59,7 +59,7 @@ public function testClearWithInvalidStoreArgument()
$cacheRepository = m::mock('Illuminate\Contracts\Cache\Repository');
- $app = new Application();
+ $app = new Application;
$command->setLaravel($app);
$cacheManager->shouldReceive('store')->once()->with('bar')->andThrow('InvalidArgumentException');
@@ -76,7 +76,7 @@ public function testClearWithTagsOption()
$cacheRepository = m::mock('Illuminate\Contracts\Cache\Repository');
- $app = new Application();
+ $app = new Application;
$command->setLaravel($app);
$cacheManager->shouldReceive('store')->once()->with(null)->andReturn($cacheRepository);
@@ -94,7 +94,7 @@ public function testClearWithStoreArgumentAndTagsOption()
$cacheRepository = m::mock('Illuminate\Contracts\Cache\Repository');
- $app = new Application();
+ $app = new Application;
$command->setLaravel($app);
$cacheManager->shouldReceive('store')->once()->with('redis')->andReturn($cacheRepository); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Container/ContainerTest.php | @@ -525,7 +525,7 @@ public function testCallWithAtSignBasedClassReferences()
public function testCallWithCallableArray()
{
$container = new Container;
- $stub = new ContainerTestCallStub();
+ $stub = new ContainerTestCallStub;
$result = $container->call([$stub, 'work'], ['foo', 'bar']);
$this->assertEquals(['foo', 'bar'], $result);
} | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Cookie/Middleware/EncryptCookiesTest.php | @@ -77,7 +77,7 @@ class EncryptCookiesTestController extends Controller
{
public function setCookies()
{
- $response = new Response();
+ $response = new Response;
$response->headers->setCookie(new Cookie('encrypted_cookie', 'value'));
$response->headers->setCookie(new Cookie('unencrypted_cookie', 'value'));
@@ -86,7 +86,7 @@ public function setCookies()
public function queueCookies()
{
- return new Response();
+ return new Response;
}
}
| true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Database/DatabaseEloquentGlobalScopesTest.php | @@ -14,39 +14,39 @@ public function tearDown()
public function testGlobalScopeIsApplied()
{
- $model = new EloquentGlobalScopesTestModel();
+ $model = new EloquentGlobalScopesTestModel;
$query = $model->newQuery();
$this->assertEquals('select * from "table" where "active" = ?', $query->toSql());
$this->assertEquals([1], $query->getBindings());
}
public function testGlobalScopeCanBeRemoved()
{
- $model = new EloquentGlobalScopesTestModel();
+ $model = new EloquentGlobalScopesTestModel;
$query = $model->newQuery()->withoutGlobalScope(ActiveScope::class);
$this->assertEquals('select * from "table"', $query->toSql());
$this->assertEquals([], $query->getBindings());
}
public function testClosureGlobalScopeIsApplied()
{
- $model = new EloquentClosureGlobalScopesTestModel();
+ $model = new EloquentClosureGlobalScopesTestModel;
$query = $model->newQuery();
$this->assertEquals('select * from "table" where "active" = ? order by "name" asc', $query->toSql());
$this->assertEquals([1], $query->getBindings());
}
public function testClosureGlobalScopeCanBeRemoved()
{
- $model = new EloquentClosureGlobalScopesTestModel();
+ $model = new EloquentClosureGlobalScopesTestModel;
$query = $model->newQuery()->withoutGlobalScope('active_scope');
$this->assertEquals('select * from "table" order by "name" asc', $query->toSql());
$this->assertEquals([], $query->getBindings());
}
public function testGlobalScopeCanBeRemovedAfterTheQueryIsExecuted()
{
- $model = new EloquentClosureGlobalScopesTestModel();
+ $model = new EloquentClosureGlobalScopesTestModel;
$query = $model->newQuery();
$this->assertEquals('select * from "table" where "active" = ? order by "name" asc', $query->toSql());
$this->assertEquals([1], $query->getBindings());
@@ -58,7 +58,7 @@ public function testGlobalScopeCanBeRemovedAfterTheQueryIsExecuted()
public function testAllGlobalScopesCanBeRemoved()
{
- $model = new EloquentClosureGlobalScopesTestModel();
+ $model = new EloquentClosureGlobalScopesTestModel;
$query = $model->newQuery()->withoutGlobalScopes();
$this->assertEquals('select * from "table"', $query->toSql());
$this->assertEquals([], $query->getBindings());
@@ -70,7 +70,7 @@ public function testAllGlobalScopesCanBeRemoved()
public function testGlobalScopesWithOrWhereConditionsAreNested()
{
- $model = new EloquentClosureGlobalScopesWithOrTestModel();
+ $model = new EloquentClosureGlobalScopesWithOrTestModel;
$query = $model->newQuery();
$this->assertEquals('select "email", "password" from "table" where ("email" = ? or "email" = ?) and "active" = ? order by "name" asc', $query->toSql()); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Database/DatabaseEloquentHasOneTest.php | @@ -26,7 +26,7 @@ public function testHasOneWithDefault()
$this->builder->shouldReceive('first')->once()->andReturnNull();
- $newModel = new EloquentHasOneModelStub();
+ $newModel = new EloquentHasOneModelStub;
$this->related->shouldReceive('newInstance')->once()->andReturn($newModel);
@@ -43,7 +43,7 @@ public function testHasOneWithDynamicDefault()
$this->builder->shouldReceive('first')->once()->andReturnNull();
- $newModel = new EloquentHasOneModelStub();
+ $newModel = new EloquentHasOneModelStub;
$this->related->shouldReceive('newInstance')->once()->andReturn($newModel);
@@ -62,7 +62,7 @@ public function testHasOneWithArrayDefault()
$this->builder->shouldReceive('first')->once()->andReturnNull();
- $newModel = new EloquentHasOneModelStub();
+ $newModel = new EloquentHasOneModelStub;
$this->related->shouldReceive('newInstance')->once()->andReturn($newModel);
| true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Database/DatabaseEloquentModelTest.php | @@ -423,7 +423,7 @@ public function testTimestampsAreCreatedFromStringsAndIntegers()
public function testFromDateTime()
{
- $model = new EloquentModelStub();
+ $model = new EloquentModelStub;
$value = \Carbon\Carbon::parse('2015-04-17 22:59:01');
$this->assertEquals('2015-04-17 22:59:01', $model->fromDateTime($value)); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Database/DatabaseEloquentRelationTest.php | @@ -71,7 +71,7 @@ public function testMacroable()
return 'foo';
});
- $model = new EloquentRelationResetModelStub();
+ $model = new EloquentRelationResetModelStub;
$relation = new EloquentRelationStub($model->newQuery(), $model);
$result = $relation->foo(); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Database/DatabaseSchemaBlueprintIntegrationTest.php | @@ -47,7 +47,7 @@ public function testRenamingAndChangingColumnsWork()
$table->integer('age')->change();
});
- $queries = $blueprint->toSql($this->db->connection(), new \Illuminate\Database\Schema\Grammars\SQLiteGrammar());
+ $queries = $blueprint->toSql($this->db->connection(), new \Illuminate\Database\Schema\Grammars\SQLiteGrammar);
$expected = [
'CREATE TEMPORARY TABLE __temp__users AS SELECT name, age FROM users', | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Events/EventsDispatcherTest.php | @@ -230,7 +230,7 @@ public function testShouldBroadcastSuccess()
$d->makePartial()->shouldAllowMockingProtectedMethods();
- $event = new BroadcastEvent();
+ $event = new BroadcastEvent;
$this->assertTrue($d->shouldBroadcast([$event]));
}
@@ -241,7 +241,7 @@ public function testShouldBroadcastFail()
$d->makePartial()->shouldAllowMockingProtectedMethods();
- $event = new BroadcastFalseCondition();
+ $event = new BroadcastFalseCondition;
$this->assertFalse($d->shouldBroadcast([$event]));
} | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Filesystem/FilesystemTest.php | @@ -17,28 +17,28 @@ public function setUp()
public function tearDown()
{
- $files = new Filesystem();
+ $files = new Filesystem;
$files->deleteDirectory($this->tempDir);
}
public function testGetRetrievesFiles()
{
file_put_contents($this->tempDir.'/file.txt', 'Hello World');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals('Hello World', $files->get($this->tempDir.'/file.txt'));
}
public function testPutStoresFiles()
{
- $files = new Filesystem();
+ $files = new Filesystem;
$files->put($this->tempDir.'/file.txt', 'Hello World');
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Hello World');
}
public function testSetChmod()
{
file_put_contents($this->tempDir.'/file.txt', 'Hello World');
- $files = new Filesystem();
+ $files = new Filesystem;
$files->chmod($this->tempDir.'/file.txt', 0755);
$filePermisson = substr(sprintf('%o', fileperms($this->tempDir.'/file.txt')), -4);
$this->assertEquals('0755', $filePermisson);
@@ -48,7 +48,7 @@ public function testGetChmod()
{
file_put_contents($this->tempDir.'/file.txt', 'Hello World');
chmod($this->tempDir.'/file.txt', 0755);
- $files = new Filesystem();
+ $files = new Filesystem;
$filePermisson = $files->chmod($this->tempDir.'/file.txt');
$this->assertEquals('0755', $filePermisson);
}
@@ -59,7 +59,7 @@ public function testDeleteRemovesFiles()
file_put_contents($this->tempDir.'/file2.txt', 'Hello World');
file_put_contents($this->tempDir.'/file3.txt', 'Hello World');
- $files = new Filesystem();
+ $files = new Filesystem;
$files->delete($this->tempDir.'/file1.txt');
$this->assertFileNotExists($this->tempDir.'/file1.txt');
@@ -70,15 +70,15 @@ public function testDeleteRemovesFiles()
public function testPrependExistingFiles()
{
- $files = new Filesystem();
+ $files = new Filesystem;
$files->put($this->tempDir.'/file.txt', 'World');
$files->prepend($this->tempDir.'/file.txt', 'Hello ');
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Hello World');
}
public function testPrependNewFiles()
{
- $files = new Filesystem();
+ $files = new Filesystem;
$files->prepend($this->tempDir.'/file.txt', 'Hello World');
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Hello World');
}
@@ -87,7 +87,7 @@ public function testDeleteDirectory()
{
mkdir($this->tempDir.'/foo');
file_put_contents($this->tempDir.'/foo/file.txt', 'Hello World');
- $files = new Filesystem();
+ $files = new Filesystem;
$files->deleteDirectory($this->tempDir.'/foo');
$this->assertFalse(is_dir($this->tempDir.'/foo'));
$this->assertFileNotExists($this->tempDir.'/foo/file.txt');
@@ -97,7 +97,7 @@ public function testCleanDirectory()
{
mkdir($this->tempDir.'/foo');
file_put_contents($this->tempDir.'/foo/file.txt', 'Hello World');
- $files = new Filesystem();
+ $files = new Filesystem;
$files->cleanDirectory($this->tempDir.'/foo');
$this->assertTrue(is_dir($this->tempDir.'/foo'));
$this->assertFileNotExists($this->tempDir.'/foo/file.txt');
@@ -106,7 +106,7 @@ public function testCleanDirectory()
public function testMacro()
{
file_put_contents($this->tempDir.'/foo.txt', 'Hello World');
- $files = new Filesystem();
+ $files = new Filesystem;
$tempDir = $this->tempDir;
$files->macro('getFoo', function () use ($files, $tempDir) {
return $files->get($tempDir.'/foo.txt');
@@ -120,14 +120,14 @@ public function testFilesMethod()
file_put_contents($this->tempDir.'/foo/1.txt', '1');
file_put_contents($this->tempDir.'/foo/2.txt', '2');
mkdir($this->tempDir.'/foo/bar');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals([$this->tempDir.'/foo/1.txt', $this->tempDir.'/foo/2.txt'], $files->files($this->tempDir.'/foo'));
unset($files);
}
public function testCopyDirectoryReturnsFalseIfSourceIsntDirectory()
{
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertFalse($files->copyDirectory($this->tempDir.'/foo/bar/baz/breeze/boom', $this->tempDir));
}
@@ -139,7 +139,7 @@ public function testCopyDirectoryMovesEntireDirectory()
mkdir($this->tempDir.'/tmp/nested', 0777, true);
file_put_contents($this->tempDir.'/tmp/nested/baz.txt', '');
- $files = new Filesystem();
+ $files = new Filesystem;
$files->copyDirectory($this->tempDir.'/tmp', $this->tempDir.'/tmp2');
$this->assertTrue(is_dir($this->tempDir.'/tmp2'));
$this->assertFileExists($this->tempDir.'/tmp2/foo.txt');
@@ -156,7 +156,7 @@ public function testMoveDirectoryMovesEntireDirectory()
mkdir($this->tempDir.'/tmp/nested', 0777, true);
file_put_contents($this->tempDir.'/tmp/nested/baz.txt', '');
- $files = new Filesystem();
+ $files = new Filesystem;
$files->moveDirectory($this->tempDir.'/tmp', $this->tempDir.'/tmp2');
$this->assertTrue(is_dir($this->tempDir.'/tmp2'));
$this->assertFileExists($this->tempDir.'/tmp2/foo.txt');
@@ -177,7 +177,7 @@ public function testMoveDirectoryMovesEntireDirectoryAndOverwrites()
file_put_contents($this->tempDir.'/tmp2/foo2.txt', '');
file_put_contents($this->tempDir.'/tmp2/bar2.txt', '');
- $files = new Filesystem();
+ $files = new Filesystem;
$files->moveDirectory($this->tempDir.'/tmp', $this->tempDir.'/tmp2', true);
$this->assertTrue(is_dir($this->tempDir.'/tmp2'));
$this->assertFileExists($this->tempDir.'/tmp2/foo.txt');
@@ -194,14 +194,14 @@ public function testMoveDirectoryMovesEntireDirectoryAndOverwrites()
*/
public function testGetThrowsExceptionNonexisitingFile()
{
- $files = new Filesystem();
+ $files = new Filesystem;
$files->get($this->tempDir.'/unknown-file.txt');
}
public function testGetRequireReturnsProperly()
{
file_put_contents($this->tempDir.'/file.php', '<?php return "Howdy?"; ?>');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals('Howdy?', $files->getRequire($this->tempDir.'/file.php'));
}
@@ -210,14 +210,14 @@ public function testGetRequireReturnsProperly()
*/
public function testGetRequireThrowsExceptionNonexisitingFile()
{
- $files = new Filesystem();
+ $files = new Filesystem;
$files->getRequire($this->tempDir.'/file.php');
}
public function testAppendAddsDataToFile()
{
file_put_contents($this->tempDir.'/file.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
$bytesWritten = $files->append($this->tempDir.'/file.txt', 'bar');
$this->assertEquals(mb_strlen('bar', '8bit'), $bytesWritten);
$this->assertFileExists($this->tempDir.'/file.txt');
@@ -227,7 +227,7 @@ public function testAppendAddsDataToFile()
public function testMoveMovesFiles()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
$files->move($this->tempDir.'/foo.txt', $this->tempDir.'/bar.txt');
$this->assertFileExists($this->tempDir.'/bar.txt');
$this->assertFileNotExists($this->tempDir.'/foo.txt');
@@ -236,42 +236,42 @@ public function testMoveMovesFiles()
public function testExtensionReturnsExtension()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals('txt', $files->extension($this->tempDir.'/foo.txt'));
}
public function testBasenameReturnsBasename()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals('foo.txt', $files->basename($this->tempDir.'/foo.txt'));
}
public function testDirnameReturnsDirectory()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals($this->tempDir, $files->dirname($this->tempDir.'/foo.txt'));
}
public function testTypeIndentifiesFile()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals('file', $files->type($this->tempDir.'/foo.txt'));
}
public function testTypeIndentifiesDirectory()
{
mkdir($this->tempDir.'/foo');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals('dir', $files->type($this->tempDir.'/foo'));
}
public function testSizeOutputsSize()
{
$size = file_put_contents($this->tempDir.'/foo.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals($size, $files->size($this->tempDir.'/foo.txt'));
}
@@ -281,14 +281,14 @@ public function testSizeOutputsSize()
public function testMimeTypeOutputsMimeType()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertEquals('text/plain', $files->mimeType($this->tempDir.'/foo.txt'));
}
public function testIsWritable()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
@chmod($this->tempDir.'/foo.txt', 0444);
$this->assertFalse($files->isWritable($this->tempDir.'/foo.txt'));
@chmod($this->tempDir.'/foo.txt', 0777);
@@ -298,7 +298,7 @@ public function testIsWritable()
public function testIsReadable()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
- $files = new Filesystem();
+ $files = new Filesystem;
// chmod is noneffective on Windows
if (DIRECTORY_SEPARATOR === '\\') {
$this->assertTrue($files->isReadable($this->tempDir.'/foo.txt'));
@@ -315,7 +315,7 @@ public function testGlobFindsFiles()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
file_put_contents($this->tempDir.'/bar.txt', 'bar');
- $files = new Filesystem();
+ $files = new Filesystem;
$glob = $files->glob($this->tempDir.'/*.txt');
$this->assertContains($this->tempDir.'/foo.txt', $glob);
$this->assertContains($this->tempDir.'/bar.txt', $glob);
@@ -325,7 +325,7 @@ public function testAllFilesFindsFiles()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
file_put_contents($this->tempDir.'/bar.txt', 'bar');
- $files = new Filesystem();
+ $files = new Filesystem;
$allFiles = [];
foreach ($files->allFiles($this->tempDir) as $file) {
$allFiles[] = $file->getFilename();
@@ -338,15 +338,15 @@ public function testDirectoriesFindsDirectories()
{
mkdir($this->tempDir.'/foo');
mkdir($this->tempDir.'/bar');
- $files = new Filesystem();
+ $files = new Filesystem;
$directories = $files->directories($this->tempDir);
$this->assertContains($this->tempDir.DIRECTORY_SEPARATOR.'foo', $directories);
$this->assertContains($this->tempDir.DIRECTORY_SEPARATOR.'bar', $directories);
}
public function testMakeDirectory()
{
- $files = new Filesystem();
+ $files = new Filesystem;
$this->assertTrue($files->makeDirectory($this->tempDir.'/foo'));
$this->assertFileExists($this->tempDir.'/foo');
}
@@ -367,7 +367,7 @@ public function testSharedGet()
$pid = pcntl_fork();
if (! $pid) {
- $files = new Filesystem();
+ $files = new Filesystem;
$files->put($this->tempDir.'/file.txt', $content, true);
$read = $files->get($this->tempDir.'/file.txt', true);
@@ -385,7 +385,7 @@ public function testSharedGet()
public function testRequireOnceRequiresFileProperly()
{
- $filesystem = new Filesystem();
+ $filesystem = new Filesystem;
mkdir($this->tempDir.'/foo');
file_put_contents($this->tempDir.'/foo/foo.php', '<?php function random_function_xyz(){};');
$filesystem->requireOnce($this->tempDir.'/foo/foo.php');
@@ -397,7 +397,7 @@ public function testRequireOnceRequiresFileProperly()
public function testCopyCopiesFileProperly()
{
- $filesystem = new Filesystem();
+ $filesystem = new Filesystem;
$data = 'contents';
mkdir($this->tempDir.'/foo');
file_put_contents($this->tempDir.'/foo/foo.txt', $data);
@@ -408,7 +408,7 @@ public function testCopyCopiesFileProperly()
public function testIsFileChecksFilesProperly()
{
- $filesystem = new Filesystem();
+ $filesystem = new Filesystem;
mkdir($this->tempDir.'/foo');
file_put_contents($this->tempDir.'/foo/foo.txt', 'contents');
$this->assertTrue($filesystem->isFile($this->tempDir.'/foo/foo.txt'));
@@ -421,7 +421,7 @@ public function testFilesMethodReturnsFileInfoObjects()
file_put_contents($this->tempDir.'/foo/1.txt', '1');
file_put_contents($this->tempDir.'/foo/2.txt', '2');
mkdir($this->tempDir.'/foo/bar');
- $files = new Filesystem();
+ $files = new Filesystem;
foreach ($files->files($this->tempDir.'/foo') as $file) {
$this->assertInstanceOf(\SplFileInfo::class, $file);
}
@@ -432,7 +432,7 @@ public function testAllFilesReturnsFileInfoObjects()
{
file_put_contents($this->tempDir.'/foo.txt', 'foo');
file_put_contents($this->tempDir.'/bar.txt', 'bar');
- $files = new Filesystem();
+ $files = new Filesystem;
$allFiles = [];
foreach ($files->allFiles($this->tempDir) as $file) {
$this->assertInstanceOf(\SplFileInfo::class, $file); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Foundation/FoundationTestResponseTest.php | @@ -147,7 +147,7 @@ public function testMacroable()
public function testCanBeCreatedFromBinaryFileResponses()
{
- $files = new Filesystem();
+ $files = new Filesystem;
$tempDir = __DIR__.'/tmp';
$files->makeDirectory($tempDir, 0755, false, true);
$files->put($tempDir.'/file.txt', 'Hello World'); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Foundation/Http/Middleware/TransformsRequestTest.php | @@ -10,7 +10,7 @@ class TransformsRequestTest extends TestCase
{
public function testLowerAgeAndAddBeer()
{
- $middleware = new ManipulateInput();
+ $middleware = new ManipulateInput;
$request = new Request(
[
'name' => 'Damian',
@@ -28,7 +28,7 @@ public function testLowerAgeAndAddBeer()
public function testAjaxLowerAgeAndAddBeer()
{
- $middleware = new ManipulateInput();
+ $middleware = new ManipulateInput;
$request = new Request(
[
'name' => 'Damian', | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Http/HttpResponseTest.php | @@ -31,7 +31,7 @@ public function testJsonResponsesAreConvertedAndHeadersAreSet()
$this->assertEquals('{"foo":"bar"}', $response->getContent());
$this->assertEquals('application/json', $response->headers->get('Content-Type'));
- $response = new \Illuminate\Http\Response();
+ $response = new \Illuminate\Http\Response;
$response->setContent(['foo' => 'bar']);
$this->assertEquals('{"foo":"bar"}', $response->getContent());
$this->assertEquals('application/json', $response->headers->get('Content-Type'));
@@ -62,7 +62,7 @@ public function testRenderablesAreRendered()
public function testHeader()
{
- $response = new \Illuminate\Http\Response();
+ $response = new \Illuminate\Http\Response;
$this->assertNull($response->headers->get('foo'));
$response->header('foo', 'bar');
$this->assertEquals('bar', $response->headers->get('foo'));
@@ -74,7 +74,7 @@ public function testHeader()
public function testWithCookie()
{
- $response = new \Illuminate\Http\Response();
+ $response = new \Illuminate\Http\Response;
$this->assertCount(0, $response->headers->getCookies());
$this->assertEquals($response, $response->withCookie(new \Symfony\Component\HttpFoundation\Cookie('foo', 'bar')));
$cookies = $response->headers->getCookies();
@@ -86,7 +86,7 @@ public function testWithCookie()
public function testGetOriginalContent()
{
$arr = ['foo' => 'bar'];
- $response = new \Illuminate\Http\Response();
+ $response = new \Illuminate\Http\Response;
$response->setContent($arr);
$this->assertSame($arr, $response->getOriginalContent());
} | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Integration/Notifications/SendingMailNotificationsTest.php | @@ -54,7 +54,7 @@ public function setUp()
public function test_mail_is_sent()
{
- $notification = new TestMailNotification();
+ $notification = new TestMailNotification;
$user = NotifiableUser::forceCreate([
'email' => 'taylor@laravel.com',
@@ -90,7 +90,7 @@ public function test_mail_is_sent()
public function test_mail_is_sent_with_subject()
{
- $notification = new TestMailNotificationWithSubject();
+ $notification = new TestMailNotificationWithSubject;
$user = NotifiableUser::forceCreate([
'email' => 'taylor@laravel.com',
@@ -120,7 +120,7 @@ public function test_mail_is_sent_with_subject()
public function test_mail_is_sent_using_mailable()
{
- $notification = new TestMailNotificationWithMailable();
+ $notification = new TestMailNotificationWithMailable;
$user = NotifiableUser::forceCreate([
'email' => 'taylor@laravel.com', | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Mail/MailMailerTest.php | @@ -201,6 +201,6 @@ public function getTransport()
public function createMessage()
{
- return new \Swift_Message();
+ return new \Swift_Message;
}
} | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Queue/QueueDatabaseQueueUnitTest.php | @@ -54,7 +54,7 @@ public function testFailureToCreatePayloadFromObject()
{
$this->expectException('InvalidArgumentException');
- $job = new stdClass();
+ $job = new stdClass;
$job->invalid = "\xc3\x28";
$queue = $this->getMockForAbstractClass('Illuminate\Queue\Queue'); | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Queue/QueueListenerTest.php | @@ -36,7 +36,7 @@ public function testListenerStopsWhenMemoryIsExceeded()
public function testMakeProcessCorrectlyFormatsCommandLine()
{
$listener = new \Illuminate\Queue\Listener(__DIR__);
- $options = new \Illuminate\Queue\ListenerOptions();
+ $options = new \Illuminate\Queue\ListenerOptions;
$options->delay = 1;
$options->memory = 2;
$options->timeout = 3; | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Queue/QueueSyncQueueTest.php | @@ -75,7 +75,7 @@ class FailingSyncQueueTestHandler
{
public function fire($job, $data)
{
- throw new Exception();
+ throw new Exception;
}
public function failed() | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Routing/RouteCollectionTest.php | @@ -18,7 +18,7 @@ public function setUp()
{
parent::setUp();
- $this->routeCollection = new RouteCollection();
+ $this->routeCollection = new RouteCollection;
}
public function testRouteCollectionCanBeConstructed() | true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Routing/RoutingRouteTest.php | @@ -761,7 +761,7 @@ public function testModelBindingWithBindingClosure()
return $name;
}]);
$router->model('bar', 'Illuminate\Tests\Routing\RouteModelBindingNullStub', function ($value) {
- return (new RouteModelBindingClosureStub())->findAlternate($value);
+ return (new RouteModelBindingClosureStub)->findAlternate($value);
});
$this->assertEquals('tayloralt', $router->dispatch(Request::create('foo/TAYLOR', 'GET'))->getContent());
}
@@ -1667,7 +1667,7 @@ public function first()
public function firstOrFail()
{
- throw new \Illuminate\Database\Eloquent\ModelNotFoundException();
+ throw new \Illuminate\Database\Eloquent\ModelNotFoundException;
}
}
| true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Session/SessionStoreTest.php | @@ -289,10 +289,10 @@ public function testHandlerNeedsRequest()
$this->assertFalse($session->handlerNeedsRequest());
$session->getHandler()->shouldReceive('setRequest')->never();
- $session = new \Illuminate\Session\Store('test', m::mock(new \Illuminate\Session\CookieSessionHandler(new \Illuminate\Cookie\CookieJar(), 60)));
+ $session = new \Illuminate\Session\Store('test', m::mock(new \Illuminate\Session\CookieSessionHandler(new \Illuminate\Cookie\CookieJar, 60)));
$this->assertTrue($session->handlerNeedsRequest());
$session->getHandler()->shouldReceive('setRequest')->once();
- $request = new \Symfony\Component\HttpFoundation\Request();
+ $request = new \Symfony\Component\HttpFoundation\Request;
$session->setRequestOnHandler($request);
}
| true |
Other | laravel | framework | cfc5264204b83309226412e6104313ad6e6f1023.json | Remove useless braces in constructors. (#19663) | tests/Session/SessionTableCommandTest.php | @@ -22,7 +22,7 @@ public function testCreateMakesMigration()
);
$creator = m::mock('Illuminate\Database\Migrations\MigrationCreator')->shouldIgnoreMissing();
- $app = new Application();
+ $app = new Application;
$app->useDatabasePath(__DIR__);
$app['migration.creator'] = $creator;
$command->setLaravel($app); | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.