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
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
@@ -497,6 +497,20 @@ protected function typeDateTime(Fluent $column) return 'datetime'; } + /** + * Create the column definition for a date-time type. + * + * Note: "SQLite does not have a storage class set aside for storing dates and/or times." + * @link https://www.sqlite.org/datatype3.html + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDateTimeTz(Fluent $column) + { + return 'datetime'; + } + /** * Create the column definition for a time type. * @@ -508,6 +522,17 @@ protected function typeTime(Fluent $column) return 'time'; } + /** + * Create the column definition for a time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimeTz(Fluent $column) + { + return 'time'; + } + /** * Create the column definition for a timestamp type. * @@ -519,6 +544,17 @@ protected function typeTimestamp(Fluent $column) return 'datetime'; } + /** + * Create the column definition for a timestamp type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimestampTz(Fluent $column) + { + return 'datetime'; + } + /** * Create the column definition for a binary type. *
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
@@ -439,6 +439,17 @@ protected function typeDateTime(Fluent $column) return 'datetime'; } + /** + * Create the column definition for a date-time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDateTimeTz(Fluent $column) + { + return 'datetimeoffset(0)'; + } + /** * Create the column definition for a time type. * @@ -450,6 +461,17 @@ protected function typeTime(Fluent $column) return 'time'; } + /** + * Create the column definition for a time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimeTz(Fluent $column) + { + return 'time'; + } + /** * Create the column definition for a timestamp type. * @@ -461,6 +483,19 @@ protected function typeTimestamp(Fluent $column) return 'datetime'; } + /** + * Create the column definition for a timestamp type. + * + * @link https://msdn.microsoft.com/en-us/library/bb630289(v=sql.120).aspx + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimestampTz(Fluent $column) + { + return 'datetimeoffset(0)'; + } + /** * Create the column definition for a binary type. *
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Foundation/Application.php
@@ -465,7 +465,7 @@ public function registerConfiguredProviders() $manifestPath = $this->getCachedServicesPath(); (new ProviderRepository($this, new Filesystem, $manifestPath)) - ->load($this->config['app.providers']); + ->load($this->config['app.providers']); } /** @@ -876,6 +876,16 @@ public function getLoadedProviders() return $this->loadedProviders; } + /** + * Get the application's deferred services. + * + * @return array + */ + public function getDeferredServices() + { + return $this->deferredServices; + } + /** * Set the application's deferred services. * @@ -887,6 +897,17 @@ public function setDeferredServices(array $services) $this->deferredServices = $services; } + /** + * Add an array of services to the application's deferred services. + * + * @param array $services + * @return void + */ + public function addDeferredServices(array $services) + { + $this->deferredServices = array_merge($this->deferredServices, $services); + } + /** * Determine if the given service is a deferred service. *
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Foundation/Http/Middleware/VerifyPostSize.php
@@ -0,0 +1,53 @@ +<?php namespace Illuminate\Foundation\Http\Middleware; + +use Closure; +use Illuminate\Contracts\Routing\Middleware; +use Illuminate\Http\Exception\PostTooLargeException; + +class VerifyPostSize implements Middleware { + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @return mixed + * + * @throws \Illuminate\Http\Exception\PostTooLargeException + */ + public function handle($request, Closure $next) + { + if ($request->server('CONTENT_LENGTH') > $this->getPostMaxSize()) + { + throw new PostTooLargeException; + } + + return $next($request); + } + + /** + * Determine the server 'post_max_size' as bytes. + * + * @return int + */ + protected function getPostMaxSize() + { + $postMaxSize = ini_get('post_max_size'); + + switch (substr($postMaxSize, -1)) + { + case 'M': + case 'm': + return (int) $postMaxSize * 1048576; + case 'K': + case 'k': + return (int) $postMaxSize * 1024; + case 'G': + case 'g': + return (int) $postMaxSize * 1073741824; + } + + return (int) $postMaxSize; + } + +}
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Foundation/Testing/AssertionsTrait.php
@@ -14,7 +14,7 @@ public function assertResponseOk() { $actual = $this->response->getStatusCode(); - return PHPUnit::assertTrue($this->response->isOk(), 'Expected status code 200, got ' .$actual); + return PHPUnit::assertTrue($this->response->isOk(), "Expected status code 200, got {$actual}."); } /** @@ -25,7 +25,9 @@ public function assertResponseOk() */ public function assertResponseStatus($code) { - return PHPUnit::assertEquals($code, $this->response->getStatusCode()); + $actual = $this->response->getStatusCode(); + + return PHPUnit::assertEquals($code, $this->response->getStatusCode(), "Expected status code {$code}, got {$actual}."); } /**
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Http/Exception/PostTooLargeException.php
@@ -0,0 +1,5 @@ +<?php namespace Illuminate\Http\Exception; + +use Exception; + +class PostTooLargeException extends Exception {}
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Mail/MailServiceProvider.php
@@ -64,9 +64,9 @@ protected function setMailerDependencies($mailer, $app) { $mailer->setContainer($app); - if ($app->bound('log')) + if ($app->bound('Psr\Log\LoggerInterface')) { - $mailer->setLogger($app['log']->getMonolog()); + $mailer->setLogger($app->make('Psr\Log\LoggerInterface')); } if ($app->bound('queue'))
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Mail/composer.json
@@ -32,6 +32,7 @@ } }, "suggest": { + "aws/aws-sdk-php": "Required to use the SES mail driver (~2.4).", "guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers (~5.0)." }, "minimum-stability": "dev"
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Routing/Router.php
@@ -323,7 +323,16 @@ public function resources(array $resources) */ public function resource($name, $controller, array $options = array()) { - (new ResourceRegistrar($this))->register($name, $controller, $options); + if ($this->container && $this->container->bound('Illuminate\Routing\ResourceRegistrar')) + { + $registrar = $this->container->make('Illuminate\Routing\ResourceRegistrar'); + } + else + { + $registrar = new ResourceRegistrar($this); + } + + $registrar->register($name, $controller, $options); } /**
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Session/Store.php
@@ -213,9 +213,9 @@ public function setName($name) */ public function invalidate($lifetime = null) { - $this->attributes = array(); + $this->clear(); - return $this->migrate(); + return $this->migrate(true, $lifetime); } /**
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Support/Arr.php
@@ -45,6 +45,26 @@ public static function build($array, callable $callback) return $results; } + /** + * Collapse an array of arrays into a single array. + * + * @param array|\ArrayAccess $array + * @return array + */ + public static function collapse($array) + { + $results = []; + + foreach ($array as $values) + { + if ($values instanceof Collection) $values = $values->all(); + + $results = array_merge($results, $values); + } + + return $results; + } + /** * Divide an array into two arrays. One with keys and the other with values. *
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Support/Collection.php
@@ -54,22 +54,13 @@ public function all() } /** - * Collapse the collection items into a single array. + * Collapse the collection of items into a single array. * * @return static */ public function collapse() { - $results = []; - - foreach ($this->items as $values) - { - if ($values instanceof Collection) $values = $values->all(); - - $results = array_merge($results, $values); - } - - return new static($results); + return new static(array_collapse($this->items)); } /** @@ -539,7 +530,17 @@ public function reverse() */ public function search($value, $strict = false) { - return array_search($value, $this->items, $strict); + if ( ! $this->useAsCallable($value)) + { + return array_search($value, $this->items, $strict); + } + + foreach ($this->items as $key => $item) + { + if ($value($item, $key)) return $key; + } + + return false; } /**
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/Support/helpers.php
@@ -62,6 +62,20 @@ function array_build($array, callable $callback) } } +if ( ! function_exists('array_collapse')) +{ + /** + * Collapse an array of arrays into a single array. + * + * @param array|\ArrayAccess $array + * @return array + */ + function array_collapse($array) + { + return Arr::collapse($array); + } +} + if ( ! function_exists('array_divide')) { /**
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/View/Compilers/BladeCompiler.php
@@ -220,7 +220,7 @@ protected function compileEchos($value) } /** - * Get the echo methdos in the proper order for compilation. + * Get the echo methods in the proper order for compilation. * * @return array */
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
src/Illuminate/View/Factory.php
@@ -865,6 +865,17 @@ public function getShared() return $this->shared; } + /** + * Check if section exists. + * + * @param string $name + * @return bool + */ + public function hasSection($name) + { + return array_key_exists($name, $this->sections); + } + /** * Get the entire array of sections. *
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/Database/DatabaseConnectorTest.php
@@ -120,19 +120,38 @@ public function testSqlServerConnectCallsCreateConnectionWithProperArguments() $this->assertSame($result, $connection); } + public function testSqlServerConnectCallsCreateConnectionWithOptionalArguments() + { + $config = array('host' => 'foo', 'database' => 'bar', 'port' => 111, 'appname' => 'baz', 'charset' => 'utf-8'); + $dsn = $this->getDsn($config); + $connector = $this->getMock('Illuminate\Database\Connectors\SqlServerConnector', array('createConnection', 'getOptions')); + $connection = m::mock('stdClass'); + $connector->expects($this->once())->method('getOptions')->with($this->equalTo($config))->will($this->returnValue(array('options'))); + $connector->expects($this->once())->method('createConnection')->with($this->equalTo($dsn), $this->equalTo($config), $this->equalTo(array('options')))->will($this->returnValue($connection)); + $result = $connector->connect($config); + + $this->assertSame($result, $connection); + + } + protected function getDsn(array $config) { extract($config); if (in_array('dblib', PDO::getAvailableDrivers())) { $port = isset($config['port']) ? ':'.$port : ''; - return "dblib:host={$host}{$port};dbname={$database}"; + $appname = isset($config['appname']) ? ';appname='.$config['appname'] : ''; + $charset = isset($config['charset']) ? ';charset='.$config['charset'] : ''; + + return "dblib:host={$host}{$port};dbname={$database}{$appname}{$charset}"; } else { $port = isset($config['port']) ? ','.$port : ''; - return "sqlsrv:Server={$host}{$port};Database={$database}"; + $appname = isset($config['appname']) ? ';APP='.$config['appname'] : ''; + + return "sqlsrv:Server={$host}{$port};Database={$database}{$appname}"; } }
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/Database/DatabaseEloquentHasOneTest.php
@@ -98,15 +98,24 @@ public function testModelsAreProperlyMatchedToParents() public function testRelationCountQueryCanBeBuilt() { $relation = $this->getRelation(); - $query = m::mock('Illuminate\Database\Eloquent\Builder'); - $query->shouldReceive('select')->once()->with(m::type('Illuminate\Database\Query\Expression')); + $builder = m::mock('Illuminate\Database\Eloquent\Builder'); + + $baseQuery = m::mock('Illuminate\Database\Query\Builder'); + $baseQuery->from = 'one'; + $parentQuery = m::mock('Illuminate\Database\Query\Builder'); + $parentQuery->from = 'two'; + + $builder->shouldReceive('getQuery')->once()->andReturn($baseQuery); + $builder->shouldReceive('getQuery')->once()->andReturn($parentQuery); + + $builder->shouldReceive('select')->once()->with(m::type('Illuminate\Database\Query\Expression')); $relation->getParent()->shouldReceive('getTable')->andReturn('table'); - $query->shouldReceive('where')->once()->with('table.foreign_key', '=', m::type('Illuminate\Database\Query\Expression')); + $builder->shouldReceive('where')->once()->with('table.foreign_key', '=', m::type('Illuminate\Database\Query\Expression')); $relation->getQuery()->shouldReceive('getQuery')->andReturn($parentQuery = m::mock('StdClass')); $parentQuery->shouldReceive('getGrammar')->once()->andReturn($grammar = m::mock('StdClass')); $grammar->shouldReceive('wrap')->once()->with('table.id'); - $relation->getRelationCountQuery($query, $query); + $relation->getRelationCountQuery($builder, $builder); }
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/Database/DatabaseMySqlSchemaGrammarTest.php
@@ -523,6 +523,16 @@ public function testAddingDateTime() $this->assertEquals('alter table `users` add `foo` datetime not null', $statements[0]); } + public function testAddingDateTimeTz() + { + $blueprint = new Blueprint('users'); + $blueprint->dateTimeTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table `users` add `foo` datetime not null', $statements[0]); + } + public function testAddingTime() { @@ -534,6 +544,15 @@ public function testAddingTime() $this->assertEquals('alter table `users` add `foo` time not null', $statements[0]); } + public function testAddingTimeTz() + { + $blueprint = new Blueprint('users'); + $blueprint->timeTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table `users` add `foo` time not null', $statements[0]); + } public function testAddingTimeStamp() { @@ -545,6 +564,15 @@ public function testAddingTimeStamp() $this->assertEquals('alter table `users` add `foo` timestamp default 0 not null', $statements[0]); } + public function testAddingTimeStampTz() + { + $blueprint = new Blueprint('users'); + $blueprint->timestampTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table `users` add `foo` timestamp default 0 not null', $statements[0]); + } public function testAddingTimeStamps() {
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/Database/DatabasePostgresSchemaGrammarTest.php
@@ -424,6 +424,15 @@ public function testAddingDateTime() $this->assertEquals('alter table "users" add column "foo" timestamp(0) without time zone not null', $statements[0]); } + public function testAddingDateTimeTz() + { + $blueprint = new Blueprint('users'); + $blueprint->dateTimeTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table "users" add column "foo" timestamp(0) with time zone not null', $statements[0]); + } public function testAddingTime() { @@ -435,6 +444,15 @@ public function testAddingTime() $this->assertEquals('alter table "users" add column "foo" time(0) without time zone not null', $statements[0]); } + public function testAddingTimeTz() + { + $blueprint = new Blueprint('users'); + $blueprint->timeTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table "users" add column "foo" time(0) with time zone not null', $statements[0]); + } public function testAddingTimeStamp() { @@ -446,6 +464,15 @@ public function testAddingTimeStamp() $this->assertEquals('alter table "users" add column "foo" timestamp(0) without time zone not null', $statements[0]); } + public function testAddingTimeStampTz() + { + $blueprint = new Blueprint('users'); + $blueprint->timestampTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table "users" add column "foo" timestamp(0) with time zone not null', $statements[0]); + } public function testAddingTimeStamps() {
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/Database/DatabaseSQLiteSchemaGrammarTest.php
@@ -364,6 +364,15 @@ public function testAddingDateTime() $this->assertEquals('alter table "users" add column "foo" datetime not null', $statements[0]); } + public function testAddingDateTimeTz() + { + $blueprint = new Blueprint('users'); + $blueprint->dateTimeTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table "users" add column "foo" datetime not null', $statements[0]); + } public function testAddingTime() { @@ -375,6 +384,16 @@ public function testAddingTime() $this->assertEquals('alter table "users" add column "foo" time not null', $statements[0]); } + public function testAddingTimeTz() + { + $blueprint = new Blueprint('users'); + $blueprint->timeTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table "users" add column "foo" time not null', $statements[0]); + } + public function testAddingTimeStamp() { @@ -386,6 +405,16 @@ public function testAddingTimeStamp() $this->assertEquals('alter table "users" add column "foo" datetime not null', $statements[0]); } + public function testAddingTimeStampTz() + { + $blueprint = new Blueprint('users'); + $blueprint->timestampTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table "users" add column "foo" datetime not null', $statements[0]); + } + public function testAddingTimeStamps() {
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/Database/DatabaseSqlServerSchemaGrammarTest.php
@@ -392,6 +392,15 @@ public function testAddingDateTime() $this->assertEquals('alter table "users" add "foo" datetime not null', $statements[0]); } + public function testAddingDateTimeTz() + { + $blueprint = new Blueprint('users'); + $blueprint->dateTimeTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table "users" add "foo" datetimeoffset(0) not null', $statements[0]); + } public function testAddingTime() { @@ -403,6 +412,16 @@ public function testAddingTime() $this->assertEquals('alter table "users" add "foo" time not null', $statements[0]); } + public function testAddingTimeTz() + { + $blueprint = new Blueprint('users'); + $blueprint->timeTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table "users" add "foo" time not null', $statements[0]); + } + public function testAddingTimeStamp() { @@ -414,6 +433,16 @@ public function testAddingTimeStamp() $this->assertEquals('alter table "users" add "foo" datetime not null', $statements[0]); } + public function testAddingTimeStampTz() + { + $blueprint = new Blueprint('users'); + $blueprint->timestampTz('foo'); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertEquals(1, count($statements)); + $this->assertEquals('alter table "users" add "foo" datetimeoffset(0) not null', $statements[0]); + } + public function testAddingTimeStamps() {
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/Session/SessionStoreTest.php
@@ -84,10 +84,17 @@ public function testSessionInvalidate() { $session = $this->getSession(); $oldId = $session->getId(); + $session->set('foo','bar'); $this->assertGreaterThan(0, count($session->all())); - $session->getHandler()->shouldReceive('destroy')->never(); + + $session->flash('name', 'Taylor'); + $this->assertTrue($session->has('name')); + + $session->getHandler()->shouldReceive('destroy')->once()->with($oldId); $this->assertTrue($session->invalidate()); + + $this->assertFalse($session->has('name')); $this->assertNotEquals($oldId, $session->getId()); $this->assertCount(0, $session->all()); }
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/Support/SupportCollectionTest.php
@@ -650,6 +650,28 @@ public function testRejectRemovesElementsPassingTruthTest() } + public function testSearchReturnsIndexOfFirstFoundItem() + { + $c = new Collection([1, 2, 3, 4, 5, 2, 5, 'foo' => 'bar']); + + $this->assertEquals(1, $c->search(2)); + $this->assertEquals('foo', $c->search('bar')); + $this->assertEquals(4, $c->search(function($value){ return $value > 4; })); + $this->assertEquals('foo', $c->search(function($value){ return ! is_numeric($value); })); + } + + + public function testSearchReturnsFalseWhenItemIsNotFound() + { + $c = new Collection([1, 2, 3, 4, 5, 'foo' => 'bar']); + + $this->assertFalse($c->search(6)); + $this->assertFalse($c->search('foo')); + $this->assertFalse($c->search(function($value){ return $value < 1 && is_numeric($value); })); + $this->assertFalse($c->search(function($value){ return $value == 'nope'; })); + } + + public function testKeys() { $c = new Collection(array('name' => 'taylor', 'framework' => 'laravel'));
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/Support/SupportHelpersTest.php
@@ -94,6 +94,13 @@ public function testArrayOnly() } + public function testArrayCollapse() + { + $array = [[1], [2], [3], ['foo', 'bar'], collect(['baz', 'boom'])]; + $this->assertEquals([1, 2, 3, 'foo', 'bar', 'baz', 'boom'], array_collapse($array)); + } + + public function testArrayDivide() { $array = array('name' => 'taylor');
true
Other
laravel
framework
330d11ba8cd3d6c0a54a1125943526b126147b5f.json
fix merge conflicts.
tests/View/ViewFactoryTest.php
@@ -342,6 +342,18 @@ public function testSectionFlushing() } + public function testHasSection() + { + $factory = $this->getFactory(); + $factory->startSection('foo'); + echo 'hi'; + $factory->stopSection(); + + $this->assertTrue($factory->hasSection('foo')); + $this->assertFalse($factory->hasSection('bar')); + } + + public function testMakeWithSlashAndDot() { $factory = $this->getFactory();
true
Other
laravel
framework
a8236fa1efaef9c23a763068d012e53a663bfe68.json
Add blank lines between test methods
tests/View/ViewBladeCompilerTest.php
@@ -646,6 +646,7 @@ public function testRetrieveDefaultEscapedContentTags() $this->assertEquals(['{{{', '}}}'], $compiler->getEscapedContentTags()); } + public function testSequentialCompileStringCalls() { $compiler = new BladeCompiler($this->getFiles(), __DIR__);
false
Other
laravel
framework
f0789b5b4585076d55793e5563b948380030dfe4.json
Add blank lines between test methods
tests/View/ViewBladeCompilerTest.php
@@ -70,6 +70,7 @@ public function testCompileSetAndGetThePath() $this->assertEquals('foo', $compiler->getPath()); } + public function testCompileWithPathSetBefore() { $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__); @@ -82,6 +83,7 @@ public function testCompileWithPathSetBefore() $this->assertEquals('foo', $compiler->getPath()); } + public function testCompileDoesntStoreFilesWhenCachePathIsNull() { $compiler = new BladeCompiler($files = $this->getFiles(), null);
false
Other
laravel
framework
1c8e24deee344668baf0bb40c78e286b361d6862.json
Fix Blade sequential compileString calls. Clear compilation artifacts ($this->footer) before starting another compilation. Issue is exposed when calling compileString() twice for templates with @extends directive.
src/Illuminate/View/Compilers/BladeCompiler.php
@@ -78,8 +78,6 @@ class BladeCompiler extends Compiler implements CompilerInterface { */ public function compile($path = null) { - $this->footer = array(); - if ($path) { $this->setPath($path); @@ -123,6 +121,8 @@ public function setPath($path) public function compileString($value) { $result = ''; + // reset compiler state before compilation + $this->footer = array(); // Here we will loop through all of the tokens returned by the Zend lexer and // parse each one into the corresponding valid PHP. We will then have this
true
Other
laravel
framework
1c8e24deee344668baf0bb40c78e286b361d6862.json
Fix Blade sequential compileString calls. Clear compilation artifacts ($this->footer) before starting another compilation. Issue is exposed when calling compileString() twice for templates with @extends directive.
tests/View/ViewBladeCompilerTest.php
@@ -646,6 +646,20 @@ public function testRetrieveDefaultEscapedContentTags() $this->assertEquals(['{{{', '}}}'], $compiler->getEscapedContentTags()); } + public function testSequentialCompileStringCalls() + { + $compiler = new BladeCompiler($this->getFiles(), __DIR__); + $string = '@extends(\'foo\') +test'; + $expected = "test".PHP_EOL.'<?php echo $__env->make(\'foo\', array_except(get_defined_vars(), array(\'__data\', \'__path\')))->render(); ?>'; + $this->assertEquals($expected, $compiler->compileString($string)); + + // use the same compiler instance to compile another template with @extends directive + $string = '@extends(name(foo))'.PHP_EOL.'test'; + $expected = "test".PHP_EOL.'<?php echo $__env->make(name(foo), array_except(get_defined_vars(), array(\'__data\', \'__path\')))->render(); ?>'; + $this->assertEquals($expected, $compiler->compileString($string)); + } + /** * @dataProvider testGetTagsProvider()
true
Other
laravel
framework
69e5c3c1daca84549a15ce3a96021ec914bf002a.json
Add security contact to readme
readme.md
@@ -22,6 +22,10 @@ Documentation for the framework can be found on the [Laravel website](http://lar Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions). +## Security Vulnerabilities + +If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylorotwell@gmail.com. All security vulnerabilities will be promptly addressed. + ### License The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
false
Other
laravel
framework
549bd4aa94c2dddbeb74630ffb5b8ddd4f4d7fbd.json
Extract credentials retrieval to method
src/Illuminate/Foundation/Auth/AuthenticatesAndRegistersUsers.php
@@ -61,7 +61,7 @@ public function postLogin(Request $request) 'email' => 'required|email', 'password' => 'required', ]); - $credentials = $request->only('email', 'password'); + $credentials = $this->getCredentials($request); if (Auth::attempt($credentials, $request->has('remember'))) { @@ -84,6 +84,18 @@ protected function getFailedLoginMessage() { return 'These credentials do not match our records.'; } + + /** + * Get needed for authorization credentials from request + * + * @param Request $request + * + * @return array + */ + protected function getCredentials(Request $request) + { + return $request->only('email', 'password'); + } /** * Log the user out of the application.
false
Other
laravel
framework
644e13583e940bf3e76c7c74640376683fa4ad40.json
Provide collection with final models in hydrate
src/Illuminate/Database/Eloquent/Model.php
@@ -491,12 +491,12 @@ public static function hydrate(array $items, $connection = null) { $instance = (new static)->setConnection($connection); - $collection = $instance->newCollection($items); - - return $collection->map(function ($item) use ($instance) + $items = array_map(function ($item) use ($instance) { return $instance->newFromBuilder($item); - }); + }, $items); + + return $instance->newCollection($items); } /**
false
Other
laravel
framework
f44f335e29dca1198814e45df473489cb18305cc.json
Add getter for the defferedService property. Added a simple getter method for the Application's deferredServices property.
src/Illuminate/Foundation/Application.php
@@ -940,6 +940,16 @@ public function getLoadedProviders() return $this->loadedProviders; } + /** + * Get the application's deferred services. + * + * @return array + */ + public function getDeferredServices() + { + return $this->deferredServices; + } + /** * Set the application's deferred services. *
false
Other
laravel
framework
decd163efff4537ec0d2648953d8baf654901a62.json
Add method to dynamically add a deferred service. Added a simple method onto the application class that allow users to add an item to the application's deferredServices array.
src/Illuminate/Foundation/Application.php
@@ -951,6 +951,17 @@ public function setDeferredServices(array $services) $this->deferredServices = $services; } + /** + * Add a service to the application's deferred services. + * + * @param string $service + * @return void + */ + public function addDeferredService($service) + { + $this->deferredServices[] = $service; + } + /** * Determine if the given service is a deferred service. *
false
Other
laravel
framework
682d6179bf8558e93176c03d6532cd744eae8705.json
Add test case for shorter statement
src/Illuminate/View/Compilers/BladeCompiler.php
@@ -264,7 +264,7 @@ protected function compileStatements($value) { $match[0] = $this->$method(array_get($match, 3)); } - else if (isset($this->statements[$match[1]])) + elseif (isset($this->statements[$match[1]])) { $match[0] = call_user_func($this->statements[$match[1]], array_get($match, 3)); }
true
Other
laravel
framework
682d6179bf8558e93176c03d6532cd744eae8705.json
Add test case for shorter statement
tests/View/ViewBladeCompilerTest.php
@@ -557,6 +557,19 @@ public function testCustomStatements() } + public function testCustomShortStatements() + { + $compiler = new BladeCompiler($this->getFiles(), __DIR__); + $compiler->addStatement('customControl', function($expression) { + return '<?php echo custom_control(); ?>'; + }); + + $string = '@customControl'; + $expected = '<?php echo custom_control(); ?>'; + $this->assertEquals($expected, $compiler->compileString($string)); + } + + public function testConfiguringContentTags() { $compiler = new BladeCompiler($this->getFiles(), __DIR__);
true
Other
laravel
framework
534689d354261155afd2d0321c16afcac063537f.json
Implement new mechanism for extending Blade. Instead of using outdated matcher methods, even custom tags are now matched my the same powerful regex that was contributed earlier. Extensions are also easier to write this way.
src/Illuminate/View/Compilers/BladeCompiler.php
@@ -9,6 +9,13 @@ class BladeCompiler extends Compiler implements CompilerInterface { */ protected $extensions = array(); + /** + * All custom statement handlers. + * + * @var array + */ + protected $statements = []; + /** * The file currently being compiled. * @@ -250,10 +257,17 @@ protected function compileStatements($value) { $callback = function($match) { + // Blade tags are usually compiled by equally-named + // methods. Users can also register their custom + // handler callbacks to resolve custom tags. if (method_exists($this, $method = 'compile'.ucfirst($match[1]))) { $match[0] = $this->$method(array_get($match, 3)); } + else if (isset($this->statements[$match[1]])) + { + $match[0] = call_user_func($this->statements[$match[1]], array_get($match, 3)); + } return isset($match[3]) ? $match[0] : $match[0].$match[2]; }; @@ -706,6 +720,18 @@ public function extend(callable $compiler) $this->extensions[] = $compiler; } + /** + * Register a handler for custom statements. + * + * @param string $name + * @param callable $handler + * @return void + */ + public function addStatement($name, callable $handler) + { + $this->statements[$name] = $handler; + } + /** * Sets the raw tags used for the compiler. *
false
Other
laravel
framework
73c88939d7b5e554741f6913a1d94cd441678e51.json
Add failing test for new custom statement handler.
tests/View/ViewBladeCompilerTest.php
@@ -540,6 +540,23 @@ public function testCustomExtensionsAreCompiled() } + public function testCustomStatements() + { + $compiler = new BladeCompiler($this->getFiles(), __DIR__); + $compiler->addStatement('customControl', function($expression) { + return "<?php echo custom_control{$expression}; ?>"; + }); + + $string = '@if($foo) +@customControl(10, $foo, \'bar\') +@endif'; + $expected = '<?php if($foo): ?> +<?php echo custom_control(10, $foo, \'bar\'); ?> +<?php endif; ?>'; + $this->assertEquals($expected, $compiler->compileString($string)); + } + + public function testConfiguringContentTags() { $compiler = new BladeCompiler($this->getFiles(), __DIR__);
false
Other
laravel
framework
5d93473b56b7ce481000902ec8f2e3c426be7c03.json
Fix path for namespaced translation overrides This change fixes #8302
src/Illuminate/Translation/FileLoader.php
@@ -87,7 +87,7 @@ protected function loadNamespaced($locale, $group, $namespace) */ protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace) { - $file = "{$this->path}/packages/{$locale}/{$namespace}/{$group}.php"; + $file = "{$this->path}/vendor/{$namespace}/{$locale}/{$group}.php"; if ($this->files->exists($file)) {
true
Other
laravel
framework
5d93473b56b7ce481000902ec8f2e3c426be7c03.json
Fix path for namespaced translation overrides This change fixes #8302
tests/Translation/TranslationFileLoaderTest.php
@@ -26,7 +26,7 @@ public function testLoadMethodWithNamespacesProperlyCallsLoader() { $loader = new FileLoader($files = m::mock('Illuminate\Filesystem\Filesystem'), __DIR__); $files->shouldReceive('exists')->once()->with('bar/en/foo.php')->andReturn(true); - $files->shouldReceive('exists')->once()->with(__DIR__.'/packages/en/namespace/foo.php')->andReturn(false); + $files->shouldReceive('exists')->once()->with(__DIR__.'/vendor/namespace/en/foo.php')->andReturn(false); $files->shouldReceive('getRequire')->once()->with('bar/en/foo.php')->andReturn(array('foo' => 'bar')); $loader->addNamespace('namespace', 'bar'); @@ -38,9 +38,9 @@ public function testLoadMethodWithNamespacesProperlyCallsLoaderAndLoadsLocalOver { $loader = new FileLoader($files = m::mock('Illuminate\Filesystem\Filesystem'), __DIR__); $files->shouldReceive('exists')->once()->with('bar/en/foo.php')->andReturn(true); - $files->shouldReceive('exists')->once()->with(__DIR__.'/packages/en/namespace/foo.php')->andReturn(true); + $files->shouldReceive('exists')->once()->with(__DIR__.'/vendor/namespace/en/foo.php')->andReturn(true); $files->shouldReceive('getRequire')->once()->with('bar/en/foo.php')->andReturn(array('foo' => 'bar')); - $files->shouldReceive('getRequire')->once()->with(__DIR__.'/packages/en/namespace/foo.php')->andReturn(array('foo' => 'override', 'baz' => 'boom')); + $files->shouldReceive('getRequire')->once()->with(__DIR__.'/vendor/namespace/en/foo.php')->andReturn(array('foo' => 'override', 'baz' => 'boom')); $loader->addNamespace('namespace', 'bar'); $this->assertEquals(array('foo' => 'override', 'baz' => 'boom'), $loader->load('en', 'foo', 'namespace'));
true
Other
laravel
framework
2f01b93c9e918dc83532aa19a8960a3c810c0357.json
Remove old matcher methods
src/Illuminate/View/Compilers/BladeCompiler.php
@@ -706,39 +706,6 @@ public function extend(callable $compiler) $this->extensions[] = $compiler; } - /** - * Get the regular expression for a generic Blade function. - * - * @param string $function - * @return string - */ - public function createMatcher($function) - { - return '/(?<!\w)(\s*)@'.$function.'(\s*\(.*\))/'; - } - - /** - * Get the regular expression for a generic Blade function. - * - * @param string $function - * @return string - */ - public function createOpenMatcher($function) - { - return '/(?<!\w)(\s*)@'.$function.'(\s*\(.*)\)/'; - } - - /** - * Create a plain Blade matcher. - * - * @param string $function - * @return string - */ - public function createPlainMatcher($function) - { - return '/(?<!\w)(\s*)@'.$function.'(\s*)/'; - } - /** * Sets the raw tags used for the compiler. *
true
Other
laravel
framework
2f01b93c9e918dc83532aa19a8960a3c810c0357.json
Remove old matcher methods
tests/View/ViewBladeCompilerTest.php
@@ -540,50 +540,6 @@ public function testCustomExtensionsAreCompiled() } - public function testCreateMatcher() - { - $compiler = new BladeCompiler($this->getFiles(), __DIR__); - $compiler->extend( - function($view, BladeCompiler $compiler) - { - $pattern = $compiler->createMatcher('customControl'); - $replace = '<?php echo custom_control$2; ?>'; - return preg_replace($pattern, '$1'.$replace, $view); - } - ); - - $string = '@if($foo) -@customControl(10, $foo, \'bar\') -@endif'; - $expected = '<?php if($foo): ?> -<?php echo custom_control(10, $foo, \'bar\'); ?> -<?php endif; ?>'; - $this->assertEquals($expected, $compiler->compileString($string)); - } - - - public function testCreatePlainMatcher() - { - $compiler = new BladeCompiler($this->getFiles(), __DIR__); - $compiler->extend( - function($view, BladeCompiler $compiler) - { - $pattern = $compiler->createPlainMatcher('customControl'); - $replace = '<?php echo custom_control; ?>'; - return preg_replace($pattern, '$1'.$replace.'$2', $view); - } - ); - - $string = '@if($foo) -@customControl -@endif'; - $expected = '<?php if($foo): ?> -<?php echo custom_control; ?> -<?php endif; ?>'; - $this->assertEquals($expected, $compiler->compileString($string)); - } - - public function testConfiguringContentTags() { $compiler = new BladeCompiler($this->getFiles(), __DIR__);
true
Other
laravel
framework
118dede7e042dc1678fbfd4320471a6e0ffa1ecf.json
Add zip function to Collection Inspired by Ruby and Python: http://apidock.com/ruby/Array/zip
src/Illuminate/Support/Collection.php
@@ -762,6 +762,28 @@ protected function valueRetriever($value) }; } + /** + * Zip the collection together with one or more arrays + * + * e.g. new Collection([1, 2, 3])->zip([4, 5, 6]); + * => [[1, 4], [2, 5], [3, 6]] + * + * @param \Illuminate\Support\Collection|\Illuminate\Contracts\Support\Arrayable|array ...$items + * @return static + */ + public function zip($items) + { + $arrayableItems = array_map(function ($items) { + return $this->getArrayableItems($items); + }, func_get_args()); + + $params = array_merge([function () { + return new static(func_get_args()); + }, $this->items], $arrayableItems); + + return new static(call_user_func_array('array_map', $params)); + } + /** * Get the collection of items as a plain array. *
true
Other
laravel
framework
118dede7e042dc1678fbfd4320471a6e0ffa1ecf.json
Add zip function to Collection Inspired by Ruby and Python: http://apidock.com/ruby/Array/zip
tests/Support/SupportCollectionTest.php
@@ -630,6 +630,35 @@ public function testPaginate() $this->assertEquals([], $c->forPage(3, 2)->all()); } + + public function testZip() + { + $c = new Collection([1, 2, 3]); + $c = $c->zip(new Collection([4, 5, 6])); + $this->assertInstanceOf('Illuminate\Support\Collection', $c); + $this->assertInstanceOf('Illuminate\Support\Collection', $c[0]); + $this->assertInstanceOf('Illuminate\Support\Collection', $c[1]); + $this->assertInstanceOf('Illuminate\Support\Collection', $c[2]); + $this->assertEquals(3, $c->count()); + $this->assertEquals([1, 4], $c[0]->all()); + $this->assertEquals([2, 5], $c[1]->all()); + $this->assertEquals([3, 6], $c[2]->all()); + + $c = new Collection([1, 2, 3]); + $c = $c->zip([4, 5, 6], [7, 8, 9]); + $this->assertEquals(3, $c->count()); + $this->assertEquals([1, 4, 7], $c[0]->all()); + $this->assertEquals([2, 5, 8], $c[1]->all()); + $this->assertEquals([3, 6, 9], $c[2]->all()); + + $c = new Collection([1, 2, 3]); + $c = $c->zip([4, 5, 6], [7]); + $this->assertEquals(3, $c->count()); + $this->assertEquals([1, 4, 7], $c[0]->all()); + $this->assertEquals([2, 5, null], $c[1]->all()); + $this->assertEquals([3, 6, null], $c[2]->all()); + } + } class TestAccessorEloquentTestStub
true
Other
laravel
framework
b825a3c197249f468f3525f5ffd4c2f0987e8a66.json
Enclose PostgreSQL schema name with double quotes Schema names must be enclosed with double quotes to prevent PDOException while setting search path to a alphanumerical value. Following exception is from a production environment (v4.2.17). (Note that the first id is trimmed version of the second id) [PDOException] SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "d959d1fa9f6f2831c1d13ff05baed" LINE 1: set search_path to 397d959d1fa9f6f2831c1d13ff05baed
src/Illuminate/Database/Connectors/PostgresConnector.php
@@ -54,7 +54,7 @@ public function connect(array $config) { $schema = $config['schema']; - $connection->prepare("set search_path to {$schema}")->execute(); + $connection->prepare("set search_path to \"{$schema}\"")->execute(); } return $connection;
true
Other
laravel
framework
b825a3c197249f468f3525f5ffd4c2f0987e8a66.json
Enclose PostgreSQL schema name with double quotes Schema names must be enclosed with double quotes to prevent PDOException while setting search path to a alphanumerical value. Following exception is from a production environment (v4.2.17). (Note that the first id is trimmed version of the second id) [PDOException] SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "d959d1fa9f6f2831c1d13ff05baed" LINE 1: set search_path to 397d959d1fa9f6f2831c1d13ff05baed
tests/Database/DatabaseConnectorTest.php
@@ -71,7 +71,7 @@ public function testPostgresSearchPathIsSet() $connector->expects($this->once())->method('getOptions')->with($this->equalTo($config))->will($this->returnValue(array('options'))); $connector->expects($this->once())->method('createConnection')->with($this->equalTo($dsn), $this->equalTo($config), $this->equalTo(array('options')))->will($this->returnValue($connection)); $connection->shouldReceive('prepare')->once()->with('set names \'utf8\'')->andReturn($connection); - $connection->shouldReceive('prepare')->once()->with("set search_path to public")->andReturn($connection); + $connection->shouldReceive('prepare')->once()->with('set search_path to "public"')->andReturn($connection); $connection->shouldReceive('execute')->twice(); $result = $connector->connect($config);
true
Other
laravel
framework
7ce580c88bbfc131a5562a8913a8a3c2d8e6546e.json
Add dropIfExists() support for SQL Server SQL Server is currently the only driver lacking dropIfExists() support, giving no warning when it is used. This solution was tested on Windows Server 2012 running SQL Server 2014 and should be compatible with SQL Server going all the way back to v7. The other drivers use `$this->wrapTable($blueprint)` which wraps the table name in double quotes. SQL server choked on this, so I've used `$blueprint->getTable()` instead. Hope that won't be a problem. See [this StackOverflow discussion](http://stackoverflow.com/a/14290099/161752) for more details.
src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php
@@ -132,6 +132,18 @@ public function compileDrop(Blueprint $blueprint, Fluent $command) return 'drop table '.$this->wrapTable($blueprint); } + /** + * Compile a drop table (if exists) command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropIfExists(Blueprint $blueprint, Fluent $command) + { + return 'if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = \''.$blueprint->getTable().'\') drop table '.$blueprint->getTable(); + } + /** * Compile a drop column command. *
false
Other
laravel
framework
357c2664825911d53cbb9c43e7d5305b2161e2e8.json
Remove dead code (stubs) in test classes
tests/Bus/BusDispatcherTest.php
@@ -139,13 +139,6 @@ public function handle() } } -class BusDispatcherTestBasicHandler { - public function handle(BusDispatcherTestBasicCommand $command) - { - - } -} - class BusDispatcherTestQueuedHandler implements Illuminate\Contracts\Queue\ShouldBeQueued { }
true
Other
laravel
framework
357c2664825911d53cbb9c43e7d5305b2161e2e8.json
Remove dead code (stubs) in test classes
tests/Database/DatabaseEloquentBuilderTest.php
@@ -513,21 +513,13 @@ protected function getMockQueryBuilder() } -class EloquentBuilderTestModelStub extends Illuminate\Database\Eloquent\Model {} - class EloquentBuilderTestScopeStub extends Illuminate\Database\Eloquent\Model { public function scopeApproved($query) { $query->where('foo', 'bar'); } } -class EloquentBuilderTestWithTrashedStub extends Illuminate\Database\Eloquent\Model { - use Illuminate\Database\Eloquent\SoftDeletes; - protected $table = 'table'; - public function getKeyName() { return 'foo'; } -} - class EloquentBuilderTestNestedStub extends Illuminate\Database\Eloquent\Model { protected $table = 'table'; use Illuminate\Database\Eloquent\SoftDeletes;
true
Other
laravel
framework
357c2664825911d53cbb9c43e7d5305b2161e2e8.json
Remove dead code (stubs) in test classes
tests/Database/DatabaseEloquentMorphTest.php
@@ -205,13 +205,6 @@ protected function getManyRelation() class EloquentMorphResetModelStub extends Illuminate\Database\Eloquent\Model {} -class EloquentMorphResetBuilderStub extends Illuminate\Database\Eloquent\Builder { - public function __construct() { $this->query = new EloquentRelationQueryStub; } - public function getModel() { return new EloquentMorphResetModelStub; } - public function isSoftDeleting() { return false; } -} - - class EloquentMorphQueryStub extends Illuminate\Database\Query\Builder { public function __construct() {} }
true
Other
laravel
framework
357c2664825911d53cbb9c43e7d5305b2161e2e8.json
Remove dead code (stubs) in test classes
tests/Database/DatabaseEloquentPivotTest.php
@@ -91,8 +91,6 @@ public function testDeleteMethodDeletesModelByKeys() } -class DatabaseEloquentPivotTestModelStub extends Illuminate\Database\Eloquent\Model {} - class DatabaseEloquentPivotTestDateStub extends Illuminate\Database\Eloquent\Relations\Pivot { public function getDates() {
true
Other
laravel
framework
357c2664825911d53cbb9c43e7d5305b2161e2e8.json
Remove dead code (stubs) in test classes
tests/Database/DatabaseEloquentRelationTest.php
@@ -76,16 +76,6 @@ public function getQuery() } -class EloquentRelationResetStub extends Illuminate\Database\Eloquent\Builder { - public function __construct() { $this->query = new EloquentRelationQueryStub; } - public function getModel() { return new EloquentRelationResetModelStub; } -} - - -class EloquentRelationQueryStub extends Illuminate\Database\Query\Builder { - public function __construct() {} -} - class EloquentRelationStub extends \Illuminate\Database\Eloquent\Relations\Relation { public function addConstraints() {} public function addEagerConstraints(array $models) {}
true
Other
laravel
framework
357c2664825911d53cbb9c43e7d5305b2161e2e8.json
Remove dead code (stubs) in test classes
tests/Database/DatabaseSoftDeletingScopeTest.php
@@ -107,17 +107,3 @@ public function testOnlyTrashedExtension() } } - - -class DatabaseSoftDeletingScopeBuilderStub { - public $extensions = []; - public $onDelete; - public function extend($name, $callback) - { - $this->extensions[$name] = $callback; - } - public function onDelete($callback) - { - $this->onDelete = $callback; - } -}
true
Other
laravel
framework
357c2664825911d53cbb9c43e7d5305b2161e2e8.json
Remove dead code (stubs) in test classes
tests/Foundation/FoundationApplicationTest.php
@@ -135,33 +135,6 @@ public function testEnvironment() } -class ApplicationCustomExceptionHandlerStub extends Illuminate\Foundation\Application { - - public function prepareResponse($value) - { - $response = m::mock('Symfony\Component\HttpFoundation\Response'); - $response->shouldReceive('send')->once(); - return $response; - } - - protected function setExceptionHandler(Closure $handler) { return $handler; } - -} - -class ApplicationKernelExceptionHandlerStub extends Illuminate\Foundation\Application { - - protected function setExceptionHandler(Closure $handler) { return $handler; } - -} - -class ApplicationGetMiddlewaresStub extends Illuminate\Foundation\Application -{ - public function getMiddlewares() - { - return $this->middlewares; - } -} - class ApplicationDeferredSharedServiceProviderStub extends Illuminate\Support\ServiceProvider { protected $defer = true; public function register()
true
Other
laravel
framework
357c2664825911d53cbb9c43e7d5305b2161e2e8.json
Remove dead code (stubs) in test classes
tests/Validation/ValidationValidatorTest.php
@@ -1443,10 +1443,3 @@ protected function getRealTranslator() } } - - -class ValidatorTestAfterCallbackStub { - public function validate() { - $_SERVER['__validator.after.test'] = true; - } -}
true
Other
laravel
framework
c15fd12dc866a602dbc27a03366fa3b53bd06466.json
Remove unnecessary is_null check.
src/Illuminate/Database/Eloquent/Model.php
@@ -1622,19 +1622,16 @@ public function touchOwners() { $this->$relation()->touch(); - if ( ! is_null($this->$relation)) + if ($this->$relation instanceof Model) { - if ($this->$relation instanceof Model) - { - $this->$relation->touchOwners(); - } - elseif ($this->$relation instanceof Collection) + $this->$relation->touchOwners(); + } + elseif ($this->$relation instanceof Collection) + { + $this->$relation->each(function (Model $relation) { - $this->$relation->each(function (Model $relation) - { - $relation->touchOwners(); - }); - } + $relation->touchOwners(); + }); } } }
false
Other
laravel
framework
51249415072614aada9f2bb51d9340d687f71a24.json
Reduce is_null call.
src/Illuminate/Database/Eloquent/Model.php
@@ -1622,16 +1622,19 @@ public function touchOwners() { $this->$relation()->touch(); - if ( ! is_null($this->$relation) && $this->$relation instanceof Model) + if ( ! is_null($this->$relation)) { - $this->$relation->touchOwners(); - } - elseif ( ! is_null($this->$relation) && $this->$relation instanceof Collection) - { - $this->$relation->each(function (Model $relation) + if ($this->$relation instanceof Model) + { + $this->$relation->touchOwners(); + } + elseif ($this->$relation instanceof Collection) { - $relation->touchOwners(); - }); + $this->$relation->each(function (Model $relation) + { + $relation->touchOwners(); + }); + } } } }
false
Other
laravel
framework
deebda1e4a02fe901b83bacaf35a53da9606c1e1.json
Fix touchOwners() on many to many relationship.
src/Illuminate/Database/Eloquent/Model.php
@@ -1622,10 +1622,17 @@ public function touchOwners() { $this->$relation()->touch(); - if ( ! is_null($this->$relation)) + if ( ! is_null($this->$relation) && $this->$relation instanceof Model) { $this->$relation->touchOwners(); } + elseif ( ! is_null($this->$relation) && $this->$relation instanceof Collection) + { + $this->$relation->each(function (Model $relation) + { + $relation->touchOwners(); + }); + } } }
false
Other
laravel
framework
8e211ead462c96929fd31392a000c417840955bc.json
fix wrong indention
src/Illuminate/Database/Schema/Builder.php
@@ -5,240 +5,240 @@ class Builder { - /** - * The database connection instance. - * - * @var \Illuminate\Database\Connection - */ - protected $connection; - - /** - * The schema grammar instance. - * - * @var \Illuminate\Database\Schema\Grammars\Grammar - */ - protected $grammar; - - /** - * The Blueprint resolver callback. - * - * @var \Closure - */ - protected $resolver; - - /** - * Create a new database Schema manager. - * - * @param \Illuminate\Database\Connection $connection - * @return void - */ - public function __construct(Connection $connection) - { - $this->connection = $connection; - $this->grammar = $connection->getSchemaGrammar(); - } - - /** - * Determine if the given table exists. - * - * @param string $table - * @return bool - */ - public function hasTable($table) - { - $sql = $this->grammar->compileTableExists(); - - $table = $this->connection->getTablePrefix().$table; - - return count($this->connection->select($sql, array($table))) > 0; - } - - /** - * Determine if the given table has a given column. - * - * @param string $table - * @param string $column - * @return bool - */ - public function hasColumn($table, $column) - { - $column = strtolower($column); - - return in_array($column, array_map('strtolower', $this->getColumnListing($table))); - } - - /** - * Determine if the given table has given columns. - * - * @param string $table - * @param array $columns - * @return bool - */ - public function hasColumns($table, array $columns) - { - $tableColumns = $this->getColumnListing($table); - - array_map('strtolower', $tableColumns); - - foreach ($columns as $column) - { - if ( ! in_array(strtolower($column), $tableColumns)) return false; - } - - return true; - } - - /** - * Get the column listing for a given table. - * - * @param string $table - * @return array - */ - public function getColumnListing($table) - { - $table = $this->connection->getTablePrefix().$table; - - $results = $this->connection->select($this->grammar->compileColumnExists($table)); - - return $this->connection->getPostProcessor()->processColumnListing($results); - } - - /** - * Modify a table on the schema. - * - * @param string $table - * @param \Closure $callback - * @return \Illuminate\Database\Schema\Blueprint - */ - public function table($table, Closure $callback) - { - $this->build($this->createBlueprint($table, $callback)); - } - - /** - * Create a new table on the schema. - * - * @param string $table - * @param \Closure $callback - * @return \Illuminate\Database\Schema\Blueprint - */ - public function create($table, Closure $callback) - { - $blueprint = $this->createBlueprint($table); - - $blueprint->create(); - - $callback($blueprint); - - $this->build($blueprint); - } - - /** - * Drop a table from the schema. - * - * @param string $table - * @return \Illuminate\Database\Schema\Blueprint - */ - public function drop($table) - { - $blueprint = $this->createBlueprint($table); - - $blueprint->drop(); - - $this->build($blueprint); - } - - /** - * Drop a table from the schema if it exists. - * - * @param string $table - * @return \Illuminate\Database\Schema\Blueprint - */ - public function dropIfExists($table) - { - $blueprint = $this->createBlueprint($table); - - $blueprint->dropIfExists(); - - $this->build($blueprint); - } - - /** - * Rename a table on the schema. - * - * @param string $from - * @param string $to - * @return \Illuminate\Database\Schema\Blueprint - */ - public function rename($from, $to) - { - $blueprint = $this->createBlueprint($from); - - $blueprint->rename($to); - - $this->build($blueprint); - } - - /** - * Execute the blueprint to build / modify the table. - * - * @param \Illuminate\Database\Schema\Blueprint $blueprint - * @return void - */ - protected function build(Blueprint $blueprint) - { - $blueprint->build($this->connection, $this->grammar); - } - - /** - * Create a new command set with a Closure. - * - * @param string $table - * @param \Closure|null $callback - * @return \Illuminate\Database\Schema\Blueprint - */ - protected function createBlueprint($table, Closure $callback = null) - { - if (isset($this->resolver)) - { - return call_user_func($this->resolver, $table, $callback); - } - - return new Blueprint($table, $callback); - } - - /** - * Get the database connection instance. - * - * @return \Illuminate\Database\Connection - */ - public function getConnection() - { - return $this->connection; - } - - /** - * Set the database connection instance. - * - * @param \Illuminate\Database\Connection - * @return $this - */ - public function setConnection(Connection $connection) - { - $this->connection = $connection; - - return $this; - } - - /** - * Set the Schema Blueprint resolver callback. - * - * @param \Closure $resolver - * @return void - */ - public function blueprintResolver(Closure $resolver) - { - $this->resolver = $resolver; - } + /** + * The database connection instance. + * + * @var \Illuminate\Database\Connection + */ + protected $connection; + + /** + * The schema grammar instance. + * + * @var \Illuminate\Database\Schema\Grammars\Grammar + */ + protected $grammar; + + /** + * The Blueprint resolver callback. + * + * @var \Closure + */ + protected $resolver; + + /** + * Create a new database Schema manager. + * + * @param \Illuminate\Database\Connection $connection + * @return void + */ + public function __construct(Connection $connection) + { + $this->connection = $connection; + $this->grammar = $connection->getSchemaGrammar(); + } + + /** + * Determine if the given table exists. + * + * @param string $table + * @return bool + */ + public function hasTable($table) + { + $sql = $this->grammar->compileTableExists(); + + $table = $this->connection->getTablePrefix().$table; + + return count($this->connection->select($sql, array($table))) > 0; + } + + /** + * Determine if the given table has a given column. + * + * @param string $table + * @param string $column + * @return bool + */ + public function hasColumn($table, $column) + { + $column = strtolower($column); + + return in_array($column, array_map('strtolower', $this->getColumnListing($table))); + } + + /** + * Determine if the given table has given columns. + * + * @param string $table + * @param array $columns + * @return bool + */ + public function hasColumns($table, array $columns) + { + $tableColumns = $this->getColumnListing($table); + + array_map('strtolower', $tableColumns); + + foreach ($columns as $column) + { + if ( ! in_array(strtolower($column), $tableColumns)) return false; + } + + return true; + } + + /** + * Get the column listing for a given table. + * + * @param string $table + * @return array + */ + public function getColumnListing($table) + { + $table = $this->connection->getTablePrefix().$table; + + $results = $this->connection->select($this->grammar->compileColumnExists($table)); + + return $this->connection->getPostProcessor()->processColumnListing($results); + } + + /** + * Modify a table on the schema. + * + * @param string $table + * @param \Closure $callback + * @return \Illuminate\Database\Schema\Blueprint + */ + public function table($table, Closure $callback) + { + $this->build($this->createBlueprint($table, $callback)); + } + + /** + * Create a new table on the schema. + * + * @param string $table + * @param \Closure $callback + * @return \Illuminate\Database\Schema\Blueprint + */ + public function create($table, Closure $callback) + { + $blueprint = $this->createBlueprint($table); + + $blueprint->create(); + + $callback($blueprint); + + $this->build($blueprint); + } + + /** + * Drop a table from the schema. + * + * @param string $table + * @return \Illuminate\Database\Schema\Blueprint + */ + public function drop($table) + { + $blueprint = $this->createBlueprint($table); + + $blueprint->drop(); + + $this->build($blueprint); + } + + /** + * Drop a table from the schema if it exists. + * + * @param string $table + * @return \Illuminate\Database\Schema\Blueprint + */ + public function dropIfExists($table) + { + $blueprint = $this->createBlueprint($table); + + $blueprint->dropIfExists(); + + $this->build($blueprint); + } + + /** + * Rename a table on the schema. + * + * @param string $from + * @param string $to + * @return \Illuminate\Database\Schema\Blueprint + */ + public function rename($from, $to) + { + $blueprint = $this->createBlueprint($from); + + $blueprint->rename($to); + + $this->build($blueprint); + } + + /** + * Execute the blueprint to build / modify the table. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @return void + */ + protected function build(Blueprint $blueprint) + { + $blueprint->build($this->connection, $this->grammar); + } + + /** + * Create a new command set with a Closure. + * + * @param string $table + * @param \Closure|null $callback + * @return \Illuminate\Database\Schema\Blueprint + */ + protected function createBlueprint($table, Closure $callback = null) + { + if (isset($this->resolver)) + { + return call_user_func($this->resolver, $table, $callback); + } + + return new Blueprint($table, $callback); + } + + /** + * Get the database connection instance. + * + * @return \Illuminate\Database\Connection + */ + public function getConnection() + { + return $this->connection; + } + + /** + * Set the database connection instance. + * + * @param \Illuminate\Database\Connection + * @return $this + */ + public function setConnection(Connection $connection) + { + $this->connection = $connection; + + return $this; + } + + /** + * Set the Schema Blueprint resolver callback. + * + * @param \Closure $resolver + * @return void + */ + public function blueprintResolver(Closure $resolver) + { + $this->resolver = $resolver; + } } \ No newline at end of file
false
Other
laravel
framework
153094586e49be5d7176eba991f6cb20aa31bfd6.json
Use header() function
src/Illuminate/Http/Response.php
@@ -31,7 +31,7 @@ public function setContent($content) // from routes that will be automatically transformed to their JSON form. if ($this->shouldBeJson($content)) { - $this->headers->set('Content-Type', 'application/json'); + $this->header('Content-Type', 'application/json'); $content = $this->morphToJson($content); }
false
Other
laravel
framework
ae4ff8e705ba9f3f6e6c2dc9e758ceb03446d1b9.json
Add missing curly brackets
src/Illuminate/Foundation/Application.php
@@ -479,7 +479,9 @@ public function registerConfiguredProviders() public function register($provider, $options = array(), $force = false) { if ($registered = $this->getProvider($provider) && ! $force) - return $registered; + { + return $registered; + } // If the given "provider" is a string, we will resolve it, passing in the // application instance automatically for the developer. This is simply
true
Other
laravel
framework
ae4ff8e705ba9f3f6e6c2dc9e758ceb03446d1b9.json
Add missing curly brackets
src/Illuminate/Routing/Route.php
@@ -125,10 +125,14 @@ public function run(Request $request) try { if ( ! is_string($this->action['uses'])) + { return $this->runCallable($request); + } if ($this->customDispatcherIsBound()) + { return $this->runWithCustomDispatcher($request); + } return $this->runController($request); } @@ -168,7 +172,9 @@ protected function runController(Request $request) ); if ( ! method_exists($instance = $this->container->make($class), $method)) + { throw new NotFoundHttpException; + } return call_user_func_array([$instance, $method], $parameters); }
true
Other
laravel
framework
705ccb731cd65574b047c945a71a9adb60f078b9.json
Use unguarded method for forceFill and forceCreate
src/Illuminate/Database/Eloquent/Model.php
@@ -416,13 +416,15 @@ public function fill(array $attributes) */ public function forceFill(array $attributes) { - static::unguard(); - - $this->fill($attributes); - - static::reguard(); + // Since some versions of PHP have a bug that prevents it from properly + // binding the late static context in a closure, we will first store + // the model in a variable, which we will then use in the closure. + $model = $this; - return $this; + return static::unguarded(function() use ($model, $attributes) + { + return $model->fill($attributes); + }); } /** @@ -537,18 +539,15 @@ public static function create(array $attributes) */ public static function forceCreate(array $attributes) { - if (static::$unguarded) - { - return static::create($attributes); - } - - static::unguard(); + // Since some versions of PHP have a bug that prevents it from properly + // binding the late static context in a closure, we will first store + // the model in a variable, which we will then use in the closure. + $model = new static; - $model = static::create($attributes); - - static::reguard(); - - return $model; + return static::unguarded(function() use ($model, $attributes) + { + return $model->create($attributes); + }); } /**
true
Other
laravel
framework
705ccb731cd65574b047c945a71a9adb60f078b9.json
Use unguarded method for forceFill and forceCreate
tests/Database/DatabaseEloquentModelTest.php
@@ -105,6 +105,15 @@ public function testCreateMethodSavesNewModel() } + public function testForceCreateMethodSavesNewModelWithGuardedAttributes() + { + $_SERVER['__eloquent.saved'] = false; + $model = EloquentModelSaveStub::forceCreate(['id' => 21]); + $this->assertTrue($_SERVER['__eloquent.saved']); + $this->assertEquals(21, $model->id); + } + + public function testFindMethodCallsQueryBuilderCorrectly() { $result = EloquentModelFindStub::find(1); @@ -705,6 +714,13 @@ public function testFillable() } + public function testForceFillMethodFillsGuardedAttributes() + { + $model = (new EloquentModelSaveStub)->forceFill(['id' => 21]); + $this->assertEquals(21, $model->id); + } + + public function testUnguardAllowsAnythingToBeSet() { $model = new EloquentModelStub; @@ -1300,7 +1316,7 @@ public function getDates() class EloquentModelSaveStub extends Model { protected $table = 'save_stub'; - protected $guarded = array(); + protected $guarded = ['id']; public function save(array $options = array()) { $_SERVER['__eloquent.saved'] = true; } public function setIncrementing($value) {
true
Other
laravel
framework
dfc6bb040994806f8d56fa995b2818209fd2ad59.json
Replace some spaces with tabs
tests/Mail/MailMandrillTransportTest.php
@@ -2,44 +2,44 @@ class MailMandrillTransportTest extends PHPUnit_Framework_TestCase { - public function testSend() - { - $message = new Swift_Message('Foo subject', 'Bar body'); - $message->setTo('me@example.com'); - $message->setBcc('you@example.com'); - - $transport = new MandrillTransportStub('testkey'); - $client = $this->getMock('GuzzleHttp\Client', array('post')); - $transport->setHttpClient($client); - - $client->expects($this->once()) - ->method('post') - ->with($this->equalTo('https://mandrillapp.com/api/1.0/messages/send-raw.json'), - $this->equalTo([ - 'body' => [ - 'key' => 'testkey', - 'raw_message' => $message->toString(), - 'async' => false, - 'to' => ['me@example.com', 'you@example.com'] - ] - ]) - ); - - $transport->send($message); - } + public function testSend() + { + $message = new Swift_Message('Foo subject', 'Bar body'); + $message->setTo('me@example.com'); + $message->setBcc('you@example.com'); + + $transport = new MandrillTransportStub('testkey'); + $client = $this->getMock('GuzzleHttp\Client', array('post')); + $transport->setHttpClient($client); + + $client->expects($this->once()) + ->method('post') + ->with($this->equalTo('https://mandrillapp.com/api/1.0/messages/send-raw.json'), + $this->equalTo([ + 'body' => [ + 'key' => 'testkey', + 'raw_message' => $message->toString(), + 'async' => false, + 'to' => ['me@example.com', 'you@example.com'] + ] + ]) + ); + + $transport->send($message); + } } class MandrillTransportStub extends \Illuminate\Mail\Transport\MandrillTransport { - protected $client; + protected $client; - protected function getHttpClient() - { - return $this->client; - } + protected function getHttpClient() + { + return $this->client; + } - public function setHttpClient($client) - { - $this->client = $client; - } + public function setHttpClient($client) + { + $this->client = $client; + } }
false
Other
laravel
framework
cca3c44078d458e9013e6788f40744907a9af616.json
Fix some tests
tests/Cookie/CookieTest.php
@@ -69,7 +69,7 @@ public function testUnqueue() { $cookie = $this->getCreator(); $cookie->queue($cookie->make('foo','bar')); - $this->assertArrayHasKey('foo',$cookie->getQueuedCookies()); + $this->assertArrayHasKey('foo', $cookie->getQueuedCookies()); $cookie->unqueue('foo'); $this->assertEmpty($cookie->getQueuedCookies()); }
true
Other
laravel
framework
cca3c44078d458e9013e6788f40744907a9af616.json
Fix some tests
tests/Database/DatabaseEloquentModelTest.php
@@ -55,7 +55,7 @@ public function testCalculatedAttributes() $attributes = $model->getAttributes(); // ensure password attribute was not set to null - $this->assertFalse(array_key_exists('password', $attributes)); + $this->assertArrayNotHasKey('password', $attributes); $this->assertEquals('******', $model->password); $this->assertEquals('5ebe2294ecd0e0f08eab7690d2a6ee69', $attributes['password_hash']); $this->assertEquals('5ebe2294ecd0e0f08eab7690d2a6ee69', $model->password_hash);
true
Other
laravel
framework
cca3c44078d458e9013e6788f40744907a9af616.json
Fix some tests
tests/Database/DatabaseEloquentRelationTest.php
@@ -14,10 +14,10 @@ public function tearDown() public function testSetRelationFail() { $parent = new EloquentRelationResetModelStub; - $relation =new EloquentRelationResetModelStub; - $parent->setRelation('test',$relation); - $parent->setRelation('foo','bar'); - $this->assertTrue(!array_key_exists('foo', $parent->toArray())); + $relation = new EloquentRelationResetModelStub; + $parent->setRelation('test', $relation); + $parent->setRelation('foo', 'bar'); + $this->assertArrayNotHasKey('foo', $parent->toArray()); }
true
Other
laravel
framework
cca3c44078d458e9013e6788f40744907a9af616.json
Fix some tests
tests/Session/SessionStoreTest.php
@@ -70,13 +70,13 @@ public function testCantSetInvalidId() $session = $this->getSession(); $session->setId(null); - $this->assertFalse(null == $session->getId()); + $this->assertNotNull($session->getId()); $session->setId(array('a')); - $this->assertFalse(array('a') == $session->getId()); + $this->assertNotSame(array('a'), $session->getId()); $session->setId('wrong'); - $this->assertFalse('wrong' == $session->getId()); + $this->assertNotEquals('wrong', $session->getId()); }
true
Other
laravel
framework
ff988e4290329140638cc71c054d030c9a545937.json
Fix getCountForPagination for grouped query Signed-off-by: Graham Campbell <graham@mineuk.com>
src/Illuminate/Database/Query/Builder.php
@@ -1388,7 +1388,7 @@ public function paginate($perPage = 15, $columns = ['*']) { $page = Paginator::resolveCurrentPage(); - $total = $this->getCountForPagination(); + $total = $this->getCountForPagination($columns); $results = $this->forPage($page, $perPage)->get($columns); @@ -1420,16 +1420,28 @@ public function simplePaginate($perPage = 15, $columns = ['*']) /** * Get the count of the total records for the paginator. * + * @param array $columns * @return int */ - public function getCountForPagination() + public function getCountForPagination($columns = ['*']) { $this->backupFieldsForCount(); - $total = $this->count(); + $this->aggregate = ['function' => 'count', 'columns' => $columns]; + + $results = $this->get(); + + $this->aggregate = null; $this->restoreFieldsForCount(); + if (isset($results[0])) + { + if (isset($this->groups)) return count($results); + + return (int) array_change_key_case((array) $results[0])['aggregate']; + } + return $total; } @@ -1440,7 +1452,7 @@ public function getCountForPagination() */ protected function backupFieldsForCount() { - foreach (['orders', 'limit', 'offset'] as $field) + foreach (['orders', 'limit', 'offset', 'columns'] as $field) { $this->backups[$field] = $this->{$field}; @@ -1455,7 +1467,7 @@ protected function backupFieldsForCount() */ protected function restoreFieldsForCount() { - foreach (['orders', 'limit', 'offset'] as $field) + foreach (['orders', 'limit', 'offset', 'columns'] as $field) { $this->{$field} = $this->backups[$field]; }
true
Other
laravel
framework
ff988e4290329140638cc71c054d030c9a545937.json
Fix getCountForPagination for grouped query Signed-off-by: Graham Campbell <graham@mineuk.com>
tests/Database/DatabaseEloquentIntegrationTest.php
@@ -156,6 +156,19 @@ public function testPaginatedModelCollectionRetrieval() } + public function testCountForPaginationWithGrouping() + { + EloquentTestUser::create(['id' => 1, 'email' => 'taylorotwell@gmail.com']); + EloquentTestUser::create(['id' => 2, 'email' => 'abigailotwell@gmail.com']); + EloquentTestUser::create(['id' => 3, 'email' => 'foo@gmail.com']); + EloquentTestUser::create(['id' => 4, 'email' => 'foo@gmail.com']); + + $query = EloquentTestUser::groupBy('email')->getQuery(); + + $this->assertEquals(3, $query->getCountForPagination()); + } + + public function testListsRetrieval() { EloquentTestUser::create(['id' => 1, 'email' => 'taylorotwell@gmail.com']);
true
Other
laravel
framework
08a59792be97afb598ae59ad816aae9de677f3b6.json
Add empty comments for empty functions
src/Illuminate/Database/Connection.php
@@ -182,7 +182,10 @@ public function useDefaultSchemaGrammar() * * @return \Illuminate\Database\Schema\Grammars\Grammar */ - protected function getDefaultSchemaGrammar() {} + protected function getDefaultSchemaGrammar() + { + // + } /** * Set the query post processor to the default implementation.
true
Other
laravel
framework
08a59792be97afb598ae59ad816aae9de677f3b6.json
Add empty comments for empty functions
src/Illuminate/Database/Seeder.php
@@ -24,7 +24,10 @@ class Seeder { * * @return void */ - public function run() {} + public function run() + { + // + } /** * Seed the given connection from the given path.
true
Other
laravel
framework
08a59792be97afb598ae59ad816aae9de677f3b6.json
Add empty comments for empty functions
src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php
@@ -91,7 +91,10 @@ protected function loadRoutesFrom($path) * * @return void */ - public function register() {} + public function register() + { + // + } /** * Pass dynamic methods onto the router instance.
true
Other
laravel
framework
5e905c728e4e486c8d4090d51b5037ec97a5253b.json
Fix some docblocks
src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
@@ -242,7 +242,7 @@ public function find($id, $columns = ['*']) /** * Find multiple related models by their primary keys. * - * @param mixed $id + * @param mixed $ids * @param array $columns * @return \Illuminate\Database\Eloquent\Collection */ @@ -299,7 +299,7 @@ protected function getSelectColumns(array $columns = ['*']) return array_merge($columns, [$this->parent->getTable().'.'.$this->firstKey]); } - /* + /** * Get a paginator for the "select" statement. * * @param int $perPage
true
Other
laravel
framework
5e905c728e4e486c8d4090d51b5037ec97a5253b.json
Fix some docblocks
src/Illuminate/Queue/Worker.php
@@ -40,7 +40,7 @@ class Worker { /** * The exception handler instance. * - * @var \Illuminate\Exception\Handler + * @var \Illuminate\Foundation\Exceptions\Handler */ protected $exceptions;
true
Other
laravel
framework
080f8192b5a9531b1c54e3efa455c526e5f264ee.json
Add reset method to migrator.
src/Illuminate/Database/Console/Migrations/ResetCommand.php
@@ -56,19 +56,14 @@ public function fire() $pretend = $this->input->getOption('pretend'); - while (true) - { - $count = $this->migrator->rollback($pretend); - - // Once the migrator has run we will grab the note output and send it out to - // the console screen, since the migrator itself functions without having - // any instances of the OutputInterface contract passed into the class. - foreach ($this->migrator->getNotes() as $note) - { - $this->output->writeln($note); - } + $this->migrator->reset($pretend); - if ($count == 0) break; + // Once the migrator has run we will grab the note output and send it out to + // the console screen, since the migrator itself functions without having + // any instances of the OutputInterface contract passed into the class. + foreach ($this->migrator->getNotes() as $note) + { + $this->output->writeln($note); } }
true
Other
laravel
framework
080f8192b5a9531b1c54e3efa455c526e5f264ee.json
Add reset method to migrator.
src/Illuminate/Database/Migrations/Migrator.php
@@ -175,6 +175,33 @@ public function rollback($pretend = false) return count($migrations); } + /** + * Rolls all of the currently applied migrations back. + * + * @param bool $pretend + * @return int + */ + public function reset($pretend = false) + { + $this->notes = []; + + $migrations = array_reverse($this->repository->getRan()); + + if (count($migrations) == 0) + { + $this->note('<info>Nothing to rollback.</info>'); + + return count($migrations); + } + + foreach ($migrations as $migration) + { + $this->runDown((object) ['migration' => $migration], $pretend); + } + + return count($migrations); + } + /** * Run "down" a migration instance. *
true
Other
laravel
framework
080f8192b5a9531b1c54e3efa455c526e5f264ee.json
Add reset method to migrator.
tests/Database/DatabaseMigrationResetCommandTest.php
@@ -16,8 +16,8 @@ public function testResetCommandCallsMigratorWithProperArguments() $command = new ResetCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator')); $command->setLaravel(new AppDatabaseMigrationStub()); $migrator->shouldReceive('setConnection')->once()->with(null); - $migrator->shouldReceive('rollback')->twice()->with(false)->andReturn(true, false); - $migrator->shouldReceive('getNotes')->andReturn(array()); + $migrator->shouldReceive('reset')->once()->with(false); + $migrator->shouldReceive('getNotes')->andReturn([]); $this->runCommand($command); } @@ -28,8 +28,8 @@ public function testResetCommandCanBePretended() $command = new ResetCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator')); $command->setLaravel(new AppDatabaseMigrationStub()); $migrator->shouldReceive('setConnection')->once()->with('foo'); - $migrator->shouldReceive('rollback')->twice()->with(true)->andReturn(true, false); - $migrator->shouldReceive('getNotes')->andReturn(array()); + $migrator->shouldReceive('reset')->once()->with(true); + $migrator->shouldReceive('getNotes')->andReturn([]); $this->runCommand($command, array('--pretend' => true, '--database' => 'foo')); } @@ -39,6 +39,7 @@ protected function runCommand($command, $input = array()) { return $command->run(new Symfony\Component\Console\Input\ArrayInput($input), new Symfony\Component\Console\Output\NullOutput); } + } class AppDatabaseMigrationStub extends \Illuminate\Foundation\Application {
true
Other
laravel
framework
080f8192b5a9531b1c54e3efa455c526e5f264ee.json
Add reset method to migrator.
tests/Database/DatabaseMigratorTest.php
@@ -191,6 +191,114 @@ public function testNothingIsRolledBackWhenNothingInRepository() $migrator->rollback(); } + + public function testResettingMigrationsRollsBackAllMigrations() + { + $migrator = $this->getMock('Illuminate\Database\Migrations\Migrator', ['resolve'], [ + m::mock('Illuminate\Database\Migrations\MigrationRepositoryInterface'), + $resolver = m::mock('Illuminate\Database\ConnectionResolverInterface'), + m::mock('Illuminate\Filesystem\Filesystem'), + ]); + + $fooMigration = (object) ['migration' => 'foo']; + $barMigration = (object) ['migration' => 'bar']; + $bazMigration = (object) ['migration' => 'baz']; + + $migrator->getRepository()->shouldReceive('getRan')->once()->andReturn([ + $fooMigration->migration, + $barMigration->migration, + $bazMigration->migration + ]); + + $barMock = m::mock('stdClass'); + $barMock->shouldReceive('down')->once(); + + $fooMock = m::mock('stdClass'); + $fooMock->shouldReceive('down')->once(); + + $bazMock = m::mock('stdClass'); + $bazMock->shouldReceive('down')->once(); + + $migrator->expects($this->at(0))->method('resolve')->with($this->equalTo('baz'))->will($this->returnValue($bazMock)); + $migrator->expects($this->at(1))->method('resolve')->with($this->equalTo('bar'))->will($this->returnValue($barMock)); + $migrator->expects($this->at(2))->method('resolve')->with($this->equalTo('foo'))->will($this->returnValue($fooMock)); + + $migrator->getRepository()->shouldReceive('delete')->once()->with(m::mustBe($bazMigration)); + $migrator->getRepository()->shouldReceive('delete')->once()->with(m::mustBe($barMigration)); + $migrator->getRepository()->shouldReceive('delete')->once()->with(m::mustBe($fooMigration)); + + $migrator->reset(); + } + + + public function testResetMigrationsCanBePretended() + { + $migrator = $this->getMock('Illuminate\Database\Migrations\Migrator', ['resolve'], [ + m::mock('Illuminate\Database\Migrations\MigrationRepositoryInterface'), + $resolver = m::mock('Illuminate\Database\ConnectionResolverInterface'), + m::mock('Illuminate\Filesystem\Filesystem'), + ]); + + $fooMigration = (object) ['migration' => 'foo']; + $barMigration = (object) ['migration' => 'bar']; + $bazMigration = (object) ['migration' => 'baz']; + + $migrator->getRepository()->shouldReceive('getRan')->once()->andReturn([ + $fooMigration->migration, + $barMigration->migration, + $bazMigration->migration + ]); + + $barMock = m::mock('stdClass'); + $barMock->shouldReceive('getConnection')->once()->andReturn(null); + $barMock->shouldReceive('down')->once(); + + $fooMock = m::mock('stdClass'); + $fooMock->shouldReceive('getConnection')->once()->andReturn(null); + $fooMock->shouldReceive('down')->once(); + + $bazMock = m::mock('stdClass'); + $bazMock->shouldReceive('getConnection')->once()->andReturn(null); + $bazMock->shouldReceive('down')->once(); + + $migrator->expects($this->at(0))->method('resolve')->with($this->equalTo('baz'))->will($this->returnValue($bazMock)); + $migrator->expects($this->at(1))->method('resolve')->with($this->equalTo('bar'))->will($this->returnValue($barMock)); + $migrator->expects($this->at(2))->method('resolve')->with($this->equalTo('foo'))->will($this->returnValue($fooMock)); + + $connection = m::mock('stdClass'); + $connection->shouldReceive('pretend')->with(m::type('Closure'))->andReturnUsing(function($closure) + { + $closure(); + return [['query' => 'baz']]; + }, + function($closure) + { + $closure(); + return [['query' => 'bar']]; + }, + function($closure) + { + $closure(); + return [['query' => 'foo']]; + }); + $resolver->shouldReceive('connection')->with(null)->andReturn($connection); + + $migrator->reset(true); + } + + + public function testNothingIsResetBackWhenNothingInRepository() + { + $migrator = $this->getMock('Illuminate\Database\Migrations\Migrator', ['resolve'], [ + m::mock('Illuminate\Database\Migrations\MigrationRepositoryInterface'), + $resolver = m::mock('Illuminate\Database\ConnectionResolverInterface'), + m::mock('Illuminate\Filesystem\Filesystem'), + ]); + $migrator->getRepository()->shouldReceive('getRan')->once()->andReturn([]); + + $migrator->reset(); + } + }
true
Other
laravel
framework
3f223fba974bf56551d576618109ec50429fe0b2.json
Fix weird wording.
src/Illuminate/Database/Console/Migrations/StatusCommand.php
@@ -16,7 +16,7 @@ class StatusCommand extends BaseCommand { * * @var string */ - protected $description = 'Show a list of migrations up/down'; + protected $description = 'Show the status of each migration'; /** * The migrator instance.
false
Other
laravel
framework
0984411bda2cd2cc62a698f222b32ee991d57ff5.json
Use basePath helper.
src/Illuminate/Database/Console/Migrations/MigrateCommand.php
@@ -63,7 +63,7 @@ public function fire() // so that migrations may be run for any path within the applications. if ( ! is_null($path = $this->input->getOption('path'))) { - $path = $this->laravel['path.base'].'/'.$path; + $path = $this->laravel->basePath().'/'.$path; } else {
true
Other
laravel
framework
0984411bda2cd2cc62a698f222b32ee991d57ff5.json
Use basePath helper.
src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php
@@ -16,7 +16,7 @@ public function bootstrap(Application $app) { try { - Dotenv::load($app['path.base'], $app->environmentFile()); + Dotenv::load($app->basePath(), $app->environmentFile()); } catch (InvalidArgumentException $e) {
true
Other
laravel
framework
0984411bda2cd2cc62a698f222b32ee991d57ff5.json
Use basePath helper.
src/Illuminate/Foundation/Console/AppNameCommand.php
@@ -259,7 +259,7 @@ protected function getUserClassPath() */ protected function getBootstrapPath() { - return $this->laravel['path.base'].'/bootstrap/app.php'; + return $this->laravel->basePath().'/bootstrap/app.php'; } /** @@ -269,7 +269,7 @@ protected function getBootstrapPath() */ protected function getComposerPath() { - return $this->laravel['path.base'].'/composer.json'; + return $this->laravel->basePath().'/composer.json'; } /** @@ -310,7 +310,7 @@ protected function getServicesConfigPath() */ protected function getPhpSpecConfigPath() { - return $this->laravel['path.base'].'/phpspec.yml'; + return $this->laravel->basePath().'/phpspec.yml'; } /**
true
Other
laravel
framework
0984411bda2cd2cc62a698f222b32ee991d57ff5.json
Use basePath helper.
src/Illuminate/Foundation/Console/ConfigCacheCommand.php
@@ -66,7 +66,7 @@ public function fire() */ protected function getFreshConfiguration() { - $app = require $this->laravel['path.base'].'/bootstrap/app.php'; + $app = require $this->laravel->basePath().'/bootstrap/app.php'; $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
true
Other
laravel
framework
0984411bda2cd2cc62a698f222b32ee991d57ff5.json
Use basePath helper.
src/Illuminate/Foundation/Console/RouteCacheCommand.php
@@ -75,7 +75,7 @@ public function fire() */ protected function getFreshApplicationRoutes() { - $app = require $this->laravel['path.base'].'/bootstrap/app.php'; + $app = require $this->laravel->basePath().'/bootstrap/app.php'; $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
true
Other
laravel
framework
0984411bda2cd2cc62a698f222b32ee991d57ff5.json
Use basePath helper.
src/Illuminate/Foundation/Providers/ComposerServiceProvider.php
@@ -21,7 +21,7 @@ public function register() { $this->app->singleton('composer', function($app) { - return new Composer($app['files'], $app['path.base']); + return new Composer($app['files'], $app->basePath()); }); }
true
Other
laravel
framework
0984411bda2cd2cc62a698f222b32ee991d57ff5.json
Use basePath helper.
src/Illuminate/Foundation/helpers.php
@@ -106,7 +106,7 @@ function auth() */ function base_path($path = '') { - return app()->make('path.base').($path ? '/'.$path : $path); + return app()->basePath().($path ? '/'.$path : $path); } }
true
Other
laravel
framework
0984411bda2cd2cc62a698f222b32ee991d57ff5.json
Use basePath helper.
src/Illuminate/Queue/QueueServiceProvider.php
@@ -112,7 +112,7 @@ protected function registerListener() $this->app->singleton('queue.listener', function($app) { - return new Listener($app['path.base']); + return new Listener($app->basePath()); }); }
true
Other
laravel
framework
c72dc3aa2f5d072c5b6a769b4683730bf7da7179.json
Use the slice method
src/Illuminate/Support/Collection.php
@@ -408,7 +408,7 @@ public function merge($items) */ public function forPage($page, $perPage) { - return new static(array_slice($this->items, ($page - 1) * $perPage, $perPage)); + return $this->slice(($page - 1) * $perPage, $perPage); } /**
false
Other
laravel
framework
46203676c748ac3cdb4849e75e711ca9cb1ca118.json
Create "auth" helper
src/Illuminate/Foundation/helpers.php
@@ -83,6 +83,19 @@ function asset($path, $secure = null) } } +if ( ! function_exists('auth')) +{ + /** + * Get the available auth instance. + * + * @return \Illuminate\Contracts\Auth\Guard + */ + function auth() + { + return app('Illuminate\Contracts\Auth\Guard'); + } +} + if ( ! function_exists('base_path')) { /**
false
Other
laravel
framework
7bbc31c75f94f29f0d76a9a3ffdb500dcc2bd9d6.json
Add "unguarded" method to eloquent
src/Illuminate/Database/Eloquent/Model.php
@@ -416,13 +416,10 @@ public function fill(array $attributes) */ public function forceFill(array $attributes) { - static::unguard(); - - $this->fill($attributes); - - static::reguard(); - - return $this; + return $this->unguarded(function() use ($attributes) + { + return $this->fill($attributes); + }); } /** @@ -537,18 +534,10 @@ public static function create(array $attributes) */ public static function forceCreate(array $attributes) { - if (static::$unguarded) + return static::unguarded(function() use ($attributes) { return static::create($attributes); - } - - static::unguard(); - - $model = static::create($attributes); - - static::reguard(); - - return $model; + }); } /** @@ -2226,6 +2215,35 @@ public static function setUnguardState($state) static::$unguarded = $state; } + /** + * Get the current state of "unguard". + * + * @return bool + */ + public static function getUnguardState() + { + return static::$unguarded; + } + + /** + * Run the given callable while being unguarded. + * + * @param callable $callback + * @return mixed + */ + public static function unguarded(callable $callback) + { + if (static::$unguarded) return $callback(); + + static::unguard(); + + $result = $callback(); + + static::reguard(); + + return $result; + } + /** * Determine if the given attribute may be mass assigned. *
true
Other
laravel
framework
7bbc31c75f94f29f0d76a9a3ffdb500dcc2bd9d6.json
Add "unguarded" method to eloquent
tests/Database/DatabaseEloquentModelTest.php
@@ -1,6 +1,7 @@ <?php use Mockery as m; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\ModelNotFoundException; class DatabaseEloquentModelTest extends PHPUnit_Framework_TestCase { @@ -758,6 +759,28 @@ public function testGlobalGuarded() } + public function testUnguaredRunsCallbackWhileBeingUnguarded() + { + $model = Model::unguarded(function() { + return (new EloquentModelStub)->guard(['*'])->fill(['name' => 'Taylor']); + }); + $this->assertEquals('Taylor', $model->name); + $this->assertFalse(Model::getUnguardState()); + } + + + public function testUnguaredCallDoesNotChangeUnguardedState() + { + Model::unguard(); + $model = Model::unguarded(function() { + return (new EloquentModelStub)->guard(['*'])->fill(['name' => 'Taylor']); + }); + $this->assertEquals('Taylor', $model->name); + $this->assertTrue(Model::getUnguardState()); + Model::reguard(); + } + + public function testHasOneCreatesProperRelation() { $model = new EloquentModelStub; @@ -1214,7 +1237,7 @@ public function creating() {} public function saved() {} } -class EloquentModelStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelStub extends Model { protected $table = 'stub'; protected $guarded = array(); protected $morph_to_stub_type = 'EloquentModelSaveStub'; @@ -1275,7 +1298,7 @@ public function getDates() } } -class EloquentModelSaveStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelSaveStub extends Model { protected $table = 'save_stub'; protected $guarded = array(); public function save(array $options = array()) { $_SERVER['__eloquent.saved'] = true; } @@ -1285,7 +1308,7 @@ public function setIncrementing($value) } } -class EloquentModelFindStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelFindStub extends Model { public function newQuery() { $mock = m::mock('Illuminate\Database\Eloquent\Builder'); @@ -1294,7 +1317,7 @@ public function newQuery() } } -class EloquentModelFindWithWritePdoStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelFindWithWritePdoStub extends Model { public function newQuery() { $mock = m::mock('Illuminate\Database\Eloquent\Builder'); @@ -1305,7 +1328,7 @@ public function newQuery() } } -class EloquentModelDestroyStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelDestroyStub extends Model { public function newQuery() { $mock = m::mock('Illuminate\Database\Eloquent\Builder'); @@ -1316,7 +1339,7 @@ public function newQuery() } } -class EloquentModelHydrateRawStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelHydrateRawStub extends Model { public static function hydrate(array $items, $connection = null) { return 'hydrated'; } public function getConnection() { @@ -1326,7 +1349,7 @@ public function getConnection() } } -class EloquentModelFindManyStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelFindManyStub extends Model { public function newQuery() { $mock = m::mock('Illuminate\Database\Eloquent\Builder'); @@ -1335,7 +1358,7 @@ public function newQuery() } } -class EloquentModelWithStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelWithStub extends Model { public function newQuery() { $mock = m::mock('Illuminate\Database\Eloquent\Builder'); @@ -1344,9 +1367,9 @@ public function newQuery() } } -class EloquentModelWithoutTableStub extends Illuminate\Database\Eloquent\Model {} +class EloquentModelWithoutTableStub extends Model {} -class EloquentModelBootingTestStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelBootingTestStub extends Model { public static function unboot() { unset(static::$booted[get_called_class()]); @@ -1357,7 +1380,7 @@ public static function isBooted() } } -class EloquentModelAppendsStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelAppendsStub extends Model { protected $appends = array('is_admin', 'camelCased', 'StudlyCased'); public function getIsAdminAttribute() { @@ -1373,7 +1396,7 @@ public function getStudlyCasedAttribute() } } -class EloquentModelCastingStub extends Illuminate\Database\Eloquent\Model { +class EloquentModelCastingStub extends Model { protected $casts = array( 'first' => 'int', 'second' => 'float',
true
Other
laravel
framework
bf87be23a152895ea6869f50aaaee25aac7870ac.json
Fix broken PR.
src/Illuminate/Routing/UrlGenerator.php
@@ -320,7 +320,7 @@ protected function replaceRouteParameters($path, array &$parameters) if (count($parameters)) { $path = preg_replace_sub( - '/\{[^?]+?\}/', $parameters, $this->replaceNamedParameters($path, $parameters) + '/\{.*?\}/', $parameters, $this->replaceNamedParameters($path, $parameters) ); }
true
Other
laravel
framework
bf87be23a152895ea6869f50aaaee25aac7870ac.json
Fix broken PR.
src/Illuminate/Support/helpers.php
@@ -543,12 +543,7 @@ function preg_replace_sub($pattern, &$replacements, $subject) { foreach ($replacements as $key => $value) { - if (is_int($key)) - { - unset($replacements[$key]); - - return $value; - } + return array_shift($replacements); } }, $subject);
true
Other
laravel
framework
bf87be23a152895ea6869f50aaaee25aac7870ac.json
Fix broken PR.
tests/Routing/RoutingUrlGeneratorTest.php
@@ -70,12 +70,6 @@ public function testBasicRouteGeneration() $route = new Illuminate\Routing\Route(array('GET'), 'foo/bar/{baz}', array('as' => 'foobar')); $routes->add($route); - /** - * Optional Parameter... - */ - $route = new Illuminate\Routing\Route(array('GET'), 'foo/bar/{baz?}', array('as' => 'foobaz')); - $routes->add($route); - /** * HTTPS... */ @@ -109,8 +103,6 @@ public function testBasicRouteGeneration() $this->assertEquals('http://www.foo.com/foo/bar/otwell/breeze/taylor?fly=wall', $url->route('bar', array('boom' => 'taylor', 'baz' => 'otwell', 'fly' => 'wall'))); $this->assertEquals('http://www.foo.com/foo/bar/2', $url->route('foobar', 2)); $this->assertEquals('http://www.foo.com/foo/bar/taylor', $url->route('foobar', 'taylor')); - $this->assertEquals('http://www.foo.com/foo/bar/taylor', $url->route('foobar', array('taylor'))); - $this->assertEquals('http://www.foo.com/foo/bar/otwell?foo=taylor', $url->route('foobar', array('foo' => 'taylor', 'otwell'))); $this->assertEquals('/foo/bar/taylor/breeze/otwell?fly=wall', $url->route('bar', array('taylor', 'otwell', 'fly' => 'wall'), false)); $this->assertEquals('https://www.foo.com/foo/baz', $url->route('baz')); $this->assertEquals('http://www.foo.com/foo/bam', $url->action('foo@bar')); @@ -120,11 +112,6 @@ public function testBasicRouteGeneration() $this->assertEquals('/foo/bar#derp', $url->route('fragment', array(), false)); $this->assertEquals('/foo/bar?foo=bar#derp', $url->route('fragment', array('foo' => 'bar'), false)); $this->assertEquals('/foo/bar?baz=%C3%A5%CE%B1%D1%84#derp', $url->route('fragment', array('baz' => 'åαф'), false)); - $this->assertEquals('http://www.foo.com/foo/bar/wall?taylor', $url->route('foobaz', array('taylor', 'baz' => 'wall'))); - $this->assertEquals('http://www.foo.com/foo/bar/wall?taylor', $url->route('foobaz', array('baz' => 'wall', 'taylor'))); - $this->assertEquals('http://www.foo.com/foo/bar?fly=wall&taylor', $url->route('foobaz', array('taylor', 'fly' => 'wall'))); - $this->assertEquals('http://www.foo.com/foo/bar?fly=wall&taylor', $url->route('foobaz', array('fly' => 'wall', 'taylor'))); - $this->assertEquals('http://www.foo.com/foo/bar?taylor', $url->route('foobaz', 'taylor')); }
true
Other
laravel
framework
6a9aa29278e13274549d8205f2b21a2d2cb70e98.json
Run schedule after booting app.
src/Illuminate/Foundation/Console/Kernel.php
@@ -57,7 +57,11 @@ public function __construct(Application $app, Dispatcher $events) { $this->app = $app; $this->events = $events; - $this->defineConsoleSchedule(); + + $this->app->booted(function() + { + $this->defineConsoleSchedule(); + }); } /**
false
Other
laravel
framework
648826ce52981353bbfda26e53d546f9d54d101d.json
Add support for FTP adapter in filesystem
src/Illuminate/Filesystem/FilesystemManager.php
@@ -5,6 +5,7 @@ use OpenCloud\Rackspace; use League\Flysystem\FilesystemInterface; use League\Flysystem\Filesystem as Flysystem; +use League\Flysystem\Adapter\Ftp as FtpAdapter; use League\Flysystem\Rackspace\RackspaceAdapter; use League\Flysystem\Adapter\Local as LocalAdapter; use League\Flysystem\AwsS3v2\AwsS3Adapter as S3Adapter; @@ -126,6 +127,19 @@ public function createLocalDriver(array $config) return $this->adapt(new Flysystem(new LocalAdapter($config['root']))); } + /** + * Create an instance of the ftp driver. + * + * @param array $config + * @return \Illuminate\Contracts\Filesystem\Filesystem + */ + public function createFtpDriver(array $config) + { + $ftpConfig = array_only($config, ['host', 'username', 'password', 'port', 'root', 'passive', 'ssl', 'timeout']); + + return $this->adapt(new Flysystem(new FtpAdapter($ftpConfig))); + } + /** * Create an instance of the Amazon S3 driver. *
false
Other
laravel
framework
5114257478e2ee1aa53ec44573cfafdec74e7473.json
Use the rename function Update the "move" function of the Adapter to use the "rename" function of the driver, instead of using a copy/delete combination.
src/Illuminate/Filesystem/FilesystemAdapter.php
@@ -164,9 +164,7 @@ public function copy($from, $to) */ public function move($from, $to) { - $this->driver->copy($from, $to); - - $this->driver->delete($from); + $this->driver->rename($from, $to); } /**
false
Other
laravel
framework
078697196e7f7f6c3315c8657ec2fb2310c4d423.json
Fix selected columns on hasManyThrough
src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
@@ -203,6 +203,8 @@ public function get($columns = array('*')) // First we'll add the proper select columns onto the query so it is run with // the proper columns. Then, we will get the results and hydrate out pivot // models with the result of those columns as a separate model relation. + $columns = $this->query->getQuery()->columns ? array() : $columns; + $select = $this->getSelectColumns($columns); $models = $this->query->addSelect($select)->getModels();
true