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
a65d353597f5a9bb283fa37772381308e4bd1349.json
Fix contract and concrete type hints and PHPDocs
src/Illuminate/Bus/Dispatcher.php
@@ -72,8 +72,8 @@ public function dispatchFromArray($command, array $array) * Marshal a command and dispatch it to its appropriate handler. * * @param mixed $command - * @param \ArrayAccess $array - * @param array $extras + * @param \ArrayAccess $source + * @param array $extras * @return mixed */ public function dispatchFrom($command, ArrayAccess $source, array $extras = []) @@ -101,7 +101,7 @@ protected function marshalFromArray($command, array $array) * @param array $extras * @return mixed */ - protected function marshal($command, ArrayAccess $source, $extras = []) + protected function marshal($command, ArrayAccess $source, array $extras = []) { $injected = []; @@ -120,7 +120,7 @@ protected function marshal($command, ArrayAccess $source, $extras = []) } /** - * Get a parameter value for a marshalled command. + * Get a parameter value for a marshaled command. * * @param string $command * @param \ArrayAccess $source
true
Other
laravel
framework
a65d353597f5a9bb283fa37772381308e4bd1349.json
Fix contract and concrete type hints and PHPDocs
src/Illuminate/Contracts/Bus/Dispatcher.php
@@ -18,15 +18,17 @@ public function dispatchFromArray($command, array $array); * Marshal a command and dispatch it to its appropriate handler. * * @param mixed $command - * @param array $array + * @param \ArrayAccess $source + * @param array $extras * @return mixed */ - public function dispatchFrom($command, ArrayAccess $source, $extras = []); + public function dispatchFrom($command, ArrayAccess $source, array $extras = []); /** * Dispatch a command to its appropriate handler. * * @param mixed $command + * @param \Closure|null $afterResolving * @return mixed */ public function dispatch($command, Closure $afterResolving = null); @@ -35,6 +37,7 @@ public function dispatch($command, Closure $afterResolving = null); * Dispatch a command to its appropriate handler in the current process. * * @param mixed $command + * @param \Closure|null $afterResolving * @return mixed */ public function dispatchNow($command, Closure $afterResolving = null);
true
Other
laravel
framework
142a84d83793b84f644d4c0d495dea40e18514bf.json
Use expression instead of numeric value
src/Illuminate/Database/Query/Grammars/Grammar.php
@@ -306,7 +306,7 @@ protected function whereNotExists(Builder $query, $where) */ protected function whereIn(Builder $query, $where) { - if (empty($where['values'])) return '0'; + if (empty($where['values'])) return '0=1'; $values = $this->parameterize($where['values']); @@ -322,7 +322,7 @@ protected function whereIn(Builder $query, $where) */ protected function whereNotIn(Builder $query, $where) { - if (empty($where['values'])) return '1'; + if (empty($where['values'])) return '1=1'; $values = $this->parameterize($where['values']);
true
Other
laravel
framework
142a84d83793b84f644d4c0d495dea40e18514bf.json
Use expression instead of numeric value
tests/Database/DatabaseQueryBuilderTest.php
@@ -347,12 +347,12 @@ public function testEmptyWhereIns() { $builder = $this->getBuilder(); $builder->select('*')->from('users')->whereIn('id', array()); - $this->assertEquals('select * from "users" where 0', $builder->toSql()); + $this->assertEquals('select * from "users" where 0=1', $builder->toSql()); $this->assertEquals(array(), $builder->getBindings()); $builder = $this->getBuilder(); $builder->select('*')->from('users')->where('id', '=', 1)->orWhereIn('id', array()); - $this->assertEquals('select * from "users" where "id" = ? or 0', $builder->toSql()); + $this->assertEquals('select * from "users" where "id" = ? or 0=1', $builder->toSql()); $this->assertEquals(array(0 => 1), $builder->getBindings()); } @@ -361,12 +361,12 @@ public function testEmptyWhereNotIns() { $builder = $this->getBuilder(); $builder->select('*')->from('users')->whereNotIn('id', array()); - $this->assertEquals('select * from "users" where 1', $builder->toSql()); + $this->assertEquals('select * from "users" where 1=1', $builder->toSql()); $this->assertEquals(array(), $builder->getBindings()); $builder = $this->getBuilder(); $builder->select('*')->from('users')->where('id', '=', 1)->orWhereNotIn('id', array()); - $this->assertEquals('select * from "users" where "id" = ? or 1', $builder->toSql()); + $this->assertEquals('select * from "users" where "id" = ? or 1=1', $builder->toSql()); $this->assertEquals(array(0 => 1), $builder->getBindings()); }
true
Other
laravel
framework
52a0b5809da033e17d6dc96b7e79ac705df0e568.json
Fix queries with whereIn and empty arrays
src/Illuminate/Database/Query/Grammars/Grammar.php
@@ -306,6 +306,8 @@ protected function whereNotExists(Builder $query, $where) */ protected function whereIn(Builder $query, $where) { + if (empty($where['values'])) return '0'; + $values = $this->parameterize($where['values']); return $this->wrap($where['column']).' in ('.$values.')'; @@ -320,6 +322,8 @@ protected function whereIn(Builder $query, $where) */ protected function whereNotIn(Builder $query, $where) { + if (empty($where['values'])) return '1'; + $values = $this->parameterize($where['values']); return $this->wrap($where['column']).' not in ('.$values.')'; @@ -376,7 +380,7 @@ protected function whereNotNull(Builder $query, $where) { return $this->wrap($where['column']).' is not null'; } - + /** * Compile a "where date" clause. * @@ -388,7 +392,7 @@ protected function whereDate(Builder $query, $where) { return $this->dateBasedWhere('date', $query, $where); } - + /** * Compile a "where day" clause. *
true
Other
laravel
framework
52a0b5809da033e17d6dc96b7e79ac705df0e568.json
Fix queries with whereIn and empty arrays
tests/Database/DatabaseQueryBuilderTest.php
@@ -343,6 +343,34 @@ public function testBasicWhereNotIns() } + public function testEmptyWhereIns() + { + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->whereIn('id', array()); + $this->assertEquals('select * from "users" where 0', $builder->toSql()); + $this->assertEquals(array(), $builder->getBindings()); + + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->where('id', '=', 1)->orWhereIn('id', array()); + $this->assertEquals('select * from "users" where "id" = ? or 0', $builder->toSql()); + $this->assertEquals(array(0 => 1), $builder->getBindings()); + } + + + public function testEmptyWhereNotIns() + { + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->whereNotIn('id', array()); + $this->assertEquals('select * from "users" where 1', $builder->toSql()); + $this->assertEquals(array(), $builder->getBindings()); + + $builder = $this->getBuilder(); + $builder->select('*')->from('users')->where('id', '=', 1)->orWhereNotIn('id', array()); + $this->assertEquals('select * from "users" where "id" = ? or 1', $builder->toSql()); + $this->assertEquals(array(0 => 1), $builder->getBindings()); + } + + public function testUnions() { $builder = $this->getBuilder();
true
Other
laravel
framework
85ff8b3f8de7fd2795db44929217d08879ebd917.json
Add some package helpers to service provider.
src/Illuminate/Support/ServiceProvider.php
@@ -36,6 +36,35 @@ public function __construct($app) */ abstract public function register(); + /** + * Register a view file namespace. + * + * @param string $namespace + * @param string $path + * @return void + */ + protected function loadViewsFrom($namespace, $path) + { + if (is_dir($appPath = $this->app->basePath().'/resources/views/packages/'.$namespace)) + { + $this->app['view']->addNamespace($namespace, $appPath); + } + + $this->app['view']->addNamespace($namespace, $path); + } + + /** + * Register a translation file namespace. + * + * @param string $namespace + * @param string $path + * @return void + */ + protected function loadTranslationsFrom($namespace, $path) + { + $this->app['translator']->addNamespace($namespace, $path); + } + /** * Register the package's custom Artisan commands. *
false
Other
laravel
framework
4542536f244b5b759f1f4eefbc94baee4e5151af.json
Fix duplicate queries for Cache::rememberForever
src/Illuminate/Cache/TaggedCache.php
@@ -195,7 +195,7 @@ public function rememberForever($key, Closure $callback) // If the item exists in the cache we will just return this immediately // otherwise we will execute the given Closure and cache the result // of that execution for the given number of minutes. It's easy. - if ($this->has($key)) return $this->get($key); + if ( ! is_null($value = $this->get($key))) return $value; $this->forever($key, $value = $callback());
false
Other
laravel
framework
8283c19d9110118b43d9dd128f42c50c4687d638.json
Fix duplicate queries for Cache::remember
src/Illuminate/Cache/TaggedCache.php
@@ -164,7 +164,7 @@ public function remember($key, $minutes, Closure $callback) // If the item exists in the cache we will just return this immediately // otherwise we will execute the given Closure and cache the result // of that execution for the given number of minutes in storage. - if ($this->has($key)) return $this->get($key); + if ( ! is_null($value = $this->get($key))) return $value; $this->put($key, $value = $callback(), $minutes);
false
Other
laravel
framework
1de41ba73bf7f6e16419ac2293506dfdab5d3434.json
Remove hardcoded cache filename
src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
@@ -20,7 +20,7 @@ public function bootstrap(Application $app) // First we will see if we have a cache configuration file. If we do, we'll load // the configuration items from that file so that it is very quick. Otherwise // we will need to spin through every configuration file and load them all. - if (file_exists($cached = storage_path('framework/config.php'))) + if (file_exists($cached = $app->getCachedConfigPath())) { $items = require $cached;
false
Other
laravel
framework
9297ad762f2db3744db7ed7588dae844a282277f.json
Add reverse assertion.
tests/Database/DatabaseEloquentIntegrationTests.php
@@ -101,6 +101,9 @@ public function testBasicHasManyEagerLoading() $user = EloquentTestUser::with('posts')->where('email', 'taylorotwell@gmail.com')->first(); $this->assertEquals('First Post', $user->posts->first()->name); + + $post = EloquentTestPost::with('user')->where('name', 'First Post')->get(); + $this->assertEquals('taylorotwell@gmail.com', $post->first()->user->email); } /**
false
Other
laravel
framework
28390c9e76f87dc61ec8e0352a22b32a212a7706.json
Add another integration test.
tests/Database/DatabaseEloquentIntegrationTests.php
@@ -49,6 +49,13 @@ public function setUp() $table->integer('user_id'); $table->integer('friend_id'); }); + + $this->schema()->create('posts', function($table) { + $table->increments('id'); + $table->integer('user_id'); + $table->string('name'); + $table->timestamps(); + }); } @@ -61,6 +68,7 @@ public function tearDown() { $this->schema()->drop('users'); $this->schema()->drop('friends'); + $this->schema()->drop('posts'); } /** @@ -85,6 +93,16 @@ public function testHasOnSelfReferencingBelongsToManyRelationship() $this->assertEquals('taylorotwell@gmail.com', $results->first()->email); } + + public function testBasicHasManyEagerLoading() + { + $user = EloquentTestUser::create(['email' => 'taylorotwell@gmail.com']); + $user->posts()->create(['name' => 'First Post']); + $user = EloquentTestUser::with('posts')->where('email', 'taylorotwell@gmail.com')->first(); + + $this->assertEquals('First Post', $user->posts->first()->name); + } + /** * Helpers... */ @@ -121,6 +139,17 @@ class EloquentTestUser extends Eloquent { public function friends() { return $this->belongsToMany('EloquentTestUser', 'friends', 'user_id', 'friend_id'); } + public function posts() { + return $this->hasMany('EloquentTestPost', 'user_id'); + } +} + +class EloquentTestPost extends Eloquent { + protected $table = 'posts'; + protected $guarded = []; + public function user() { + return $this->belongsTo('EloquentTestUser', 'user_id'); + } } /**
false
Other
laravel
framework
ad26757222f0a25ccafa56c83980589c3fd0f59c.json
Use raw array to load relations
src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
@@ -153,7 +153,7 @@ public function get($columns = array('*')) $select = $this->getSelectColumns($columns); - $models = $this->query->addSelect($select)->getModels(); + $models = $this->query->addSelect($select)->getModels()->all(); $this->hydratePivotRelation($models);
true
Other
laravel
framework
ad26757222f0a25ccafa56c83980589c3fd0f59c.json
Use raw array to load relations
src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
@@ -205,7 +205,7 @@ public function get($columns = array('*')) // models with the result of those columns as a separate model relation. $select = $this->getSelectColumns($columns); - $models = $this->query->addSelect($select)->getModels(); + $models = $this->query->addSelect($select)->getModels()->all(); // If we actually found models we will also eager load any relationships that // have been specified as needing to be eager loaded. This will solve the
true
Other
laravel
framework
ad26757222f0a25ccafa56c83980589c3fd0f59c.json
Use raw array to load relations
tests/Database/DatabaseEloquentBelongsToManyTest.php
@@ -2,6 +2,7 @@ use Mockery as m; use Illuminate\Database\Eloquent\Collection; +use Illuminate\Support\Collection as BaseCollection; use Illuminate\Database\Eloquent\Relations\BelongsToMany; class DatabaseEloquentBelongsToManyTest extends PHPUnit_Framework_TestCase { @@ -25,7 +26,7 @@ public function testModelsAreProperlyHydrated() $relation = $this->getRelation(); $relation->getParent()->shouldReceive('getConnectionName')->andReturn('foo.connection'); $relation->getQuery()->shouldReceive('addSelect')->once()->with(array('roles.*', 'user_role.user_id as pivot_user_id', 'user_role.role_id as pivot_role_id'))->andReturn($relation->getQuery()); - $relation->getQuery()->shouldReceive('getModels')->once()->andReturn($models); + $relation->getQuery()->shouldReceive('getModels')->once()->andReturn(new BaseCollection($models)); $relation->getQuery()->shouldReceive('eagerLoadRelations')->once()->with($models)->andReturn($models); $relation->getRelated()->shouldReceive('newCollection')->andReturnUsing(function($array) { return new Collection($array); }); $relation->getQuery()->shouldReceive('getQuery')->once()->andReturn($baseBuilder); @@ -69,7 +70,7 @@ public function testTimestampsCanBeRetrievedProperly() 'user_role.created_at as pivot_created_at', 'user_role.updated_at as pivot_updated_at', ))->andReturn($relation->getQuery()); - $relation->getQuery()->shouldReceive('getModels')->once()->andReturn($models); + $relation->getQuery()->shouldReceive('getModels')->once()->andReturn(new BaseCollection($models)); $relation->getQuery()->shouldReceive('eagerLoadRelations')->once()->with($models)->andReturn($models); $relation->getRelated()->shouldReceive('newCollection')->andReturnUsing(function($array) { return new Collection($array); }); $relation->getQuery()->shouldReceive('getQuery')->once()->andReturn($baseBuilder);
true
Other
laravel
framework
5d148e582381e95af77a43ae1c3cd68e477c8235.json
Fix some type hints
src/Illuminate/Bus/Dispatcher.php
@@ -72,7 +72,7 @@ public function dispatchFromArray($command, array $array) * Marshal a command and dispatch it to its appropriate handler. * * @param mixed $command - * @param array $array + * @param \ArrayAccess $array * @return mixed */ public function dispatchFrom($command, ArrayAccess $source, $extras = [])
true
Other
laravel
framework
5d148e582381e95af77a43ae1c3cd68e477c8235.json
Fix some type hints
src/Illuminate/Foundation/Bus/DispatchesCommands.php
@@ -34,7 +34,7 @@ protected function dispatchFromArray($command, array $array) * Marshal a command and dispatch it to its appropriate handler. * * @param mixed $command - * @param array $array + * @param \ArrayAccess $array * @return mixed */ protected function dispatchFrom($command, ArrayAccess $source, $extras = [])
true
Other
laravel
framework
3626b9b5bd8a47e6ae2000655ee29c3e690f453c.json
Fix indentation (tabs for now)
src/Illuminate/Foundation/Application.php
@@ -625,10 +625,10 @@ public function booted($callback) /** * {@inheritdoc} */ - public function handle(SymfonyRequest $request, $type = self::MASTER_REQUEST, $catch = true) - { - return $this['Illuminate\Contracts\Http\Kernel']->handle(Request::createFromBase($request)); - } + public function handle(SymfonyRequest $request, $type = self::MASTER_REQUEST, $catch = true) + { + return $this['Illuminate\Contracts\Http\Kernel']->handle(Request::createFromBase($request)); + } /** * Determine if the application configuration is cached.
false
Other
laravel
framework
b8d3f5f08f6cc3fa64015af1f4a062133b0d3d88.json
Return new collection on values.
src/Illuminate/Support/Collection.php
@@ -715,9 +715,7 @@ public function unique() */ public function values() { - $this->items = array_values($this->items); - - return $this; + return new static(array_values($this->items)); } /**
false
Other
laravel
framework
124d0451d2c0fdf22e3e18b2338afbf867317457.json
Tweak a few things.
src/Illuminate/Database/Eloquent/Builder.php
@@ -370,7 +370,7 @@ public function getModels($columns = array('*')) { $connection = $this->model->getConnectionName(); - // We will first get the raw results from the query builder. We'll then + // First, We will get the raw results from the query builder. We'll then // transform the raw results into Eloquent models, while also setting // the proper database connection on every Eloquent model instance. return $this->query->get($columns)->map(function($result) use ($connection)
false
Other
laravel
framework
e33584db10fa3ca84bce135998a62e8c7529bff5.json
Allow custom queueing of commands and handlers.
src/Illuminate/Bus/Dispatcher.php
@@ -242,7 +242,14 @@ public function dispatchToQueue($command) throw new \RuntimeException("Queue resolver did not return a Queue implementation."); } - $queue->push($command); + if (method_exists($command, 'queue')) + { + $command->queue($queue, $command); + } + else + { + $queue->push($command); + } } /**
true
Other
laravel
framework
e33584db10fa3ca84bce135998a62e8c7529bff5.json
Allow custom queueing of commands and handlers.
src/Illuminate/Events/Dispatcher.php
@@ -393,12 +393,36 @@ protected function createQueuedHandlerCallable($class, $method) { return function() use ($class, $method) { - $this->resolveQueue()->push('Illuminate\Events\CallQueuedHandler@call', [ - 'class' => $class, 'method' => $method, 'data' => serialize(func_get_args()), - ]); + if (method_exists($class, 'queue')) + { + $this->callQueueMethodOnHandler($class, $method, func_get_args()); + } + else + { + $this->resolveQueue()->push('Illuminate\Events\CallQueuedHandler@call', [ + 'class' => $class, 'method' => $method, 'data' => serialize(func_get_args()), + ]); + } }; } + /** + * Call the queue method on the handler class. + * + * @param string $class + * @param string $method + * @param array $arguments + * @return void + */ + protected function callQueueMethodOnHandler($class, $method, $arguments) + { + $handler = (new ReflectionClass($class))->newInstanceWithoutConstructor(); + + $handler->queue($this->resolveQueue(), 'Illuminate\Events\CallQueuedHandler@call', [ + 'class' => $class, 'method' => $method, 'data' => serialize($arguments), + ]); + } + /** * Remove a set of listeners from the dispatcher. *
true
Other
laravel
framework
e33584db10fa3ca84bce135998a62e8c7529bff5.json
Allow custom queueing of commands and handlers.
tests/Bus/BusDispatcherTest.php
@@ -39,6 +39,19 @@ public function testCommandsThatShouldBeQueuedAreQueued() } + public function testCommandsThatShouldBeQueuedAreQueuedUsingCustomHandler() + { + $container = new Container; + $dispatcher = new Dispatcher($container, function() { + $mock = m::mock('Illuminate\Contracts\Queue\Queue'); + $mock->shouldReceive('push')->once(); + return $mock; + }); + + $dispatcher->dispatch(new BusDispatcherTestCustomQueueCommand); + } + + public function testHandlersThatShouldBeQueuedAreQueued() { $container = new Container; @@ -116,3 +129,11 @@ public function handle(BusDispatcherTestBasicCommand $command) class BusDispatcherTestQueuedHandler implements Illuminate\Contracts\Queue\ShouldBeQueued { } + + +class BusDispatcherTestCustomQueueCommand implements Illuminate\Contracts\Queue\ShouldBeQueued { + public function queue($queue, $command) + { + $queue->push($command); + } +}
true
Other
laravel
framework
e33584db10fa3ca84bce135998a62e8c7529bff5.json
Allow custom queueing of commands and handlers.
tests/Events/EventsDispatcherTest.php
@@ -125,8 +125,32 @@ public function testQueuedEventHandlersAreQueued() $d->fire('some.event', ['foo', 'bar']); } + + public function testQueuedEventHandlersAreQueuedWithCustomHandlers() + { + $d = new Dispatcher; + $queue = m::mock('Illuminate\Contracts\Queue\Queue'); + $queue->shouldReceive('push')->once()->with('Illuminate\Events\CallQueuedHandler@call', [ + 'class' => 'TestDispatcherQueuedHandlerCustomQueue', + 'method' => 'someMethod', + 'data' => serialize(['foo', 'bar']), + ]); + $d->setQueueResolver(function() use ($queue) { return $queue; }); + + $d->listen('some.event', 'TestDispatcherQueuedHandlerCustomQueue@someMethod'); + $d->fire('some.event', ['foo', 'bar']); + } + } class TestDispatcherQueuedHandler implements Illuminate\Contracts\Queue\ShouldBeQueued { public function handle() {} } + +class TestDispatcherQueuedHandlerCustomQueue implements Illuminate\Contracts\Queue\ShouldBeQueued { + public function handle() {} + public function queue($queue, $handler, array $payload) + { + $queue->push($handler, $payload); + } +}
true
Other
laravel
framework
1d3a87bd7ec245ab320cff4f5eccebfa4ff1b947.json
Fix some things.
src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php
@@ -27,8 +27,6 @@ public function boot() { $this->app->resolving(function(FormRequest $request, $app) { - // We will go ahead and initialize the request as well as set a few dependencies - // on this request instance. The "ValidatesWhenResolved" hook will fire "validate". $this->initializeRequest($request, $app['request']); $request->setContainer($app)
true
Other
laravel
framework
1d3a87bd7ec245ab320cff4f5eccebfa4ff1b947.json
Fix some things.
tests/Filesystem/FilesystemTest.php
@@ -225,16 +225,6 @@ public function testSizeOutputsSize() } - public function testLastModified() - { - $time = time(); - file_put_contents(__DIR__.'/foo.txt', 'foo'); - $files = new Filesystem; - $this->assertEquals($time, $files->lastModified(__DIR__.'/foo.txt')); - @unlink(__DIR__.'/foo.txt'); - } - - public function testIsWritable() { file_put_contents(__DIR__.'/foo.txt', 'foo');
true
Other
laravel
framework
b454d5c343ca44a07c781be953fd8997e8c35eaa.json
Remove old fixture.
tests/Routing/fixtures/annotations/BasicController.php
@@ -1,30 +0,0 @@ -<?php namespace App\Http\Controllers; - -/** - * @Resource("foobar/photos", only={"index", "update"}, names={"index": "index.name"}) - * @Controller(domain="{id}.account.com") - * @Middleware("FooMiddleware") - * @Middleware("BarMiddleware") - * @Middleware("BoomMiddleware", only={"index"}) - * @Where({"id": "regex"}) - */ -class BasicController { - - /** - * @Middleware("BazMiddleware") - * @return Response - */ - public function index() {} - - /** - * @return Response - */ - public function update($id) {} - - /** - * @Put("/more/{id}", after="log") - * @Middleware("QuxMiddleware") - */ - public function doMore($id) {} - -}
false
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
composer.json
@@ -17,7 +17,6 @@ "classpreloader/classpreloader": "~1.0.2", "danielstjules/stringy": "~1.5", "d11wtq/boris": "~1.0", - "doctrine/annotations": "~1.0", "doctrine/inflector": "~1.0", "ircmaxell/password-compat": "~1.0", "jeremeamia/superclosure": "~1.0.1",
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Events/Annotations/Annotations/Hears.php
@@ -1,26 +0,0 @@ -<?php namespace Illuminate\Events\Annotations\Annotations; - -/** - * @Annotation - */ -class Hears { - - /** - * The events the annotation hears. - * - * @var array - */ - public $events; - - /** - * Create a new annotation instance. - * - * @param array $values - * @return void - */ - public function __construct(array $values = array()) - { - $this->events = (array) $values['value']; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Events/Annotations/Scanner.php
@@ -1,120 +0,0 @@ -<?php namespace Illuminate\Events\Annotations; - -use Exception; -use ReflectionClass; -use Symfony\Component\Finder\Finder; -use Doctrine\Common\Annotations\AnnotationRegistry; -use Doctrine\Common\Annotations\SimpleAnnotationReader; - -class Scanner { - - /** - * The classes to scan for annotations. - * - * @var array - */ - protected $scan; - - /** - * Create a new event scanner instance. - * - * @param array $scan - * @return void - */ - public function __construct(array $scan) - { - $this->scan = $scan; - - foreach (Finder::create()->files()->in(__DIR__.'/Annotations') as $file) - { - AnnotationRegistry::registerFile($file->getRealPath()); - } - } - - /** - * Create a new scanner instance. - * - * @param array $scan - * @return static - */ - public static function create(array $scan) - { - return new static($scan); - } - - /** - * Convert the scanned annotations into route definitions. - * - * @return string - */ - public function getEventDefinitions() - { - $output = ''; - - $reader = $this->getReader(); - - foreach ($this->getClassesToScan() as $class) - { - foreach ($class->getMethods() as $method) - { - foreach ($reader->getMethodAnnotations($method) as $annotation) - { - $output .= $this->buildListener($class->name, $method->name, $annotation->events); - } - } - } - - return trim($output); - } - - /** - * Build the event listener for the class and method. - * - * @param string $class - * @param string $method - * @param array $events - * @return string - */ - protected function buildListener($class, $method, $events) - { - return sprintf('$events->listen(%s, \''.$class.'@'.$method.'\');', var_export($events, true)).PHP_EOL; - } - - /** - * Get all of the ReflectionClass instances in the scan path. - * - * @return array - */ - protected function getClassesToScan() - { - $classes = []; - - foreach ($this->scan as $class) - { - try - { - $classes[] = new ReflectionClass($class); - } - catch (Exception $e) - { - // - } - } - - return $classes; - } - - /** - * Get an annotation reader instance. - * - * @return \Doctrine\Common\Annotations\SimpleAnnotationReader - */ - protected function getReader() - { - with($reader = new SimpleAnnotationReader) - ->addNamespace('Illuminate\Events\Annotations\Annotations'); - - return $reader; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Foundation/Application.php
@@ -629,46 +629,6 @@ public function getCachedRoutesPath() return $this['path.storage'].'/framework/routes.php'; } - /** - * Determine if the application routes have been scanned. - * - * @return bool - */ - public function routesAreScanned() - { - return $this['files']->exists($this->getScannedRoutesPath()); - } - - /** - * Get the path to the scanned routes file. - * - * @return string - */ - public function getScannedRoutesPath() - { - return $this['path.storage'].'/framework/routes.scanned.php'; - } - - /** - * Determine if the application events have been scanned. - * - * @return bool - */ - public function eventsAreScanned() - { - return $this['files']->exists($this->getScannedEventsPath()); - } - - /** - * Get the path to the scanned events file. - * - * @return string - */ - public function getScannedEventsPath() - { - return $this['path.storage'].'/framework/events.scanned.php'; - } - /** * Call the booting callbacks for the application. *
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Foundation/Console/EventScanCommand.php
@@ -1,92 +0,0 @@ -<?php namespace Illuminate\Foundation\Console; - -use Illuminate\Console\Command; -use Illuminate\Filesystem\Filesystem; -use Illuminate\Events\Annotations\Scanner; -use Symfony\Component\Console\Input\InputOption; - -class EventScanCommand extends Command { - - /** - * The console command name. - * - * @var string - */ - protected $name = 'event:scan'; - - /** - * The console command description. - * - * @var string - */ - protected $description = 'Scan a directory for event annotations'; - - /** - * The filesystem instance. - * - * @var \Illuminate\Filesystem\Filesystem - */ - protected $files; - - /** - * Create a new event scan command instance. - * - * @param \Illuminate\Filesystem\Filesystem $files - * @return void - */ - public function __construct(Filesystem $files) - { - parent::__construct(); - - $this->files = $files; - } - - /** - * Execute the console command. - * - * @return void - */ - public function fire() - { - $this->files->put($this->getOutputPath(), $this->getEventDefinitions()); - - $this->info('Events scanned!'); - } - - /** - * Get the route definitions for the annotations. - * - * @return string - */ - protected function getEventDefinitions() - { - $provider = 'Illuminate\Foundation\Support\Providers\EventServiceProvider'; - - return '<?php '.PHP_EOL.PHP_EOL.Scanner::create( - $this->laravel->getProvider($provider)->scans() - )->getEventDefinitions().PHP_EOL; - } - - /** - * Get the path to which the routes should be written. - * - * @return string - */ - protected function getOutputPath() - { - return $this->laravel['path.storage'].'/framework/events.scanned.php'; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['path', null, InputOption::VALUE_OPTIONAL, 'The path to scan.'], - ]; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Foundation/Console/RouteScanCommand.php
@@ -1,99 +0,0 @@ -<?php namespace Illuminate\Foundation\Console; - -use Illuminate\Console\Command; -use Illuminate\Filesystem\Filesystem; -use Illuminate\Routing\Annotations\Scanner; -use Symfony\Component\Console\Input\InputOption; -use Illuminate\Console\AppNamespaceDetectorTrait; - -class RouteScanCommand extends Command { - - use AppNamespaceDetectorTrait; - - /** - * The console command name. - * - * @var string - */ - protected $name = 'route:scan'; - - /** - * The console command description. - * - * @var string - */ - protected $description = 'Scan a directory for controller annotations'; - - /** - * The filesystem instance. - * - * @var \Illuminate\Filesystem\Filesystem - */ - protected $files; - - /** - * Create a new event scan command instance. - * - * @param \Illuminate\Filesystem\Filesystem $files - * @return void - */ - public function __construct(Filesystem $files) - { - parent::__construct(); - - $this->files = $files; - } - - /** - * Execute the console command. - * - * @return void - */ - public function fire() - { - $this->files->put($this->getOutputPath(), $this->getRouteDefinitions()); - - $this->info('Routes scanned!'); - } - - /** - * Get the route definitions for the annotations. - * - * @return string - */ - protected function getRouteDefinitions() - { - $provider = 'Illuminate\Foundation\Support\Providers\RouteServiceProvider'; - - return '<?php '.PHP_EOL.PHP_EOL.Scanner::create( - $this->laravel->getProvider($provider)->scans() - )->getRouteDefinitions().PHP_EOL; - } - - /** - * Get the path to which the routes should be written. - * - * @return string - */ - protected function getOutputPath() - { - return $this->laravel['path.storage'].'/framework/routes.scanned.php'; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - $namespace = $this->getAppNamespace().'Http\Controllers'; - - return [ - ['namespace', null, InputOption::VALUE_OPTIONAL, 'The root namespace for the controllers.', $namespace], - - ['path', null, InputOption::VALUE_OPTIONAL, 'The path to scan.', 'Http'.DIRECTORY_SEPARATOR.'Controllers'], - ]; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
@@ -7,9 +7,7 @@ use Illuminate\Foundation\Console\AppNameCommand; use Illuminate\Foundation\Console\OptimizeCommand; use Illuminate\Foundation\Console\RouteListCommand; -use Illuminate\Foundation\Console\RouteScanCommand; use Illuminate\Foundation\Console\EventMakeCommand; -use Illuminate\Foundation\Console\EventScanCommand; use Illuminate\Foundation\Console\RouteCacheCommand; use Illuminate\Foundation\Console\RouteClearCommand; use Illuminate\Foundation\Console\CommandMakeCommand; @@ -48,7 +46,6 @@ class ArtisanServiceProvider extends ServiceProvider { 'EventMake' => 'command.event.make', 'Down' => 'command.down', 'Environment' => 'command.environment', - 'EventScan' => 'command.event.scan', 'HandlerCommand' => 'command.handler.command', 'HandlerEvent' => 'command.handler.event', 'KeyGenerate' => 'command.key.generate', @@ -58,7 +55,6 @@ class ArtisanServiceProvider extends ServiceProvider { 'RouteCache' => 'command.route.cache', 'RouteClear' => 'command.route.clear', 'RouteList' => 'command.route.list', - 'RouteScan' => 'command.route.scan', 'Tinker' => 'command.tinker', 'Up' => 'command.up', ]; @@ -197,19 +193,6 @@ protected function registerEnvironmentCommand() }); } - /** - * Register the command. - * - * @return void - */ - protected function registerEventScanCommand() - { - $this->app->singleton('command.event.scan', function($app) - { - return new EventScanCommand($app['files']); - }); - } - /** * Register the command. * @@ -327,19 +310,6 @@ protected function registerRouteListCommand() }); } - /** - * Register the command. - * - * @return void - */ - protected function registerRouteScanCommand() - { - $this->app->singleton('command.route.scan', function($app) - { - return new RouteScanCommand($app['files']); - }); - } - /** * Register the command. *
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php
@@ -1,32 +1,17 @@ <?php namespace Illuminate\Foundation\Support\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Events\Annotations\Scanner; use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; class EventServiceProvider extends ServiceProvider { - /** - * The classes to scan for event annotations. - * - * @var array - */ - protected $scan = []; - /** * The subscriber classes to register. - * + * * @var array */ protected $subscribe = []; - /** - * Determines if we will auto-scan in the local environment. - * - * @var bool - */ - protected $scanWhenLocal = false; - /** * Register the application's event listeners. * @@ -35,58 +20,20 @@ class EventServiceProvider extends ServiceProvider { */ public function boot(DispatcherContract $events) { - if ($this->app->environment('local') && $this->scanWhenLocal) - { - $this->scanEvents(); - } - - if ( ! empty($this->scan) && $this->app->eventsAreScanned()) - { - $this->loadScannedEvents(); - } - foreach ($this->listen as $event => $listeners) { foreach ($listeners as $listener) { $events->listen($event, $listener); } } - + foreach ($this->subscribe as $subscriber) { $events->subscribe($subscriber); } } - /** - * Load the scanned events for the application. - * - * @return void - */ - protected function loadScannedEvents() - { - $events = app('Illuminate\Contracts\Events\Dispatcher'); - - require $this->app->getScannedEventsPath(); - } - - /** - * Scan the events for the application. - * - * @return void - */ - protected function scanEvents() - { - if (empty($this->scan)) return; - - $scanner = new Scanner($this->scan); - - file_put_contents( - $this->app->getScannedEventsPath(), '<?php '.$scanner->getEventDefinitions() - ); - } - /** * {@inheritdoc} */ @@ -95,14 +42,4 @@ public function register() // } - /** - * Get the classes to be scanned by the provider. - * - * @return array - */ - public function scans() - { - return $this->scan; - } - }
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php
@@ -2,7 +2,6 @@ use Illuminate\Routing\Router; use Illuminate\Support\ServiceProvider; -use Illuminate\Routing\Annotations\Scanner; class RouteServiceProvider extends ServiceProvider { @@ -13,20 +12,6 @@ class RouteServiceProvider extends ServiceProvider { */ protected $namespace = ''; - /** - * The controllers to scan for route annotations. - * - * @var array - */ - protected $scan = []; - - /** - * Determines if we will auto-scan in the local environment. - * - * @var bool - */ - protected $scanWhenLocal = false; - /** * Bootstrap any application services. * @@ -80,16 +65,6 @@ protected function loadCachedRoutes() */ protected function loadRoutes() { - if ($this->app->environment('local') && $this->scanWhenLocal) - { - $this->scanRoutes(); - } - - if ( ! empty($this->scan) && $this->app->routesAreScanned()) - { - $this->loadScannedRoutes(); - } - $this->app->call([$this, 'map']); } @@ -109,52 +84,13 @@ protected function loadRoutesFrom($path) }); } - /** - * Scan the routes and write the scanned routes file. - * - * @return void - */ - protected function scanRoutes() - { - if (empty($this->scan)) return; - - $scanner = new Scanner($this->scan); - - file_put_contents($this->app->getScannedRoutesPath(), '<?php '.$scanner->getRouteDefinitions()); - } - - /** - * Load the scanned application routes. - * - * @return void - */ - protected function loadScannedRoutes() - { - $this->app->booted(function() - { - $router = app('Illuminate\Contracts\Routing\Registrar'); - - require $this->app->getScannedRoutesPath(); - }); - } - /** * Register the service provider. * * @return void */ public function register() {} - /** - * Get the classes to be scanned by the provider. - * - * @return array - */ - public function scans() - { - return $this->scan; - } - /** * Pass dynamic methods onto the router instance. *
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/AbstractPath.php
@@ -1,40 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -abstract class AbstractPath { - - /** - * The HTTP verb the route responds to. - * - * @var array - */ - public $verb; - - /** - * The domain the route responds to. - * - * @var string - */ - public $domain; - - /** - * The path / URI the route responds to. - * - * @var string - */ - public $path; - - /** - * The path's middleware. - * - * @var array - */ - public $middleware = []; - - /** - * The path's "where" clauses. - * - * @var array - */ - public $where = []; - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/AnnotationSet.php
@@ -1,57 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -use ReflectionClass; -use Doctrine\Common\Annotations\SimpleAnnotationReader; - -class AnnotationSet { - - /** - * The class annotations. - * - * @var array - */ - public $class; - - /** - * The method annotations. - * - * @var array - */ - public $method; - - /** - * Create a new annotation set instance. - * - * @param \ReflectionClass $class - * @param \Doctrine\Common\Annotations\SimpleAnnotationReader $reader - * @return void - */ - public function __construct(ReflectionClass $class, SimpleAnnotationReader $reader) - { - $this->class = $reader->getClassAnnotations($class); - $this->method = $this->getMethodAnnotations($class, $reader); - } - - /** - * Get the method annotations for a given class. - * - * @param \ReflectionClass $class - * @param \Doctrine\Common\Annotations\SimpleAnnotationReader $reader - * @return array - */ - protected function getMethodAnnotations(ReflectionClass $class, SimpleAnnotationReader $reader) - { - $annotations = []; - - foreach ($class->getMethods() as $method) - { - $results = $reader->getMethodAnnotations($method); - - if (count($results) > 0) - $annotations[$method->name] = $results; - } - - return $annotations; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Annotation.php
@@ -1,124 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -use ArrayAccess; -use ReflectionClass; -use ReflectionMethod; -use Illuminate\Routing\Annotations\MethodEndpoint; -use Illuminate\Routing\Annotations\EndpointCollection; - -abstract class Annotation implements ArrayAccess { - - /** - * The value array. - * - * @var array - */ - protected $values; - - /** - * Create a new annotation instance. - * - * @param array $values - * @return void - */ - public function __construct(array $values) - { - $this->values = $values; - } - - /** - * Apply the annotation's settings to the given endpoint. - * - * @param \Illuminate\Routing\Annotations\MethodEndpoint $endpoint - * @param \ReflectionMethod $method - * @return void - */ - public function modify(MethodEndpoint $endpoint, ReflectionMethod $method) - { - // - } - - /** - * Apply the annotation's settings to the given endpoint collection. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @param \ReflectionClass $class - * @return void - */ - public function modifyCollection(EndpointCollection $endpoints, ReflectionClass $class) - { - // - } - - /** - * Determine if the value at a given offset exists. - * - * @param string $offset - * @return bool - */ - public function offsetExists($offset) - { - return array_key_exists($offset, $this->values); - } - - /** - * Get the value at a given offset. - * - * @param string $offset - * @return mixed - */ - public function offsetGet($offset) - { - return $this->values[$offset]; - } - - /** - * Set the value at a given offset. - * - * @param string $offset - * @param mixed $value - * @return void - */ - public function offsetSet($offset, $value) - { - $this->values[$offset] = $value; - } - - /** - * Remove the value at a given offset. - * - * @param string $offset - * @return void - */ - public function offsetUnset($offset) - { - unset($this->values[$offset]); - } - - /** - * Dynamically get a property on the annotation. - * - * @param string $key - * @return mixed - */ - public function __get($key) - { - if ($this->offsetExists($key)) - { - return $this->values[$key]; - } - } - - /** - * Dynamically set a property on the annotation. - * - * @param string $key - * @param mixed $value - * @return void - */ - public function __set($key, $value) - { - $this->values[$key] = $value; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Controller.php
@@ -1,61 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -use ReflectionClass; -use Illuminate\Routing\Annotations\EndpointCollection; - -/** - * @Annotation - */ -class Controller extends Annotation { - - /** - * {@inheritdoc} - */ - public function modifyCollection(EndpointCollection $endpoints, ReflectionClass $class) - { - if ($this->prefix) $this->prefixEndpoints($endpoints); - - if ($this->domain) $this->setEndpointDomains($endpoints); - } - - /** - * Set the prefixes on the endpoints. - * - * @param EndpointCollection $endpoints - * @return void - */ - protected function prefixEndpoints(EndpointCollection $endpoints) - { - foreach ($endpoints->getAllPaths() as $path) - { - $path->path = $this->trimPath($this->prefix, $path->path); - } - } - - /** - * Set the domain on the endpoints. - * - * @param EndpointCollection $endpoints - * @return void - */ - protected function setEndpointDomains(EndpointCollection $endpoints) - { - foreach ($endpoints->getAllPaths() as $path) - { - if (is_null($path->domain)) $path->domain = $this->domain; - } - } - - /** - * Trim the path slashes for a given prefix and path. - * - * @param string $prefix - * @param string $path - * @return string - */ - protected function trimPath($prefix, $path) - { - return trim(trim($prefix, '/').'/'.trim($path, '/'), '/'); - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Delete.php
@@ -1,10 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -/** - * @Annotation - */ -class Delete extends Route { - - // - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Get.php
@@ -1,10 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -/** - * @Annotation - */ -class Get extends Route { - - // - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Middleware.php
@@ -1,47 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -use ReflectionClass; -use ReflectionMethod; -use Illuminate\Routing\Annotations\MethodEndpoint; -use Illuminate\Routing\Annotations\EndpointCollection; - -/** - * @Annotation - */ -class Middleware extends Annotation { - - /** - * {@inheritdoc} - */ - public function modify(MethodEndpoint $endpoint, ReflectionMethod $method) - { - if ($endpoint->hasPaths()) - { - foreach ($endpoint->getPaths() as $path) - { - $path->middleware = array_merge($path->middleware, (array) $this->value); - } - } - else - { - $endpoint->middleware = array_merge($endpoint->middleware, (array) $this->value); - } - } - - /** - * {@inheritdoc} - */ - public function modifyCollection(EndpointCollection $endpoints, ReflectionClass $class) - { - foreach ($endpoints as $endpoint) - { - foreach ((array) $this->value as $middleware) - { - $endpoint->classMiddleware[] = [ - 'name' => $middleware, 'only' => (array) $this->only, 'except' => (array) $this->except - ]; - } - } - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Options.php
@@ -1,10 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -/** - * @Annotation - */ -class Options extends Route { - - // - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Patch.php
@@ -1,10 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -/** - * @Annotation - */ -class Patch extends Route { - - // - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Post.php
@@ -1,10 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -/** - * @Annotation - */ -class Post extends Route { - - // - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Put.php
@@ -1,10 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -/** - * @Annotation - */ -class Put extends Route { - - // - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Resource.php
@@ -1,80 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -use ReflectionClass; -use Illuminate\Support\Collection; -use Illuminate\Routing\Annotations\MethodEndpoint; -use Illuminate\Routing\Annotations\ResourceEndpoint; -use Illuminate\Routing\Annotations\EndpointCollection; - -/** - * @Annotation - */ -class Resource extends Annotation { - - /** - * All of the resource controller methods. - * - * @var array - */ - protected $methods = ['index', 'create', 'store', 'show', 'edit', 'update', 'destroy']; - - /** - * {@inheritdoc} - */ - public function modifyCollection(EndpointCollection $endpoints, ReflectionClass $class) - { - $endpoints->push(new ResourceEndpoint([ - 'reflection' => $class, 'name' => $this->value, 'names' => (array) $this->names, - 'only' => (array) $this->only, 'except' => (array) $this->except, - 'middleware' => $this->getMiddleware($endpoints), - ])); - } - - /** - * Get all of the middleware defined on the resource method endpoints. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @return array - */ - protected function getMiddleware(EndpointCollection $endpoints) - { - return $this->extractFromEndpoints($endpoints, 'middleware'); - } - - /** - * Extract method items from endpoints for the given key. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @param string $key - * @return array - */ - protected function extractFromEndpoints(EndpointCollection $endpoints, $key) - { - $items = [ - 'index' => [], 'create' => [], 'store' => [], 'show' => [], - 'edit' => [], 'update' => [], 'destroy' => [] - ]; - - foreach ($this->getEndpointsWithResourceMethods($endpoints, $key) as $endpoint) - $items[$endpoint->method] = array_merge($items[$endpoint->method], $endpoint->{$key}); - - return $items; - } - - /** - * Get all of the resource method endpoints with pathless filters. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @return array - */ - protected function getEndpointsWithResourceMethods(EndpointCollection $endpoints) - { - return Collection::make($endpoints)->filter(function($endpoint) - { - return ($endpoint instanceof MethodEndpoint && - in_array($endpoint->method, $this->methods)); - - })->all(); - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Route.php
@@ -1,20 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -use ReflectionMethod; -use Illuminate\Routing\Annotations\Path; -use Illuminate\Routing\Annotations\MethodEndpoint; - -abstract class Route extends Annotation { - - /** - * {@inheritdoc} - */ - public function modify(MethodEndpoint $endpoint, ReflectionMethod $method) - { - $endpoint->addPath(new Path( - strtolower(class_basename(get_class($this))), $this->domain, $this->value, - $this->as, (array) $this->middleware, (array) $this->where - )); - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Annotations/Where.php
@@ -1,35 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations\Annotations; - -use ReflectionClass; -use ReflectionMethod; -use Illuminate\Routing\Annotations\MethodEndpoint; -use Illuminate\Routing\Annotations\EndpointCollection; - -/** - * @Annotation - */ -class Where extends Annotation { - - /** - * {@inheritdoc} - */ - public function modify(MethodEndpoint $endpoint, ReflectionMethod $method) - { - foreach ($endpoint->getPaths() as $path) - { - $path->where = array_merge($path->where, (array) $this->value); - } - } - - /** - * {@inheritdoc} - */ - public function modifyCollection(EndpointCollection $endpoints, ReflectionClass $class) - { - foreach ($endpoints->getAllPaths() as $path) - { - $path->where = array_merge($path->where, $this->value); - } - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/EndpointCollection.php
@@ -1,27 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -use Illuminate\Support\Collection; - -class EndpointCollection extends Collection { - - /** - * Get all of the paths for the given endpoint collection. - * - * @return array - */ - public function getAllPaths() - { - $paths = []; - - foreach ($this as $endpoint) - { - foreach ($endpoint->getPaths() as $path) - { - $paths[] = $path; - } - } - - return $paths; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/EndpointInterface.php
@@ -1,42 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -interface EndpointInterface { - - /** - * Transform the endpoint into a route definition. - * - * @return string - */ - public function toRouteDefinition(); - - /** - * Determine if the endpoint has any paths. - * - * @var bool - */ - public function hasPaths(); - - /** - * Get all of the path definitions for an endpoint. - * - * @return array - */ - public function getPaths(); - - /** - * Add the given path definition to the endpoint. - * - * @param \Illuminate\Routing\Annotations\AbstractPath $path - * @return void - */ - public function addPath(AbstractPath $path); - - /** - * Get the controller method for the given endpoint path. - * - * @param \Illuminate\Routing\Annotations\AbstractPath $path - * @return string - */ - public function getMethodForPath(AbstractPath $path); - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/EndpointTrait.php
@@ -1,73 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -trait EndpointTrait { - - /** - * Determine if the middleware applies to a given method. - * - * @param string $method - * @param array $middleware - * @return bool - */ - protected function middlewareAppliesToMethod($method, array $middleware) - { - if ( ! empty($middleware['only']) && ! in_array($method, $middleware['only'])) - { - return false; - } - elseif ( ! empty($middleware['except']) && in_array($method, $middleware['except'])) - { - return false; - } - - return true; - } - - /** - * Get the controller method for the given endpoint path. - * - * @param \Illuminate\Routing\Annotations\AbstractPath $path - * @return string - */ - public function getMethodForPath(AbstractPath $path) - { - return $path->method; - } - - /** - * Add the given path definition to the endpoint. - * - * @param \Illuminate\Routing\Annotations\AbstractPath $path - * @return void - */ - public function addPath(AbstractPath $path) - { - $this->paths[] = $path; - } - - /** - * Implode the given list into a comma separated string. - * - * @param array $array - * @return string - */ - protected function implodeArray(array $array) - { - $results = []; - - foreach ($array as $key => $value) - { - if (is_string($key)) - { - $results[] = "'".$key."' => '".$value."'"; - } - else - { - $results[] = "'".$value."'"; - } - } - - return count($results) > 0 ? implode(', ', $results) : ''; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/MethodEndpoint.php
@@ -1,152 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -use Illuminate\Support\Collection; - -class MethodEndpoint implements EndpointInterface { - - use EndpointTrait; - - /** - * The ReflectionClass instance for the controller class. - * - * @var \ReflectionClass - */ - public $reflection; - - /** - * The method that handles the route. - * - * @var string - */ - public $method; - - /** - * The route paths for the definition. - * - * @var array[Path] - */ - public $paths = []; - - /** - * The controller and method that handles the route. - * - * @var string - */ - public $uses; - - /** - * All of the class level "inherited" middleware defined for the pathless endpoint. - * - * @var array - */ - public $classMiddleware = []; - - /** - * All of the middleware defined for the pathless endpoint. - * - * @var array - */ - public $middleware = []; - - /** - * Create a new route definition instance. - * - * @param array $attributes - * @return void - */ - public function __construct(array $attributes = array()) - { - foreach ($attributes as $key => $value) - $this->{$key} = $value; - } - - /** - * Transform the endpoint into a route definition. - * - * @return string - */ - public function toRouteDefinition() - { - $routes = []; - - foreach ($this->paths as $path) - { - $routes[] = sprintf( - $this->getTemplate(), $path->verb, $path->path, $this->uses, var_export($path->as, true), - $this->getMiddleware($path), $this->implodeArray($path->where), var_export($path->domain, true) - ); - } - - return implode(PHP_EOL.PHP_EOL, $routes); - } - - /** - * Get the middleware for the path. - * - * @param \Illuminate\Routing\Annotations\AbstractPath $path - * @return array - */ - protected function getMiddleware(AbstractPath $path) - { - $classMiddleware = $this->getClassMiddlewareForPath($path)->all(); - - return $this->implodeArray( - array_merge($classMiddleware, $path->middleware, $this->middleware) - ); - } - - /** - * Get the class middleware for the given path. - * - * @param \Illuminate\Routing\Annotations\AbstractPath $path - * @return array - */ - protected function getClassMiddlewareForPath(AbstractPath $path) - { - return Collection::make($this->classMiddleware)->filter(function($m) - { - return $this->middlewareAppliesToMethod($this->method, $m); - }) - ->map(function($m) - { - return $m['name']; - }); - } - - /** - * Determine if the endpoint has any paths. - * - * @return bool - */ - public function hasPaths() - { - return count($this->paths) > 0; - } - - /** - * Get all of the path definitions for an endpoint. - * - * @return array - */ - public function getPaths() - { - return $this->paths; - } - - /** - * Get the template for the endpoint. - * - * @return string - */ - protected function getTemplate() - { - return '$router->%s(\'%s\', [ - \'uses\' => \'%s\', - \'as\' => %s, - \'middleware\' => [%s], - \'where\' => [%s], - \'domain\' => %s, -]);'; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Path.php
@@ -1,33 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -class Path extends AbstractPath { - - /** - * The name of the route. - * - * @var string - */ - public $as; - - /** - * Create a new Route Path instance. - * - * @param string $verb - * @param string $domain - * @param string $path - * @param string $as - * @param array $middleware - * @param array $where - * @return void - */ - public function __construct($verb, $domain, $path, $as, $middleware = [], $where = []) - { - $this->as = $as; - $this->verb = $verb; - $this->where = $where; - $this->domain = $domain; - $this->middleware = $middleware; - $this->path = $path == '/' ? '/' : trim($path, '/'); - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/ResourceEndpoint.php
@@ -1,226 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -use Illuminate\Support\Collection; - -class ResourceEndpoint implements EndpointInterface { - - use EndpointTrait; - - /** - * All of the resource controller methods. - * - * @var array - */ - protected $methods = ['index', 'create', 'store', 'show', 'edit', 'update', 'destroy']; - - /** - * The ReflectionClass instance for the controller class. - * - * @var \ReflectionClass - */ - public $reflection; - - /** - * The route paths for the definition. - * - * This corresponds to a path for each applicable resource method. - * - * @var array[ResourcePath] - */ - public $paths; - - /** - * The name of the resource. - * - * @var string - */ - public $name; - - /** - * The array of route names for the resource. - * - * @var array - */ - public $names = []; - - /** - * The only methods that should be included. - * - * @var array - */ - public $only = []; - - /** - * The methods that should not be included. - * - * @var array - */ - public $except = []; - - /** - * The class level "inherited" middleware that apply to the resource. - * - * @var array - */ - public $classMiddleware = []; - - /** - * The middleware that was applied at the method level. - * - * This array is keyed by resource method name (index, create, etc). - * - * @var array - */ - public $middleware = []; - - /** - * Create a new route definition instance. - * - * @param array $attributes - * @return void - */ - public function __construct(array $attributes = array()) - { - foreach ($attributes as $key => $value) - { - $this->{$key} = $value; - } - - $this->buildPaths(); - } - - /** - * Build all of the paths for the resource endpoint. - * - * @return void - */ - protected function buildPaths() - { - foreach ($this->getIncludedMethods() as $method) - { - $this->paths[] = new ResourcePath($method); - } - } - - /** - * Get the methods to be included in the resource. - * - * @return array - */ - protected function getIncludedMethods() - { - if ($this->only) - { - return $this->only; - } - elseif ($this->except) - { - return array_diff($this->methods, $this->except); - } - - return $this->methods; - } - - /** - * Transform the endpoint into a route definition. - * - * @return string - */ - public function toRouteDefinition() - { - $routes = []; - - foreach ($this->paths as $path) - { - $routes[] = sprintf( - $this->getTemplate(), 'Resource: '.$this->name.'@'.$path->method, - $this->implodeArray($this->getMiddleware($path)), - var_export($path->path, true), $this->implodeArray($path->where), - var_export($path->domain, true), var_export($this->name, true), - var_export($this->reflection->name, true), $this->implodeArray([$path->method]), - $this->implodeArray($this->getNames($path)) - ); - } - - return implode(PHP_EOL.PHP_EOL, $routes); - } - - /** - * Get all of the middleware for the given path. - * - * This will also merge in any of the middleware applied at the route level. - * - * @param ResourcePath $path - * @return array - */ - protected function getMiddleware(ResourcePath $path) - { - $classMiddleware = $this->getClassMiddlewareForPath($path)->all(); - - return array_merge($classMiddleware, array_get($this->middleware, $path->method, [])); - } - - /** - * Get the class middleware for the given path. - * - * @param ResourcePath $path - * @return array - */ - protected function getClassMiddlewareForPath(ResourcePath $path) - { - return Collection::make($this->classMiddleware)->filter(function($m) use ($path) - { - return $this->middlewareAppliesToMethod($path->method, $m); - }) - ->map(function($m) - { - return $m['name']; - }); - } - - /** - * Get the names for the given path. - * - * @param ResourcePath $path - * @return array - */ - protected function getNames(ResourcePath $path) - { - return isset($this->names[$path->method]) ? [$path->method => $this->names[$path->method]] : []; - } - - /** - * Determine if the endpoint has any paths. - * - * @return bool - */ - public function hasPaths() - { - return count($this->paths) > 0; - } - - /** - * Get all of the path definitions for an endpoint. - * - * @return array[AbstractPath] - */ - public function getPaths() - { - return $this->paths; - } - - /** - * Get the template for the endpoint. - * - * @return string - */ - protected function getTemplate() - { - return '// %s -$router->group([\'middleware\' => [%s], \'prefix\' => %s, \'where\' => [%s], \'domain\' => %s], function() use ($router) -{ - $router->resource(%s, %s, [\'only\' => [%s], \'names\' => [%s]]); -});'; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/ResourcePath.php
@@ -1,51 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -class ResourcePath extends AbstractPath { - - /** - * The controller method of the resource path. - * - * @param string $method - */ - public $method; - - /** - * Create a new Resource Path instance. - * - * @param string $method - * @return void - */ - public function __construct($method) - { - $this->method = $method; - $this->verb = $this->getVerb($method); - } - - /** - * Get the verb for the given resource method. - * - * @param string $method - * @return string - */ - protected function getVerb($method) - { - switch ($method) - { - case 'index': - case 'create': - case 'show': - case 'edit': - return 'get'; - - case 'store': - return 'post'; - - case 'update': - return 'put'; - - case 'destroy': - return 'delete'; - } - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
src/Illuminate/Routing/Annotations/Scanner.php
@@ -1,158 +0,0 @@ -<?php namespace Illuminate\Routing\Annotations; - -use ReflectionClass; -use Symfony\Component\Finder\Finder; -use Doctrine\Common\Annotations\AnnotationRegistry; -use Doctrine\Common\Annotations\SimpleAnnotationReader; - -class Scanner { - - /** - * The path to scan for annotations. - * - * @var array - */ - protected $scan; - - /** - * Create a new scanner instance. - * - * @param array $scan - * @return void - */ - public function __construct(array $scan) - { - $this->scan = $scan; - - foreach (Finder::create()->files()->in(__DIR__.'/Annotations') as $file) - { - AnnotationRegistry::registerFile($file->getRealPath()); - } - } - - /** - * Create a new scanner instance. - * - * @param array $scan - * @return static - */ - public static function create(array $scan) - { - return new static($scan); - } - - /** - * Convert the scanned annotations into route definitions. - * - * @return string - */ - public function getRouteDefinitions() - { - $output = ''; - - foreach ($this->getEndpointsInClasses($this->getReader()) as $endpoint) - { - $output .= $endpoint->toRouteDefinition().PHP_EOL.PHP_EOL; - } - - return trim($output); - } - - /** - * Scan the directory and generate the route manifest. - * - * @param \Doctrine\Common\Annotations\SimpleAnnotationReader $reader - * @return \Illuminate\Routing\Annotations\EndpointCollection - */ - protected function getEndpointsInClasses(SimpleAnnotationReader $reader) - { - $endpoints = new EndpointCollection; - - foreach ($this->getClassesToScan() as $class) - { - $endpoints = $endpoints->merge($this->getEndpointsInClass( - $class, new AnnotationSet($class, $reader) - )); - } - - return $endpoints; - } - - /** - * Build the Endpoints for the given class. - * - * @param \ReflectionClass $class - * @param \Illuminate\Routing\Annotations\AnnotationSet $annotations - * @return \Illuminate\Routing\Annotations\EndpointCollection - */ - protected function getEndpointsInClass(ReflectionClass $class, AnnotationSet $annotations) - { - $endpoints = new EndpointCollection; - - foreach ($annotations->method as $method => $methodAnnotations) - $this->addEndpoint($endpoints, $class, $method, $methodAnnotations); - - foreach ($annotations->class as $annotation) - $annotation->modifyCollection($endpoints, $class); - - return $endpoints; - } - - /** - * Create a new endpoint in the collection. - * - * @param \Illuminate\Routing\Annotations\EndpointCollection $endpoints - * @param \ReflectionClass $class - * @param string $method - * @param array $annotations - * @return void - */ - protected function addEndpoint(EndpointCollection $endpoints, ReflectionClass $class, - $method, array $annotations) - { - $endpoints->push($endpoint = new MethodEndpoint([ - 'reflection' => $class, 'method' => $method, 'uses' => $class->name.'@'.$method - ])); - - foreach ($annotations as $annotation) - $annotation->modify($endpoint, $class->getMethod($method)); - } - - /** - * Get all of the ReflectionClass instances in the scan array. - * - * @return array - */ - protected function getClassesToScan() - { - $classes = []; - - foreach ($this->scan as $scan) - { - try - { - $classes[] = new ReflectionClass($scan); - } - catch (Exception $e) - { - // - } - } - - return $classes; - } - - /** - * Get an annotation reader instance. - * - * @return \Doctrine\Common\Annotations\SimpleAnnotationReader - */ - protected function getReader() - { - with($reader = new SimpleAnnotationReader) - ->addNamespace('Illuminate\Routing\Annotations\Annotations'); - - return $reader; - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
tests/Routing/RoutingAnnotationScannerTest.php
@@ -1,16 +0,0 @@ -<?php - -use Illuminate\Routing\Annotations\Scanner; - -class RoutingAnnotationScannerTest extends PHPUnit_Framework_TestCase { - - public function testProperRouteDefinitionsAreGenerated() - { - require_once __DIR__.'/fixtures/annotations/BasicController.php'; - $scanner = Scanner::create(['App\Http\Controllers\BasicController']); - $definition = str_replace(PHP_EOL, "\n", $scanner->getRouteDefinitions()); - - $this->assertEquals(trim(file_get_contents(__DIR__.'/results/annotation-basic.php')), $definition); - } - -}
true
Other
laravel
framework
4d9f92ef77b3610a05f71110f539daff06e9081d.json
Remove annotation support. This will be taken over as a 3rd party package. @artisangoose has volunteered.
tests/Routing/results/annotation-basic.php
@@ -1,19 +0,0 @@ -$router->put('more/{id}', [ - 'uses' => 'App\Http\Controllers\BasicController@doMore', - 'as' => NULL, - 'middleware' => ['FooMiddleware', 'BarMiddleware', 'QuxMiddleware'], - 'where' => ['id' => 'regex'], - 'domain' => '{id}.account.com', -]); - -// Resource: foobar/photos@index -$router->group(['middleware' => ['FooMiddleware', 'BarMiddleware', 'BoomMiddleware', 'BazMiddleware'], 'prefix' => NULL, 'where' => ['id' => 'regex'], 'domain' => '{id}.account.com'], function() use ($router) -{ - $router->resource('foobar/photos', 'App\\Http\\Controllers\\BasicController', ['only' => ['index'], 'names' => ['index' => 'index.name']]); -}); - -// Resource: foobar/photos@update -$router->group(['middleware' => ['FooMiddleware', 'BarMiddleware'], 'prefix' => NULL, 'where' => ['id' => 'regex'], 'domain' => '{id}.account.com'], function() use ($router) -{ - $router->resource('foobar/photos', 'App\\Http\\Controllers\\BasicController', ['only' => ['update'], 'names' => []]); -});
true
Other
laravel
framework
3800ecb1f28a40964df80d51b4230288d49ecc7a.json
Move some things into the dispatcher.
src/Illuminate/Bus/Dispatcher.php
@@ -53,6 +53,119 @@ public function __construct(Container $container, Closure $queueResolver = null) $this->queueResolver = $queueResolver; } + /** + * Marshal a command and dispatch it to its appropriate handler. + * + * @param mixed $command + * @param array $array + * @return mixed + */ + public function dispatchFromArray($command, array $array) + { + return $this->dispatch($this->marshalFromArray($command, $array)); + } + + /** + * Marshal a command and dispatch it to its appropriate handler. + * + * @param mixed $command + * @param array $array + * @return mixed + */ + public function dispatchFrom($command, ArrayAccess $source, $extras = []) + { + return $this->dispatch($this->marshal($command, $source, $extras)); + } + + /** + * Marshal a command from the given array. + * + * @param string $command + * @param array $array + * @return mixed + */ + protected function marshalFromArray($command, array $array) + { + return $this->marshal($command, new Collection, $array); + } + + /** + * Marshal a command from the given array accessible object. + * + * @param string $command + * @param \ArrayAccess $source + * @param array $extras + * @return mixed + */ + protected function marshal($command, ArrayAccess $source, $extras = []) + { + $injected = []; + + $reflection = new ReflectionClass($command); + + if ($constructor = $reflection->getConstructor()) + { + $injected = array_map(function($parameter) use ($command, $source, $extras) + { + return $this->getParameterValueForCommand($command, $source, $parameter, $extras); + + }, $constructor->getParameters()); + } + + return $reflection->newInstanceArgs($injected); + } + + /** + * Get a parameter value for a marshalled command. + * + * @param string $command + * @param \ArrayAccess $source + * @param \ReflectionParameter $parameter + * @param array $extras + * @return mixed + */ + protected function getParameterValueForCommand($command, ArrayAccess $source, + ReflectionParameter $parameter, array $extras = array()) + { + $value = $this->extractValueFromExtras($parameter, $extras) + ?: $this->extractValueFromSource($source, $parameter); + + if (is_null($value) && $parameter->isDefaultValueAvailable()) + { + $value = $parameter->getDefaultValue(); + } + elseif (is_null($value)) + { + MarshalException::whileMapping($command, $parameter); + } + + return $value; + } + + /** + * Attempt to extract the given parameter out of the given array. + * + * @param \ReflectionParameter $parameter + * @param array $extras + * @return mixed + */ + protected function extractValueFromExtras(ReflectionParameter $parameter, array $extras) + { + return array_get($extras, $parameter->name); + } + + /** + * Attempt to extract the given parameter out of the source. + * + * @param \ArrayAccess $source + * @param \ReflectionParameter $parameter + * @return mixed + */ + protected function extractValueFromSource(ArrayAccess $source, ReflectionParameter $parameter) + { + return array_get($source, $parameter->name); + } + /** * Dispatch a command to its appropriate handler. *
true
Other
laravel
framework
3800ecb1f28a40964df80d51b4230288d49ecc7a.json
Move some things into the dispatcher.
src/Illuminate/Contracts/Bus/Dispatcher.php
@@ -1,9 +1,28 @@ <?php namespace Illuminate\Contracts\Bus; use Closure; +use ArrayAccess; interface Dispatcher { + /** + * Marshal a command and dispatch it to its appropriate handler. + * + * @param mixed $command + * @param array $array + * @return mixed + */ + public function dispatchFromArray($command, array $array); + + /** + * Marshal a command and dispatch it to its appropriate handler. + * + * @param mixed $command + * @param array $array + * @return mixed + */ + public function dispatchFrom($command, ArrayAccess $source, $extras = []); + /** * Dispatch a command to its appropriate handler. *
true
Other
laravel
framework
3800ecb1f28a40964df80d51b4230288d49ecc7a.json
Move some things into the dispatcher.
src/Illuminate/Foundation/Bus/DispatchesCommands.php
@@ -27,7 +27,7 @@ protected function dispatch($command) */ protected function dispatchFromArray($command, array $array) { - return $this->dispatch($this->marshalFromArray($command, $array)); + return app('Illuminate\Contracts\Bus\Dispatcher')->dispatchFromArray($command, $array); } /** @@ -39,96 +39,7 @@ protected function dispatchFromArray($command, array $array) */ protected function dispatchFrom($command, ArrayAccess $source, $extras = []) { - return $this->dispatch($this->marshal($command, $source, $extras)); - } - - /** - * Marshal a command from the given array. - * - * @param string $command - * @param array $array - * @return mixed - */ - public function marshalFromArray($command, array $array) - { - return $this->marshal($command, new Collection, $array); - } - - /** - * Marshal a command from the given array accessible object. - * - * @param string $command - * @param \ArrayAccess $source - * @param array $extras - * @return mixed - */ - public function marshal($command, ArrayAccess $source, $extras = []) - { - $injected = []; - - $reflection = new ReflectionClass($command); - - if ($constructor = $reflection->getConstructor()) - { - $injected = array_map(function($parameter) use ($command, $source, $extras) - { - return $this->getParameterValueForCommand($command, $source, $parameter, $extras); - - }, $constructor->getParameters()); - } - - return $reflection->newInstanceArgs($injected); - } - - /** - * Get a parameter value for a marshalled command. - * - * @param string $command - * @param \ArrayAccess $source - * @param \ReflectionParameter $parameter - * @param array $extras - * @return mixed - */ - protected function getParameterValueForCommand($command, ArrayAccess $source, - ReflectionParameter $parameter, array $extras = array()) - { - $value = $this->extractValueFromExtras($parameter, $extras) - ?: $this->extractValueFromSource($source, $parameter); - - if (is_null($value) && $parameter->isDefaultValueAvailable()) - { - $value = $parameter->getDefaultValue(); - } - elseif (is_null($value)) - { - MarshalException::whileMapping($command, $parameter); - } - - return $value; - } - - /** - * Attempt to extract the given parameter out of the given array. - * - * @param \ReflectionParameter $parameter - * @param array $extras - * @return mixed - */ - protected function extractValueFromExtras(ReflectionParameter $parameter, array $extras) - { - return array_get($extras, $parameter->name); - } - - /** - * Attempt to extract the given parameter out of the source. - * - * @param \ArrayAccess $source - * @param \ReflectionParameter $parameter - * @return mixed - */ - protected function extractValueFromSource(ArrayAccess $source, ReflectionParameter $parameter) - { - return array_get($source, $parameter->name); + return app('Illuminate\Contracts\Bus\Dispatcher')->dispatchFrom($command, $source, $extras); } }
true
Other
laravel
framework
ef8ee59f93da71798412271a7c0cb8f45a1a3c9d.json
Fix comment style
tests/Routing/RoutingUrlGeneratorTest.php
@@ -290,9 +290,7 @@ public function testForceRootUrl() $url->forceRootUrl('https://www.bar.com'); $this->assertEquals('http://www.bar.com/foo/bar', $url->to('foo/bar')); - /** - * Ensure trailing / is trimmed from root URL as UrlGenerator already handles this - */ + // Ensure trailing slash is trimmed from root URL as UrlGenerator already handles this $url->forceRootUrl('http://www.foo.com/'); $this->assertEquals('http://www.foo.com/bar', $url->to('/bar'));
false
Other
laravel
framework
924a7fcf21bbba4f4efc8e367f456cea5e4d25c1.json
Remove incomplete sanitization feature.
src/Illuminate/Foundation/Http/FormRequest.php
@@ -28,13 +28,6 @@ class FormRequest extends Request implements ValidatesWhenResolved { */ protected $redirector; - /** - * The sanitized input. - * - * @var array - */ - protected $sanitized; - /** * The URI to redirect to if validation fails. * @@ -85,39 +78,10 @@ protected function getValidatorInstance() } return $factory->make( - $this->sanitizeInput(), $this->container->call([$this, 'rules']), $this->messages() + $this->all(), $this->container->call([$this, 'rules']), $this->messages() ); } - /** - * Sanitize the input. - * - * @return array - */ - protected function sanitizeInput() - { - if (method_exists($this, 'sanitize')) - { - return $this->sanitized = $this->container->call([$this, 'sanitize']); - } - - return $this->all(); - } - - /** - * Get sanitized input. - * - * @param string $key - * @param mixed $default - * @return mixed - */ - public function sanitized($key = null, $default = null) - { - $input = is_null($this->sanitized) ? $this->all() : $this->sanitized; - - return array_get($input, $key, $default); - } - /** * Handle a failed validation attempt. *
false
Other
laravel
framework
253f22ad2e9687e6a5e3ee36e82846dfca943b89.json
Fix exception name Should be InvalidArgumentException, not InvalidParamException
src/Illuminate/Foundation/Console/OptimizeCommand.php
@@ -1,6 +1,6 @@ <?php namespace Illuminate\Foundation\Console; -use InvalidParamException; +use InvalidArgumentException; use Illuminate\Console\Command; use Illuminate\Foundation\Composer; use Illuminate\View\Engines\CompilerEngine;
false
Other
laravel
framework
7d5fc7e6db736ef76b6092f1d29bdd73a80360ce.json
Ignore more files on export
.gitattributes
@@ -1,2 +1,8 @@ /build export-ignore /tests export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.scrutinizer.yml export-ignore +.travis.yml export-ignore +phpunit.php export-ignore +phpunit.xml export-ignore
false
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Cache/DatabaseStore.php
@@ -1,5 +1,6 @@ <?php namespace Illuminate\Cache; +use Exception; use LogicException; use Illuminate\Database\ConnectionInterface; use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract; @@ -104,7 +105,7 @@ public function put($key, $value, $minutes) { $this->table()->insert(compact('key', 'value', 'expiration')); } - catch (\Exception $e) + catch (Exception $e) { $this->table()->where('key', '=', $key)->update(compact('value', 'expiration')); }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Cache/FileStore.php
@@ -1,5 +1,6 @@ <?php namespace Illuminate\Cache; +use Exception; use Illuminate\Filesystem\Filesystem; class FileStore implements StoreInterface { @@ -64,7 +65,7 @@ protected function getPayload($key) { $expire = substr($contents = $this->files->get($path), 0, 10); } - catch (\Exception $e) + catch (Exception $e) { return array('data' => null, 'time' => null); } @@ -118,7 +119,7 @@ protected function createCacheDirectory($path) { $this->files->makeDirectory(dirname($path), 0777, true, true); } - catch (\Exception $e) + catch (Exception $e) { // }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Database/Connection.php
@@ -3,6 +3,7 @@ use PDO; use Closure; use DateTime; +use Exception; use LogicException; use RuntimeException; use Illuminate\Contracts\Events\Dispatcher; @@ -451,7 +452,7 @@ public function transaction(Closure $callback) // If we catch an exception, we will roll back so nothing gets messed // up in the database. Then we'll re-throw the exception so it can // be handled how the developer sees fit for their applications. - catch (\Exception $e) + catch (Exception $e) { $this->rollBack(); @@ -608,7 +609,7 @@ protected function runQueryCallback($query, $bindings, Closure $callback) // If an exception occurs when attempting to run a query, we'll format the error // message to include the bindings with SQL, which will make this exception a // lot more helpful to the developer instead of just the database's errors. - catch (\Exception $e) + catch (Exception $e) { throw new QueryException( $query, $this->prepareBindings($bindings), $e
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Database/SqlServerConnection.php
@@ -1,6 +1,7 @@ <?php namespace Illuminate\Database; use Closure; +use Exception; use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as DoctrineDriver; use Illuminate\Database\Query\Processors\SqlServerProcessor; use Illuminate\Database\Query\Grammars\SqlServerGrammar as QueryGrammar; @@ -38,7 +39,7 @@ public function transaction(Closure $callback) // If we catch an exception, we will roll back so nothing gets messed // up in the database. Then we'll re-throw the exception so it can // be handled how the developer sees fit for their applications. - catch (\Exception $e) + catch (Exception $e) { $this->pdo->exec('ROLLBACK TRAN');
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Encryption/Encrypter.php
@@ -1,5 +1,6 @@ <?php namespace Illuminate\Encryption; +use Exception; use Illuminate\Contracts\Encryption\DecryptException; use Symfony\Component\Security\Core\Util\StringUtils; use Symfony\Component\Security\Core\Util\SecureRandom; @@ -115,7 +116,7 @@ protected function mcryptDecrypt($value, $iv) { return mcrypt_decrypt($this->cipher, $this->key, $value, $this->mode, $iv); } - catch (\Exception $e) + catch (Exception $e) { throw new DecryptException($e->getMessage()); }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Events/Annotations/Scanner.php
@@ -1,5 +1,6 @@ <?php namespace Illuminate\Events\Annotations; +use Exception; use ReflectionClass; use Symfony\Component\Finder\Finder; use Doctrine\Common\Annotations\AnnotationRegistry; @@ -94,7 +95,7 @@ protected function getClassesToScan() { $classes[] = new ReflectionClass($class); } - catch (\Exception $e) + catch (Exception $e) { // }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Events/Dispatcher.php
@@ -1,5 +1,6 @@ <?php namespace Illuminate\Events; +use Exception; use ReflectionClass; use Illuminate\Container\Container; use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; @@ -375,7 +376,7 @@ protected function handlerShouldBeQueued($class) 'Illuminate\Contracts\Queue\ShouldBeQueued' ); } - catch (\Exception $e) + catch (Exception $e) { return false; }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Foundation/Console/OptimizeCommand.php
@@ -1,5 +1,6 @@ <?php namespace Illuminate\Foundation\Console; +use InvalidParamException; use Illuminate\Console\Command; use Illuminate\Foundation\Composer; use Illuminate\View\Engines\CompilerEngine; @@ -140,7 +141,7 @@ protected function compileViews() { $engine = $this->laravel['view']->getEngineFromPath($file); } - catch (\InvalidArgumentException $e) + catch (InvalidArgumentException $e) { continue; }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Queue/Console/SubscribeCommand.php
@@ -1,5 +1,6 @@ <?php namespace Illuminate\Queue\Console; +use Exception; use RuntimeException; use Illuminate\Queue\IronQueue; use Illuminate\Console\Command; @@ -75,7 +76,7 @@ protected function getPushType() { return $this->getQueue()->push_type; } - catch (\Exception $e) + catch (Exception $e) { return 'multicast'; } @@ -106,7 +107,7 @@ protected function getCurrentSubscribers() { return $this->getQueue()->subscribers; } - catch (\Exception $e) + catch (Exception $e) { return array(); }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Queue/Worker.php
@@ -1,5 +1,6 @@ <?php namespace Illuminate\Queue; +use Exception; use Illuminate\Contracts\Queue\Job; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Queue\Failed\FailedJobProviderInterface; @@ -111,7 +112,7 @@ protected function runNextJobForDaemon($connectionName, $queue, $delay, $sleep, { $this->pop($connectionName, $queue, $delay, $sleep, $maxTries); } - catch (\Exception $e) + catch (Exception $e) { if ($this->exceptions) $this->exceptions->report($e); } @@ -208,7 +209,7 @@ public function process($connection, Job $job, $maxTries = 0, $delay = 0) return ['job' => $job, 'failed' => false]; } - catch (\Exception $e) + catch (Exception $e) { // If we catch an exception, we will attempt to release the job back onto // the queue so it is not lost. This will let is be retried at a later
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Routing/Annotations/Scanner.php
@@ -133,7 +133,7 @@ protected function getClassesToScan() { $classes[] = new ReflectionClass($scan); } - catch (\Exception $e) + catch (Exception $e) { // }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/Validation/Validator.php
@@ -3,6 +3,7 @@ use Closure; use DateTime; use Countable; +use Exception; use DateTimeZone; use RuntimeException; use BadMethodCallException; @@ -1437,7 +1438,7 @@ protected function getDateTimeWithOptionalFormat($format, $value) { return new DateTime($value); } - catch (\Exception $e) + catch (Exception $e) { return; } @@ -1456,7 +1457,7 @@ protected function validateTimezone($attribute, $value) { new DateTimeZone($value); } - catch (\Exception $e) + catch (Exception $e) { return false; }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/View/Engines/PhpEngine.php
@@ -1,5 +1,7 @@ <?php namespace Illuminate\View\Engines; +use Exception; + class PhpEngine implements EngineInterface { /** @@ -36,7 +38,7 @@ protected function evaluatePath($__path, $__data) { include $__path; } - catch (\Exception $e) + catch (Exception $e) { $this->handleViewException($e, $obLevel); }
true
Other
laravel
framework
371728db97cb4b79296d8865f784f2ea1eb97252.json
Use FQN for exceptions
src/Illuminate/View/Factory.php
@@ -231,7 +231,7 @@ public function exists($view) { $this->finder->find($view); } - catch (\InvalidArgumentException $e) + catch (InvalidArgumentException $e) { return false; }
true
Other
laravel
framework
cd6fea1d6e293a518433c69bcfaacaca3f39babd.json
refine the code & add related test case
src/Illuminate/Pagination/Paginator.php
@@ -143,8 +143,7 @@ protected function calculateCurrentAndLastPages() } else { - $this->lastPage = (int) ceil($this->total / $this->perPage); - $this->lastPage = ($this->lastPage > 0) ? $this->lastPage : 1; + $this->lastPage = max((int) ceil($this->total / $this->perPage), 1); $this->currentPage = $this->calculateCurrentPage($this->lastPage); }
true
Other
laravel
framework
cd6fea1d6e293a518433c69bcfaacaca3f39babd.json
refine the code & add related test case
tests/Pagination/PaginationPaginatorTest.php
@@ -21,6 +21,16 @@ public function testPaginationContextIsSetupCorrectly() $this->assertEquals(1, $p->getCurrentPage()); } + public function testPaginationContextIsSetupCorrectlyWithEmptyItems() + { + $p = new Paginator($factory = m::mock('Illuminate\Pagination\Factory'), array(), 0, 2); + $factory->shouldReceive('getCurrentPage')->once()->andReturn(1); + $p->setupPaginationContext(); + + $this->assertEquals(1, $p->getLastPage()); + $this->assertEquals(1, $p->getCurrentPage()); + } + public function testSimplePagination() {
true
Other
laravel
framework
0023d9b6bb2d25195be28227c81729c000ee4b4b.json
Return collection from query builder
src/Illuminate/Database/Eloquent/Builder.php
@@ -150,7 +150,7 @@ public function firstOrFail($columns = array('*')) */ public function get($columns = array('*')) { - $models = $this->getModels($columns); + $models = $this->getModels($columns)->all(); // If we actually found models we will also eager load any relationships that // have been specified as needing to be eager loaded, which will solve the @@ -364,30 +364,19 @@ public function onDelete(Closure $callback) * Get the hydrated models without eager loading. * * @param array $columns - * @return \Illuminate\Database\Eloquent\Model[] + * @return \Illuminate\Support\Collection */ public function getModels($columns = array('*')) { - // First, we will simply get the raw results from the query builders which we - // can use to populate an array with Eloquent models. We will pass columns - // that should be selected as well, which are typically just everything. - $results = $this->query->get($columns); - $connection = $this->model->getConnectionName(); - $models = array(); - - // Once we have the results, we can spin through them and instantiate a fresh - // model instance for each records we retrieved from the database. We will - // also set the proper connection name for the model after we create it. - foreach ($results as $result) + // We will first get the raw results from the query builder. We'll then + // transform the raw results into Eloquent models, while also setting + // the proper database connection on every Eloquent model instance. + return $this->query->get($columns)->map(function($result) use ($connection) { - $models[] = $model = $this->model->newFromBuilder($result); - - $model->setConnection($connection); - } - - return $models; + return $this->model->newFromBuilder($result)->setConnection($connection); + }); } /**
true
Other
laravel
framework
0023d9b6bb2d25195be28227c81729c000ee4b4b.json
Return collection from query builder
src/Illuminate/Database/Eloquent/Model.php
@@ -487,11 +487,11 @@ public function newFromBuilder($attributes = array()) /** * Create a collection of models from plain arrays. * - * @param array $items + * @param array|\ArrayAccess $items * @param string $connection * @return \Illuminate\Database\Eloquent\Collection */ - public static function hydrate(array $items, $connection = null) + public static function hydrate($items, $connection = null) { $collection = with($instance = new static)->newCollection();
true
Other
laravel
framework
0023d9b6bb2d25195be28227c81729c000ee4b4b.json
Return collection from query builder
src/Illuminate/Database/Query/Builder.php
@@ -1287,20 +1287,18 @@ public function pluck($column) * Execute the query and get the first result. * * @param array $columns - * @return mixed|static + * @return mixed */ public function first($columns = array('*')) { - $results = $this->take(1)->get($columns); - - return count($results) > 0 ? reset($results) : null; + return $this->take(1)->get($columns)->first(); } /** * Execute the query as a "select" statement. * * @param array $columns - * @return array|static[] + * @return \Illuminate\Support\Collection */ public function get($columns = array('*')) { @@ -1311,13 +1309,15 @@ public function get($columns = array('*')) * Execute the query as a fresh "select" statement. * * @param array $columns - * @return array|static[] + * @return \Illuminate\Support\Collection */ public function getFresh($columns = array('*')) { if (is_null($this->columns)) $this->columns = $columns; - return $this->processor->processSelect($this, $this->runSelect()); + $results = $this->processor->processSelect($this, $this->runSelect()); + + return new Collection($results); } /** @@ -1462,7 +1462,7 @@ public function lists($column, $key = null) // First we will just get all of the column values for the record result set // then we can associate those values with the column if it was specified // otherwise we can just give these values back without a specific key. - $results = new Collection($this->get($columns)); + $results = $this->get($columns); $values = $results->fetch($columns[0])->all(); @@ -1600,7 +1600,7 @@ public function aggregate($function, $columns = array('*')) $previousColumns = $this->columns; - $results = $this->get($columns); + $results = $this->get($columns)->all(); // Once we have executed the query, we will reset the aggregate property so // that more select queries can be executed against the database without
true
Other
laravel
framework
0023d9b6bb2d25195be28227c81729c000ee4b4b.json
Return collection from query builder
src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php
@@ -63,7 +63,7 @@ public function log($connection, $queue, $payload) */ public function all() { - return $this->getTable()->orderBy('id', 'desc')->get(); + return $this->getTable()->orderBy('id', 'desc')->get()->all(); } /**
true
Other
laravel
framework
0023d9b6bb2d25195be28227c81729c000ee4b4b.json
Return collection from query builder
tests/Database/DatabaseEloquentBuilderTest.php
@@ -106,7 +106,7 @@ public function testFirstMethod() public function testGetMethodLoadsModelsAndHydratesEagerRelations() { $builder = m::mock('Illuminate\Database\Eloquent\Builder[getModels,eagerLoadRelations]', array($this->getMockQueryBuilder())); - $builder->shouldReceive('getModels')->with(array('foo'))->andReturn(array('bar')); + $builder->shouldReceive('getModels')->with(array('foo'))->andReturn(new Collection(array('bar'))); $builder->shouldReceive('eagerLoadRelations')->with(array('bar'))->andReturn(array('bar', 'baz')); $builder->setModel($this->getMockModel()); $builder->getModel()->shouldReceive('newCollection')->with(array('bar', 'baz'))->andReturn(new Collection(array('bar', 'baz'))); @@ -119,7 +119,7 @@ public function testGetMethodLoadsModelsAndHydratesEagerRelations() public function testGetMethodDoesntHydrateEagerRelationsWhenNoResultsAreReturned() { $builder = m::mock('Illuminate\Database\Eloquent\Builder[getModels,eagerLoadRelations]', array($this->getMockQueryBuilder())); - $builder->shouldReceive('getModels')->with(array('foo'))->andReturn(array()); + $builder->shouldReceive('getModels')->with(array('foo'))->andReturn(new Collection); $builder->shouldReceive('eagerLoadRelations')->never(); $builder->setModel($this->getMockModel()); $builder->getModel()->shouldReceive('newCollection')->with(array())->andReturn(new Collection(array())); @@ -221,13 +221,13 @@ public function testGetModelsProperlyHydratesModels() $builder = m::mock('Illuminate\Database\Eloquent\Builder[get]', array($this->getMockQueryBuilder())); $records[] = array('name' => 'taylor', 'age' => 26); $records[] = array('name' => 'dayle', 'age' => 28); - $builder->getQuery()->shouldReceive('get')->once()->with(array('foo'))->andReturn($records); + $builder->getQuery()->shouldReceive('get')->once()->with(array('foo'))->andReturn(new Collection($records)); $model = m::mock('Illuminate\Database\Eloquent\Model[getTable,getConnectionName,newInstance]'); $model->shouldReceive('getTable')->once()->andReturn('foo_table'); $builder->setModel($model); $model->shouldReceive('getConnectionName')->once()->andReturn('foo_connection'); $model->shouldReceive('newInstance')->andReturnUsing(function() { return new EloquentBuilderTestModelStub; }); - $models = $builder->getModels(array('foo')); + $models = $builder->getModels(['foo']); $this->assertEquals('taylor', $models[0]->name); $this->assertEquals($models[0]->getAttributes(), $models[0]->getOriginal());
true
Other
laravel
framework
0023d9b6bb2d25195be28227c81729c000ee4b4b.json
Return collection from query builder
tests/Database/DatabaseEloquentModelTest.php
@@ -1101,7 +1101,7 @@ public function newQuery() } class EloquentModelHydrateRawStub extends Illuminate\Database\Eloquent\Model { - public static function hydrate(array $items, $connection = null) { return 'hydrated'; } + public static function hydrate($items, $connection = null) { return 'hydrated'; } public function getConnection() { $mock = m::mock('Illuminate\Database\Connection');
true
Other
laravel
framework
0023d9b6bb2d25195be28227c81729c000ee4b4b.json
Return collection from query builder
tests/Database/DatabaseQueryBuilderTest.php
@@ -699,7 +699,7 @@ public function testAggregateResetFollowedByGet() $sum = $builder->sum('id'); $this->assertEquals(2, $sum); $result = $builder->get(); - $this->assertEquals(array(array('column1' => 'foo', 'column2' => 'bar')), $result); + $this->assertEquals(array(array('column1' => 'foo', 'column2' => 'bar')), $result->all()); } @@ -713,7 +713,7 @@ public function testAggregateResetFollowedBySelectGet() $count = $builder->count('column1'); $this->assertEquals(1, $count); $result = $builder->select('column2', 'column3')->get(); - $this->assertEquals(array(array('column2' => 'foo', 'column3' => 'bar')), $result); + $this->assertEquals(array(array('column2' => 'foo', 'column3' => 'bar')), $result->all()); } @@ -727,7 +727,7 @@ public function testAggregateResetFollowedByGetWithColumns() $count = $builder->count('column1'); $this->assertEquals(1, $count); $result = $builder->get(array('column2', 'column3')); - $this->assertEquals(array(array('column2' => 'foo', 'column3' => 'bar')), $result); + $this->assertEquals(array(array('column2' => 'foo', 'column3' => 'bar')), $result->all()); }
true
Other
laravel
framework
06b91833d2dc83f4cf554a9625f4003c435db6c6.json
Fix variable name.
src/Illuminate/Foundation/Console/stubs/event-handler-queued.stub
@@ -25,7 +25,7 @@ class {{class}} implements ShouldBeQueued { * @param {{event}} * @return void */ - public function handle({{event}} $command) + public function handle({{event}} $event) { // }
true
Other
laravel
framework
06b91833d2dc83f4cf554a9625f4003c435db6c6.json
Fix variable name.
src/Illuminate/Foundation/Console/stubs/event-handler.stub
@@ -23,7 +23,7 @@ class {{class}} { * @param {{event}} * @return void */ - public function handle({{event}} $command) + public function handle({{event}} $event) { // }
true
Other
laravel
framework
6469e261ec75a415fd626a4b5ab9bb07adddcd43.json
Add a "where date" statement to the query Add a "where date" statement to the query
src/Illuminate/Database/Query/Builder.php
@@ -869,7 +869,21 @@ public function orWhereNotNull($column) { return $this->whereNotNull($column, 'or'); } - + + /** + * Add a "where date" statement to the query. + * + * @param string $column + * @param string $operator + * @param int $value + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereDate($column, $operator, $value, $boolean = 'and') + { + return $this->addDateBasedWhere('Date', $column, $operator, $value, $boolean); + } + /** * Add a "where day" statement to the query. *
false
Other
laravel
framework
ca32323d7e29cad363d4014fde156440855919a8.json
fix conflicts and tests.
src/Illuminate/Database/Eloquent/Model.php
@@ -1830,14 +1830,7 @@ public function freshTimestampString() */ public function newQuery() { - $builder = $this->newEloquentBuilder( - $this->newBaseQueryBuilder() - ); - - // Once we have the query builders, we will set the model instances so the - // builder can easily access any information it may need from the model - // while it is constructing and executing various queries against it. - $builder->setModel($this)->with($this->with); + $builder = $this->newQueryWithoutScopes(); return $this->applyGlobalScopes($builder); } @@ -1862,7 +1855,14 @@ public function newQueryWithoutScope($scope) */ public function newQueryWithoutScopes() { - return $this->removeGlobalScopes($this->newQuery()); + $builder = $this->newEloquentBuilder( + $this->newBaseQueryBuilder() + ); + + // Once we have the query builders, we will set the model instances so the + // builder can easily access any information it may need from the model + // while it is constructing and executing various queries against it. + return $builder->setModel($this)->with($this->with); } /**
true
Other
laravel
framework
ca32323d7e29cad363d4014fde156440855919a8.json
fix conflicts and tests.
src/Illuminate/Support/Collection.php
@@ -650,11 +650,16 @@ public function splice($offset, $length = 0, $replacement = array()) /** * Get the sum of the given values. * - * @param \Closure $callback + * @param \Closure|null $callback * @return mixed */ - public function sum($callback) + public function sum($callback = null) { + if (is_null($callback)) + { + return array_sum($this->items); + } + if (is_string($callback)) { $callback = $this->valueRetriever($callback);
true
Other
laravel
framework
ca32323d7e29cad363d4014fde156440855919a8.json
fix conflicts and tests.
tests/Database/DatabaseEloquentModelTest.php
@@ -150,11 +150,11 @@ public function testWithMethodCallsQueryBuilderCorrectlyWithArray() public function testUpdateProcess() { - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('where')->once()->with('id', '=', 1); $query->shouldReceive('update')->once()->with(array('name' => 'taylor')); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('updateTimestamps'); $model->setEventDispatcher($events = m::mock('Illuminate\Contracts\Events\Dispatcher')); $events->shouldReceive('until')->once()->with('eloquent.saving: '.get_class($model), $model)->andReturn(true); @@ -174,11 +174,11 @@ public function testUpdateProcess() public function testUpdateProcessDoesntOverrideTimestamps() { - $model = $this->getMock('EloquentModelStub', array('newQuery')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('where')->once()->with('id', '=', 1); $query->shouldReceive('update')->once()->with(array('created_at' => 'foo', 'updated_at' => 'bar')); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->setEventDispatcher($events = m::mock('Illuminate\Contracts\Events\Dispatcher')); $events->shouldReceive('until'); $events->shouldReceive('fire'); @@ -194,9 +194,9 @@ public function testUpdateProcessDoesntOverrideTimestamps() public function testSaveIsCancelledIfSavingEventReturnsFalse() { - $model = $this->getMock('EloquentModelStub', array('newQuery')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->setEventDispatcher($events = m::mock('Illuminate\Contracts\Events\Dispatcher')); $events->shouldReceive('until')->once()->with('eloquent.saving: '.get_class($model), $model)->andReturn(false); $model->exists = true; @@ -207,9 +207,9 @@ public function testSaveIsCancelledIfSavingEventReturnsFalse() public function testUpdateIsCancelledIfUpdatingEventReturnsFalse() { - $model = $this->getMock('EloquentModelStub', array('newQuery')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->setEventDispatcher($events = m::mock('Illuminate\Contracts\Events\Dispatcher')); $events->shouldReceive('until')->once()->with('eloquent.saving: '.get_class($model), $model)->andReturn(true); $events->shouldReceive('until')->once()->with('eloquent.updating: '.get_class($model), $model)->andReturn(false); @@ -222,12 +222,12 @@ public function testUpdateIsCancelledIfUpdatingEventReturnsFalse() public function testUpdateProcessWithoutTimestamps() { - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps', 'fireModelEvent')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps', 'fireModelEvent')); $model->timestamps = false; $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('where')->once()->with('id', '=', 1); $query->shouldReceive('update')->once()->with(array('name' => 'taylor')); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->never())->method('updateTimestamps'); $model->expects($this->any())->method('fireModelEvent')->will($this->returnValue(true)); @@ -241,11 +241,11 @@ public function testUpdateProcessWithoutTimestamps() public function testUpdateUsesOldPrimaryKey() { - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('where')->once()->with('id', '=', 1); $query->shouldReceive('update')->once()->with(array('id' => 2, 'foo' => 'bar')); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('updateTimestamps'); $model->setEventDispatcher($events = m::mock('Illuminate\Contracts\Events\Dispatcher')); $events->shouldReceive('until')->once()->with('eloquent.saving: '.get_class($model), $model)->andReturn(true); @@ -344,10 +344,10 @@ public function testTimestampsAreCreatedFromStringsAndIntegers() public function testInsertProcess() { - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('updateTimestamps'); $model->setEventDispatcher($events = m::mock('Illuminate\Contracts\Events\Dispatcher')); @@ -362,10 +362,10 @@ public function testInsertProcess() $this->assertEquals(1, $model->id); $this->assertTrue($model->exists); - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insert')->once()->with(array('name' => 'taylor')); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('updateTimestamps'); $model->setIncrementing(false); @@ -385,9 +385,9 @@ public function testInsertProcess() public function testInsertIsCancelledIfCreatingEventReturnsFalse() { - $model = $this->getMock('EloquentModelStub', array('newQuery')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->setEventDispatcher($events = m::mock('Illuminate\Contracts\Events\Dispatcher')); $events->shouldReceive('until')->once()->with('eloquent.saving: '.get_class($model), $model)->andReturn(true); $events->shouldReceive('until')->once()->with('eloquent.creating: '.get_class($model), $model)->andReturn(false); @@ -399,11 +399,11 @@ public function testInsertIsCancelledIfCreatingEventReturnsFalse() public function testDeleteProperlyDeletesModel() { - $model = $this->getMock('Illuminate\Database\Eloquent\Model', array('newQuery', 'updateTimestamps', 'touchOwners')); + $model = $this->getMock('Illuminate\Database\Eloquent\Model', array('newQueryWithoutScopes', 'updateTimestamps', 'touchOwners')); $query = m::mock('stdClass'); $query->shouldReceive('where')->once()->with('id', 1)->andReturn($query); $query->shouldReceive('delete')->once(); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('touchOwners'); $model->exists = true; $model->id = 1; @@ -413,10 +413,10 @@ public function testDeleteProperlyDeletesModel() public function testPushNoRelations() { - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('updateTimestamps'); $model->name = 'taylor'; @@ -430,10 +430,10 @@ public function testPushNoRelations() public function testPushEmptyOneRelation() { - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('updateTimestamps'); $model->name = 'taylor'; @@ -449,18 +449,18 @@ public function testPushEmptyOneRelation() public function testPushOneRelation() { - $related1 = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $related1 = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insertGetId')->once()->with(array('name' => 'related1'), 'id')->andReturn(2); - $related1->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $related1->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $related1->expects($this->once())->method('updateTimestamps'); $related1->name = 'related1'; $related1->exists = false; - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('updateTimestamps'); $model->name = 'taylor'; @@ -479,10 +479,10 @@ public function testPushOneRelation() public function testPushEmptyManyRelation() { - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('updateTimestamps'); $model->name = 'taylor'; @@ -498,26 +498,26 @@ public function testPushEmptyManyRelation() public function testPushManyRelation() { - $related1 = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $related1 = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insertGetId')->once()->with(array('name' => 'related1'), 'id')->andReturn(2); - $related1->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $related1->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $related1->expects($this->once())->method('updateTimestamps'); $related1->name = 'related1'; $related1->exists = false; - $related2 = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $related2 = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insertGetId')->once()->with(array('name' => 'related2'), 'id')->andReturn(3); - $related2->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $related2->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $related2->expects($this->once())->method('updateTimestamps'); $related2->name = 'related2'; $related2->exists = false; - $model = $this->getMock('EloquentModelStub', array('newQuery', 'updateTimestamps')); + $model = $this->getMock('EloquentModelStub', array('newQueryWithoutScopes', 'updateTimestamps')); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('insertGetId')->once()->with(array('name' => 'taylor'), 'id')->andReturn(1); - $model->expects($this->once())->method('newQuery')->will($this->returnValue($query)); + $model->expects($this->once())->method('newQueryWithoutScopes')->will($this->returnValue($query)); $model->expects($this->once())->method('updateTimestamps'); $model->name = 'taylor'; @@ -1095,11 +1095,11 @@ public function testRelationshipTouchOwnersIsNotPropagatedIfNoRelationshipResult public function testTimestampsAreNotUpdatedWithTimestampsFalseSaveOption() { - $model = m::mock('EloquentModelStub[newQuery]'); + $model = m::mock('EloquentModelStub[newQueryWithoutScopes]'); $query = m::mock('Illuminate\Database\Eloquent\Builder'); $query->shouldReceive('where')->once()->with('id', '=', 1); $query->shouldReceive('update')->once()->with(array('name' => 'taylor')); - $model->shouldReceive('newQuery')->once()->andReturn($query); + $model->shouldReceive('newQueryWithoutScopes')->once()->andReturn($query); $model->id = 1; $model->syncOriginal();
true
Other
laravel
framework
ca32323d7e29cad363d4014fde156440855919a8.json
fix conflicts and tests.
tests/Support/SupportCollectionTest.php
@@ -515,6 +515,13 @@ public function testGettingSumFromCollection() } + public function testCanSumValuesWithoutACallback() + { + $c = new Collection([1, 2, 3, 4, 5]); + $this->assertEquals(15, $c->sum()); + } + + public function testGettingSumFromEmptyCollection() { $c = new Collection();
true
Other
laravel
framework
e6b368f7413d72b2095e445283df81827fcb47a4.json
Move env() to Foundation helper
src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php
@@ -20,7 +20,7 @@ public function bootstrap(Application $app) $app->detectEnvironment(function() { - return getenv('APP_ENV') ?: 'production'; + return env('APP_ENV', 'production'); }); }
true
Other
laravel
framework
e6b368f7413d72b2095e445283df81827fcb47a4.json
Move env() to Foundation helper
src/Illuminate/Foundation/helpers.php
@@ -534,6 +534,42 @@ function view($view = null, $data = array(), $mergeData = array()) } } +if ( ! function_exists('env')) +{ + /** + * Gets the value of an environment variable. Supports boolean, empty and null. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + function env($key, $default = null) + { + $value = getenv($key); + + if ($value === false) return value($default); + + switch (strtolower($value)) + { + case 'true': + case '(true)': + return true; + + case 'false': + case '(false)': + return false; + + case '(null)': + return null; + + case '(empty)': + return ''; + } + + return $value; + } +} + if ( ! function_exists('elixir')) { /**
true
Other
laravel
framework
e6b368f7413d72b2095e445283df81827fcb47a4.json
Move env() to Foundation helper
src/Illuminate/Support/helpers.php
@@ -491,42 +491,6 @@ function ends_with($haystack, $needles) } } -if ( ! function_exists('env')) -{ - /** - * Gets the value of an environment variable. Supports boolean, empty and null. - * - * @param string $key - * @param mixed $default - * @return mixed - */ - function env($key, $default = null) - { - $value = getenv($key); - - if ($value === false) return value($default); - - switch (strtolower($value)) - { - case 'true': - case '(true)': - return true; - - case 'false': - case '(false)': - return false; - - case '(null)': - return null; - - case '(empty)': - return ''; - } - - return $value; - } -} - if ( ! function_exists('head')) { /**
true