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
01541893d20a5540d1f8e911e780f907103bfb60.json
Use alternative for array_add
src/Illuminate/Container/Container.php
@@ -388,7 +388,7 @@ public function tag($abstracts, $tags) foreach ($tags as $tag) { - array_add($this->tags, $tag, []); + if ( ! isset($this->tags[$tag])) $this->tags[$tag] = []; foreach ((array) $abstracts as $abstract) {
false
Other
laravel
framework
074c00d5d1584e27d407e2e4cae9f504727b709f.json
Standardize return null;
src/Illuminate/Cache/DatabaseStore.php
@@ -73,7 +73,7 @@ public function get($key) { $this->forget($key); - return null; + return; } return $this->encrypter->decrypt($cache->value);
true
Other
laravel
framework
074c00d5d1584e27d407e2e4cae9f504727b709f.json
Standardize return null;
src/Illuminate/Filesystem/FilesystemAdapter.php
@@ -294,7 +294,7 @@ protected function filterContentsByType($contents, $type) */ protected function parseVisibility($visibility) { - if (is_null($visibility)) return null; + if (is_null($visibility)) return; switch ($visibility) {
true
Other
laravel
framework
074c00d5d1584e27d407e2e4cae9f504727b709f.json
Standardize return null;
src/Illuminate/Foundation/Console/RouteListCommand.php
@@ -183,7 +183,7 @@ protected function filterRoute(array $route) if (($this->option('name') && ! str_contains($route['name'], $this->option('name'))) || $this->option('path') && ! str_contains($route['uri'], $this->option('path'))) { - return null; + return; } return $route;
true
Other
laravel
framework
074c00d5d1584e27d407e2e4cae9f504727b709f.json
Standardize return null;
src/Illuminate/Routing/Router.php
@@ -792,7 +792,7 @@ public function model($key, $class, Closure $callback = null) { $this->bind($key, function($value) use ($class, $callback) { - if (is_null($value)) return null; + if (is_null($value)) return; // For model binders, we will attempt to retrieve the models using the first // method on the model instance. If we cannot retrieve the models we'll
true
Other
laravel
framework
074c00d5d1584e27d407e2e4cae9f504727b709f.json
Standardize return null;
src/Illuminate/Support/Collection.php
@@ -431,7 +431,7 @@ public function put($key, $value) */ public function random($amount = 1) { - if ($this->isEmpty()) return null; + if ($this->isEmpty()) return; $keys = array_rand($this->items, $amount);
true
Other
laravel
framework
074c00d5d1584e27d407e2e4cae9f504727b709f.json
Standardize return null;
src/Illuminate/Validation/Validator.php
@@ -1413,7 +1413,7 @@ protected function getDateTimeWithOptionalFormat($format, $value) } catch (\Exception $e) { - return null; + return; } }
true
Other
laravel
framework
074c00d5d1584e27d407e2e4cae9f504727b709f.json
Standardize return null;
tests/Routing/RoutingRouteTest.php
@@ -229,7 +229,7 @@ public function testBasicBeforeFilters() $router = $this->getRouter(); $router->get('foo/bar', array('before' => 'foo:bar,baz|bar:boom', function() { return 'hello'; })); - $router->filter('foo', function($route, $request, $bar, $baz) { return null; }); + $router->filter('foo', function($route, $request, $bar, $baz) { return; }); $router->filter('bar', function($route, $request, $boom) { return $boom; }); $this->assertEquals('boom', $router->dispatch(Request::create('foo/bar', 'GET'))->getContent());
true
Other
laravel
framework
6b167368c96ad146cdeab9c67ede66e5f9759ac8.json
Remove unneeded class.
src/Illuminate/Foundation/Artisan.php
@@ -1,60 +0,0 @@ -<?php namespace Illuminate\Foundation; - -use Illuminate\Console\Application as ConsoleApplication; - -class Artisan { - - /** - * The application instance. - * - * @var \Illuminate\Foundation\Application - */ - protected $app; - - /** - * The Artisan console instance. - * - * @var \Illuminate\Console\Application - */ - protected $artisan; - - /** - * Create a new Artisan command runner instance. - * - * @param \Illuminate\Foundation\Application $app - * @return void - */ - public function __construct(Application $app) - { - $this->app = $app; - } - - /** - * Get the Artisan console instance. - * - * @return \Illuminate\Console\Application - */ - protected function getArtisan() - { - if ( ! is_null($this->artisan)) return $this->artisan; - - $this->app->loadDeferredProviders(); - - $this->artisan = ConsoleApplication::make($this->app); - - return $this->artisan->boot(); - } - - /** - * Dynamically pass all missing methods to console Artisan. - * - * @param string $method - * @param array $parameters - * @return mixed - */ - public function __call($method, $parameters) - { - return call_user_func_array(array($this->getArtisan(), $method), $parameters); - } - -}
false
Other
laravel
framework
6b185832af11badaef1c47547db435a5124e0b88.json
Add lastOutput property.
src/Illuminate/Console/Application.php
@@ -26,6 +26,13 @@ class Application extends SymfonyApplication implements ApplicationContract { */ protected $events; + /** + * The output from the previous command. + * + * @var \Symfony\Component\Console\Output\OutputInterface + */ + protected $lastOutput; + /** * Create a new Artisan console application. *
false
Other
laravel
framework
95d4f703f6a0b2c5e3f9d24412dd0049dae9c20b.json
Tweak some bootstrapping logic.
src/Illuminate/Foundation/Application.php
@@ -28,6 +28,13 @@ class Application extends Container implements ApplicationContract { */ protected $basePath; + /** + * Indicates if the application has been bootstrapped before. + * + * @var bool + */ + protected $hasBeenBootstrapped = false; + /** * Indicates if the application has "booted". * @@ -135,6 +142,18 @@ public function bootstrapWith(array $bootstrappers) { $this->make($bootstrapper)->bootstrap($this); } + + $this->hasBeenBootstrapped = true; + } + + /** + * Determine if the application has been bootstrapped before. + * + * @return bool + */ + public function hasBeenBootstrapped() + { + return $this->hasBeenBootstrapped; } /**
true
Other
laravel
framework
95d4f703f6a0b2c5e3f9d24412dd0049dae9c20b.json
Tweak some bootstrapping logic.
src/Illuminate/Foundation/Console/Kernel.php
@@ -27,21 +27,13 @@ class Kernel implements KernelContract { * @return void */ protected $bootstrappers = [ - 'Illuminate\Foundation\Bootstrap\DetectEnvironment', + 'Illuminate\Foundation\Bootstrap\LoadEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', - 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders', ]; - /** - * The Artisan commands provided by your application. - * - * @var array - */ - protected $commands = []; - /** * Create a new console kernel instance. * @@ -64,11 +56,22 @@ public function __construct(Application $app, Dispatcher $events) */ public function handle($input, $output = null) { - $this->app->bootstrapWith($this->bootstrappers); + $this->bootstrap(); + + return (new Artisan($this->app, $this->events))->run($input, $output); + } - return (new Artisan($this->app, $this->events)) - ->resolveCommands($this->commands) - ->run($input, $output); + /** + * Bootstrap the application for HTTP requests. + * + * @return void + */ + public function bootstrap() + { + if ( ! $this->app->hasBeenBootstrapped()) + { + $this->app->bootstrapWith($this->bootstrappers); + } } }
true
Other
laravel
framework
95d4f703f6a0b2c5e3f9d24412dd0049dae9c20b.json
Tweak some bootstrapping logic.
src/Illuminate/Foundation/Http/Kernel.php
@@ -21,22 +21,14 @@ class Kernel implements KernelContract { */ protected $router; - /** - * Indicates if the bootstrap process has run. - * - * @var bool - */ - protected $bootstrapped = false; - /** * The bootstrap classes for the application. * * @return void */ protected $bootstrappers = [ - 'Illuminate\Foundation\Bootstrap\DetectEnvironment', + 'Illuminate\Foundation\Bootstrap\LoadEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', - 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', @@ -87,12 +79,10 @@ public function handle($request) */ public function bootstrap() { - if ( ! $this->bootstrapped) + if ( ! $this->app->hasBeenBootstrapped()) { $this->app->bootstrapWith($this->bootstrappers); } - - $this->bootstrapped = true; } /**
true
Other
laravel
framework
a83c3f2f471b9ba78e3f9500caf1673cac7f413d.json
Fix model typo in Eloquent/Model.php
src/Illuminate/Database/Eloquent/Model.php
@@ -336,7 +336,7 @@ public static function hasGlobalScope($scope) } /** - * Get a global scope registered with the modal. + * Get a global scope registered with the model. * * @param \Illuminate\Database\Eloquent\ScopeInterface $scope * @return \Illuminate\Database\Eloquent\ScopeInterface|null
false
Other
laravel
framework
c1e751f5f4d9dcd4af879b76bff706cb8d9d9090.json
Fix app:name Command
src/Illuminate/Foundation/Console/AppNameCommand.php
@@ -70,6 +70,8 @@ public function fire() { $this->currentRoot = trim($this->getAppNamespace(), '\\'); + $this->setBootstrapNamespaces(); + $this->setAppDirectoryNamespace(); $this->setConfigNamespaces(); @@ -89,15 +91,13 @@ public function fire() protected function setAppDirectoryNamespace() { $files = Finder::create() - ->in($this->laravel['path']) - ->name('*.php'); + ->in($this->laravel['path']) + ->name('*.php'); foreach ($files as $file) { $this->replaceNamespace($file->getRealPath()); } - - $this->setServiceProviderNamespaceReferences(); } /** @@ -121,55 +121,18 @@ protected function replaceNamespace($path) } /** - * Set the referenced namespaces in various service providers. + * Set the bootstrap namespaces. * * @return void */ - protected function setServiceProviderNamespaceReferences() - { - $this->setReferencedMiddlewareNamespaces(); - - $this->setReferencedConsoleNamespaces(); - - $this->setReferencedRouteNamespaces(); - } - - /** - * Set the namespace on the referenced middleware. - * - * @return void - */ - protected function setReferencedMiddlewareNamespaces() + protected function setBootstrapNamespaces() { $this->replaceIn( - $this->laravel['path'].'/Providers/AppServiceProvider.php', - $this->currentRoot.'\\Http\\Middleware', $this->argument('name').'\\Http\\Middleware' + $this->getBootstrapPath(), $this->currentRoot.'\\Http', $this->argument('name').'\\Http' ); - } - /** - * Set the namespace on the referenced commands in the Artisan service provider. - * - * @return void - */ - protected function setReferencedConsoleNamespaces() - { $this->replaceIn( - $this->laravel['path'].'/Providers/ArtisanServiceProvider.php', - $this->currentRoot.'\\Console', $this->argument('name').'\\Console' - ); - } - - /** - * Set the namespace on the referenced commands in the Routes service provider. - * - * @return void - */ - protected function setReferencedRouteNamespaces() - { - $this->replaceIn( - $this->laravel['path'].'/Providers/RouteServiceProvider.php', - $this->currentRoot.'\\Http', $this->argument('name').'\\Http' + $this->getBootstrapPath(), $this->currentRoot.'\\Console', $this->argument('name').'\\Console' ); } @@ -248,6 +211,16 @@ protected function getUserClassPath() return $this->laravel['path'].'/Core/User.php'; } + /** + * Get the path to the bootstrap/app.php file. + * + * @return string + */ + protected function getBootstrapPath() + { + return $this->laravel['path.base'].'/bootstrap/app.php'; + } + /** * Get the path to the Composer.json file. *
false
Other
laravel
framework
10c405725f153670645d5b5657965698149a8f34.json
Add a comment.
src/Illuminate/Foundation/Bootstrap/ConfigureLogging.php
@@ -14,8 +14,13 @@ class ConfigureLogging { */ public function bootstrap(Application $app) { - $app->instance('log', new Writer(new Monolog($app->environment()), $app['events'])); + $app->instance('log', new Writer( + new Monolog($app->environment()), $app['events']) + ); + // Next we will bind the a Closure to resolve the PSR logger implementation + // as this will grant us the ability to be interoperable with many other + // libraries which are able to utilize the PSR standardized interface. $app->bind('Psr\Log\LoggerInterface', function() { return $app['log']->getMonolog();
false
Other
laravel
framework
b83b9c26a193369361b7c7fef3bcd5220bb49934.json
Add configure logging to bootstrappers.
src/Illuminate/Foundation/Bootstrap/ConfigureLogging.php
@@ -0,0 +1,27 @@ +<?php namespace Illuminate\Foundation\Bootstrap; + +use Illuminate\Log\Writer; +use Monolog\Logger as Monolog; +use Illuminate\Contracts\Foundation\Application; + +class ConfigureLogging { + + /** + * Bootstrap the given application. + * + * @param \Illuminate\Contracts\Foundation\Application $app + * @return void + */ + public function bootstrap(Application $app) + { + $app->instance('log', new Writer(new Monolog( + $app->environment()), $app['Illuminate\Contracts\Events\Dispatcher'] + )); + + $app->bind('Psr\Log\LoggerInterface', function() + { + return $app['log']->getMonolog(); + }); + } + +}
true
Other
laravel
framework
b83b9c26a193369361b7c7fef3bcd5220bb49934.json
Add configure logging to bootstrappers.
src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php
@@ -3,7 +3,7 @@ use Dotenv; use Illuminate\Contracts\Foundation\Application; -class LoadEnvironment { +class DetectEnvironment { /** * Bootstrap the given application.
true
Other
laravel
framework
b83b9c26a193369361b7c7fef3bcd5220bb49934.json
Add configure logging to bootstrappers.
src/Illuminate/Foundation/Console/Kernel.php
@@ -27,8 +27,9 @@ class Kernel implements KernelContract { * @return void */ protected $bootstrappers = [ - 'Illuminate\Foundation\Bootstrap\LoadEnvironment', + 'Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', + 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders',
true
Other
laravel
framework
b83b9c26a193369361b7c7fef3bcd5220bb49934.json
Add configure logging to bootstrappers.
src/Illuminate/Foundation/Http/Kernel.php
@@ -34,8 +34,9 @@ class Kernel implements KernelContract { * @return void */ protected $bootstrappers = [ - 'Illuminate\Foundation\Bootstrap\LoadEnvironment', + 'Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', + 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders',
true
Other
laravel
framework
e8baa62405001f22ae0f7080550882c4d8edb9a2.json
Add tests for single parameter routing
tests/Routing/RoutingUrlGeneratorTest.php
@@ -64,6 +64,12 @@ public function testBasicRouteGeneration() $route = new Illuminate\Routing\Route(array('GET'), 'foo/bar/{baz}/breeze/{boom}', array('as' => 'bar')); $routes->add($route); + /** + * Single Parameter... + */ + $route = new Illuminate\Routing\Route(array('GET'), 'foo/bar/{baz}', array('as' => 'foobar')); + $routes->add($route); + /** * HTTPS... */ @@ -89,6 +95,8 @@ public function testBasicRouteGeneration() $this->assertEquals('/foo/bar?foo=bar', $url->route('foo', array('foo' => 'bar'), false)); $this->assertEquals('http://www.foo.com/foo/bar/taylor/breeze/otwell?fly=wall', $url->route('bar', array('taylor', 'otwell', 'fly' => 'wall'))); $this->assertEquals('http://www.foo.com/foo/bar/otwell/breeze/taylor?fly=wall', $url->route('bar', array('boom' => 'taylor', 'baz' => 'otwell', 'fly' => 'wall'))); + $this->assertEquals('http://www.foo.com/foo/bar/2', $url->route('foobar', 2)); + $this->assertEquals('http://www.foo.com/foo/bar/taylor', $url->route('foobar', 'taylor')); $this->assertEquals('/foo/bar/taylor/breeze/otwell?fly=wall', $url->route('bar', array('taylor', 'otwell', 'fly' => 'wall'), false)); $this->assertEquals('https://www.foo.com/foo/bar', $url->route('baz')); $this->assertEquals('http://www.foo.com/foo/bar', $url->action('foo@bar')); @@ -120,6 +128,7 @@ public function testControllerRoutesWithADefaultNamespace() $this->assertEquals('http://www.foo.com/something/else', $url->action('\something\foo@bar')); } + public function testRoutableInterfaceRouting() { $url = new UrlGenerator( @@ -137,6 +146,23 @@ public function testRoutableInterfaceRouting() } + public function testRoutableInterfaceRoutingWithSingleParameter() + { + $url = new UrlGenerator( + $routes = new Illuminate\Routing\RouteCollection, + $request = Illuminate\Http\Request::create('http://www.foo.com/') + ); + + $route = new Illuminate\Routing\Route(array('GET'), 'foo/{bar}', array('as' => 'routable')); + $routes->add($route); + + $model = new RoutableInterfaceStub; + $model->key = 'routable'; + + $this->assertEquals('/foo/routable', $url->route('routable', $model, false)); + } + + public function testRoutesMaintainRequestScheme() { $url = new UrlGenerator(
false
Other
laravel
framework
19690e94b1b14d6cccf3d5ffb3484ba680464c57.json
Add realpath to app_path() Fix issues when comparing paths for namespace detection on Windows environments.
src/Illuminate/Console/AppNamespaceDetectorTrait.php
@@ -14,7 +14,7 @@ protected function getAppNamespace() foreach ((array) data_get($composer, 'autoload.psr-4') as $namespace => $path) { - if (app_path() == realpath(base_path().'/'.$path)) return $namespace; + if (realpath(app_path()) == realpath(base_path().'/'.$path)) return $namespace; } throw new \RuntimeException("Unable to detect application namespace.");
false
Other
laravel
framework
308c01f927aff04d0958d8167d64e1beb17398cd.json
Use "middleware" term.
src/Illuminate/Foundation/Http/Kernel.php
@@ -46,7 +46,7 @@ class Kernel implements KernelContract { * * @var array */ - protected $stack = []; + protected $middleware = []; /** * Create a new HTTP kernel instance. @@ -74,7 +74,7 @@ public function handle($request) return (new Stack($this->app)) ->send($request) - ->through($this->stack) + ->through($this->middleware) ->then($this->dispatchToRouter()); }
false
Other
laravel
framework
319de5a80a3bddf64489d2935ddd47e70e0274ce.json
Remove type hinting in toRoute `toRoute()` used in `action()` and `route()` which can accept simple value __or__ array. Thus the ```php link_to_route('resource.edit', 'Edit', 1); ``` will throw an exception `Argument 2 passed to Illuminate\Routing\UrlGenerator::toRoute() must be of the type array, integer given`.
src/Illuminate/Routing/UrlGenerator.php
@@ -241,11 +241,11 @@ public function route($name, $parameters = array(), $absolute = true) * Get the URL for a given route instance. * * @param \Illuminate\Routing\Route $route - * @param array $parameters - * @param bool $absolute + * @param mixed $parameters + * @param bool $absolute * @return string */ - protected function toRoute($route, array $parameters, $absolute) + protected function toRoute($route, $parameters, $absolute) { $parameters = $this->formatParameters($parameters);
false
Other
laravel
framework
9a6b77518d16c7a4933cd4f25fe544a2c5325151.json
fix phpdoc block for Eloquent Model find method add null
src/Illuminate/Database/Eloquent/Model.php
@@ -633,7 +633,7 @@ public static function all($columns = array('*')) * * @param mixed $id * @param array $columns - * @return \Illuminate\Support\Collection|static + * @return \Illuminate\Support\Collection|static|null */ public static function find($id, $columns = array('*')) {
false
Other
laravel
framework
4ef2c071dcf7a6cdffdcc9e0a4e6a5d90ebf88d4.json
Fix a Str::snake Function
src/Illuminate/Support/Str.php
@@ -279,15 +279,17 @@ public static function slug($title, $separator = '-') * * @param string $value * @param string $delimiter + * @param bool $each * @return string */ - public static function snake($value, $delimiter = '_') + public static function snake($value, $delimiter = '_', $each = true) { if (ctype_lower($value)) return $value; - $replace = '$1'.$delimiter.'$2'; + $replace = $each ? '$1'.$delimiter : '$1'.$delimiter.'$2'; + $pattern = $each ? '/(.)(?=[A-Z])/' : '/(.)([A-Z]+)/'; - return strtolower(preg_replace('/(.)([A-Z])/', $replace, $value)); + return strtolower(preg_replace($pattern, $replace, $value)); } /**
true
Other
laravel
framework
4ef2c071dcf7a6cdffdcc9e0a4e6a5d90ebf88d4.json
Fix a Str::snake Function
tests/Support/SupportStrTest.php
@@ -149,4 +149,10 @@ public function testRandom() $this->assertInternalType('string', Str::random()); } + public function testSnake() + { + $this->assertEquals('laravel_p_h_p_framework', Str::snake('LaravelPHPFramework')); + $this->assertEquals('laravel-phpframework', Str::snake('LaravelPHPFramework', '-', false)); + } + }
true
Other
laravel
framework
3a01c535cd1cc272a523558bb4b9b7d250b28387.json
Use default request if necessary.
src/Illuminate/Foundation/Application.php
@@ -706,6 +706,8 @@ public function stack(Closure $stack) */ public function run(SymfonyRequest $request = null) { + $request = $request ?: $this['request']; + with($response = $this->handleRequest($request))->send(); $this->terminate($request, $response);
false
Other
laravel
framework
60f1b62e8209350e8ceaa0407e5e2cfc0ea79f5c.json
Remove the extra space.
src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php
@@ -40,7 +40,6 @@ public function boot() { $this->loadRoutes(); } - } /**
false
Other
laravel
framework
ab6bd591304b87720ea39401a090db0b6e71ba55.json
Move view error binding to a service provider.
src/Illuminate/View/Middleware/ErrorBinder.php
@@ -0,0 +1,58 @@ +<?php namespace Illuminate\View\Middleware; + +use Closure; +use Illuminate\Support\ViewErrorBag; +use Illuminate\Contracts\Routing\Middleware; +use Illuminate\Contracts\View\Factory as ViewFactory; + +class ErrorBinder implements Middleware { + + /** + * The view factory implementation. + * + * @var \Illuminate\Contracts\View\Factory + */ + protected $view; + + /** + * Create a new error binder instance. + * + * @param \Illuminate\Contracts\View\Factory $view + * @return void + */ + public function __construct(ViewFactory $view) + { + $this->view = $view; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @return mixed + */ + public function handle($request, Closure $next) + { + // If the current session has an "errors" variable bound to it, we will share + // its value with all view instances so the views can easily access errors + // without having to bind. An empty bag is set when there aren't errors. + if ($request->session()->has('errors')) + { + $this->view->share( + 'errors', $request->session()->get('errors') + ); + } + + // Putting the errors in the view for every view allows the developer to just + // assume that some errors are always available, which is convenient since + // they don't have to continually run checks for the presence of errors. + else + { + $this->view->share('errors', new ViewErrorBag); + } + + return $next($request); + } + +}
true
Other
laravel
framework
ab6bd591304b87720ea39401a090db0b6e71ba55.json
Move view error binding to a service provider.
src/Illuminate/View/ViewServiceProvider.php
@@ -20,12 +20,7 @@ public function register() $this->registerViewFinder(); - // Once the other components have been registered we're ready to include the - // view environment and session binder. The session binder will bind onto - // the "before" application event and add errors into shared view data. $this->registerFactory(); - - $this->registerSessionBinder(); } /** @@ -132,51 +127,4 @@ public function registerFactory() }); } - /** - * Register the session binder for the view environment. - * - * @return void - */ - protected function registerSessionBinder() - { - list($app, $me) = array($this->app, $this); - - $app->booted(function() use ($app, $me) - { - // If the current session has an "errors" variable bound to it, we will share - // its value with all view instances so the views can easily access errors - // without having to bind. An empty bag is set when there aren't errors. - if ($me->sessionHasErrors($app)) - { - $errors = $app['session.store']->get('errors'); - - $app['view']->share('errors', $errors); - } - - // Putting the errors in the view for every view allows the developer to just - // assume that some errors are always available, which is convenient since - // they don't have to continually run checks for the presence of errors. - else - { - $app['view']->share('errors', new ViewErrorBag); - } - }); - } - - /** - * Determine if the application session has errors. - * - * @param \Illuminate\Foundation\Application $app - * @return bool - */ - public function sessionHasErrors($app) - { - $config = $app['config']['session']; - - if (isset($app['session.store']) && ! is_null($config['driver'])) - { - return $app['session.store']->has('errors'); - } - } - }
true
Other
laravel
framework
60b184ef67ab878df450ba2c7f417b1b95075e6a.json
Remove container property.
src/Illuminate/Routing/Controller.php
@@ -27,13 +27,6 @@ abstract class Controller { */ protected $afterFilters = array(); - /** - * The container instance. - * - * @var \Illuminate\Container\Container - */ - protected $container; - /** * The router instance. *
false
Other
laravel
framework
789a9b3667d4b6a70d2c4892cc2c675e6129a40b.json
Set the router on the controller.
src/Illuminate/Routing/ControllerServiceProvider.php
@@ -13,6 +13,8 @@ public function register() { $this->app->singleton('illuminate.route.dispatcher', function($app) { + Controller::setRouter($app['router']); + return new ControllerDispatcher($app['router'], $app); }); }
false
Other
laravel
framework
fe244ae1d623e53dcffa88202d3a425a2979f5f5.json
Use annotations for auth controller.
src/Illuminate/Auth/Console/stubs/controller.stub
@@ -1,12 +1,15 @@ <?php namespace {{namespace}}; -use Illuminate\Routing\Controller; use Illuminate\Contracts\Auth\Authenticator; use {{request.namespace}}Auth\LoginRequest; use {{request.namespace}}Auth\RegisterRequest; -class AuthController extends Controller { +/** + * @Middleware("csrf") + * @Middleware("guest", except={"logout"}) + */ +class AuthController { /** * The authenticator implementation. @@ -24,28 +27,29 @@ class AuthController extends Controller { public function __construct(Authenticator $auth) { $this->auth = $auth; - - $this->beforeFilter('csrf', ['on' => ['post']]); - $this->beforeFilter('guest', ['except' => ['getLogout']]); } /** * Show the application registration form. * + * @Get("auth/register") + * * @return Response */ - public function getRegister() + public function showRegistrationForm() { return view('auth.register'); } /** * Handle a registration request for the application. * + * @Post("auth/register") + * * @param RegisterRequest $request * @return Response */ - public function postRegister(RegisterRequest $request) + public function handleRegistration(RegisterRequest $request) { // Registration form is valid, create user... @@ -57,20 +61,24 @@ class AuthController extends Controller { /** * Show the application login form. * + * @Get("auth/login") + * * @return Response */ - public function getLogin() + public function showLoginForm() { return view('auth.login'); } /** * Handle a login request to the application. * + * @Post("auth/login") + * * @param LoginRequest $request * @return Response */ - public function postLogin(LoginRequest $request) + public function handleLogin(LoginRequest $request) { if ($this->auth->attempt($request->only('email', 'password'))) { @@ -85,9 +93,11 @@ class AuthController extends Controller { /** * Log the user out of the application. * + * @Get("auth/logout") + * * @return Response */ - public function getLogout() + public function logout() { $this->auth->logout();
false
Other
laravel
framework
4492b52ca5b8d2e5220b82de0630a147e9ad1357.json
Convert frame guard to middleware.
src/Illuminate/Http/FrameGuard.php
@@ -1,41 +1,20 @@ -<?php namespace Illuminate\Http; +<?php namespace Illuminate\Http\Middleware; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request as SymfonyRequest; +use Closure; +use Illuminate\Contracts\Routing\Middleware; -class FrameGuard implements HttpKernelInterface { - - /** - * The wrapped kernel implementation. - * - * @var \Symfony\Component\HttpKernel\HttpKernelInterface - */ - protected $app; - - /** - * Create a new FrameGuard instance. - * - * @param \Symfony\Component\HttpKernel\HttpKernelInterface $app - * @return void - */ - public function __construct(HttpKernelInterface $app) - { - $this->app = $app; - } +class FrameGuard implements Middleware { /** * Handle the given request and get the response. * - * @implements HttpKernelInterface::handle - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param int $type - * @param bool $catch - * @return \Symfony\Component\HttpFoundation\Response + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @return \Illuminate\Http\Response */ - public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + public function handle($request, Closure $next) { - $response = $this->app->handle($request, $type, $catch); + $response = $next($request); $response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
false
Other
laravel
framework
cf1d3f289b345b9e8da636887cf5f19219dd86f9.json
Remove all references to EnvironmentVariables. Signed-off-by: crynobone <crynobone@gmail.com>
src/Illuminate/Foundation/Application.php
@@ -13,7 +13,6 @@ use Illuminate\Routing\RoutingServiceProvider; use Illuminate\Contracts\Support\ResponsePreparer; use Illuminate\Exception\ExceptionServiceProvider; -use Illuminate\Config\FileEnvironmentVariablesLoader; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\TerminableInterface; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -911,16 +910,6 @@ public function getConfigLoader() return new FileLoader(new Filesystem, $this['path.config']); } - /** - * Get the environment variables loader instance. - * - * @return \Illuminate\Config\EnvironmentVariablesLoaderInterface - */ - public function getEnvironmentVariablesLoader() - { - return new FileEnvironmentVariablesLoader(new Filesystem, $this['path.base']); - } - /** * Get the service provider repository instance. *
true
Other
laravel
framework
cf1d3f289b345b9e8da636887cf5f19219dd86f9.json
Remove all references to EnvironmentVariables. Signed-off-by: crynobone <crynobone@gmail.com>
src/Illuminate/Foundation/Console/Optimize/config.php
@@ -69,9 +69,6 @@ $basePath.'/vendor/laravel/framework/src/Illuminate/Support/NamespacedItemResolver.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Config/FileLoader.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Config/LoaderInterface.php', - $basePath.'/vendor/laravel/framework/src/Illuminate/Config/EnvironmentVariablesLoaderInterface.php', - $basePath.'/vendor/laravel/framework/src/Illuminate/Config/FileEnvironmentVariablesLoader.php', - $basePath.'/vendor/laravel/framework/src/Illuminate/Config/EnvironmentVariables.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php',
true
Other
laravel
framework
bc185edd184b220ee115c9b1f8c1d2dc20ae1e2f.json
Respect $catch argument in handle()
src/Illuminate/Foundation/Application.php
@@ -746,7 +746,7 @@ public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MAS } catch (\Exception $e) { - if ($this->runningUnitTests()) throw $e; + if (!$catch || $this->runningUnitTests()) throw $e; return $this['exception']->handleException($e); }
true
Other
laravel
framework
bc185edd184b220ee115c9b1f8c1d2dc20ae1e2f.json
Respect $catch argument in handle()
tests/Foundation/FoundationApplicationTest.php
@@ -123,6 +123,20 @@ public function testSingleProviderCanProvideMultipleDeferredServices() $this->assertEquals('foobar', $app->make('bar')); } + public function testHandleRespectsCatchArgument() + { + $this->setExpectedException('Exception'); + $app = new Application; + $app['router'] = $router = m::mock('StdClass'); + $router->shouldReceive('dispatch')->andThrow('Exception'); + $app['env'] = 'temporarilynottesting'; + $app->handle( + new Symfony\Component\HttpFoundation\Request(), + Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, + false + ); + } + } class ApplicationCustomExceptionHandlerStub extends Illuminate\Foundation\Application {
true
Other
laravel
framework
ee347278e625b3d07cacc70ffa1747ee53542af3.json
Check url as 'A' type record in DNS instead 'MX' Example, ``` checkdnsrr('www.laravel.com'); // false but checkdnsrr('www.laravel.com', 'A'); //true ```
src/Illuminate/Validation/Validator.php
@@ -1165,7 +1165,7 @@ protected function validateActiveUrl($attribute, $value) { $url = str_replace(array('http://', 'https://', 'ftp://'), '', strtolower($value)); - return checkdnsrr($url); + return checkdnsrr($url, 'A'); } /**
false
Other
laravel
framework
cd46f5fcf99d448d96a9066aff39cb69e20c0c62.json
Make route:list work with middleware
src/Illuminate/Foundation/Console/RouteListCommand.php
@@ -42,7 +42,7 @@ class RouteListCommand extends Command { * @var array */ protected $headers = array( - 'Domain', 'URI', 'Name', 'Action', 'Before Filters', 'After Filters' + 'Domain', 'URI', 'Name', 'Action', 'Middleware' ); /** @@ -107,8 +107,7 @@ protected function getRouteInformation(Route $route) 'uri' => $uri, 'name' => $route->getName(), 'action' => $route->getActionName(), - 'before' => $this->getBeforeFilters($route), - 'after' => $this->getAfterFilters($route) + 'middleware' => $this->getMiddleware($route) )); } @@ -129,13 +128,13 @@ protected function displayRoutes(array $routes) * @param \Illuminate\Routing\Route $route * @return string */ - protected function getBeforeFilters($route) + protected function getMiddleware($route) { - $before = array_keys($route->beforeFilters()); + $middleware = array_values($route->middleware()); - $before = array_unique(array_merge($before, $this->getPatternFilters($route))); + $middleware = array_unique(array_merge($middleware, $this->getPatternFilters($route))); - return implode(', ', $before); + return implode(', ', $middleware); } /** @@ -173,17 +172,6 @@ protected function getMethodPatterns($uri, $method) return $this->router->findPatternFilters(Request::create($uri, $method)); } - /** - * Get after filters - * - * @param \Illuminate\Routing\Route $route - * @return string - */ - protected function getAfterFilters($route) - { - return implode(', ', array_keys($route->afterFilters())); - } - /** * Filter the route by URI and / or name. *
false
Other
laravel
framework
833a0e2dd9b85ba1d6cb7a925fcc353f319af2f4.json
Use short array here.
src/Illuminate/Routing/Router.php
@@ -561,7 +561,7 @@ public function dispatchToRoute(Request $request, $runMiddleware = true) return $route; }); - $this->events->fire('router.matched', array($route, $request)); + $this->events->fire('router.matched', [$route, $request]); // Once we have successfully matched the incoming request to a given route we // can call the before filters on that route. This works similar to global
false
Other
laravel
framework
80a06259ff82f2818c6c764d752b817a74eae9d3.json
Assign the route to the request after routing.
src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php
@@ -61,6 +61,8 @@ protected function initializeRequest(FormRequest $form, Request $current) ); $form->setUserResolver($current->getUserResolver()); + + $form->setRouteResolver($current->getRouteResolver()); } }
true
Other
laravel
framework
80a06259ff82f2818c6c764d752b817a74eae9d3.json
Assign the route to the request after routing.
src/Illuminate/Http/Request.php
@@ -21,6 +21,20 @@ class Request extends SymfonyRequest { */ protected $sessionStore; + /** + * The user resolver callback. + * + * @var \Closure + */ + protected $userResolver; + + /** + * The route resolver callback. + * + * @var \Closure + */ + protected $routeResolver; + /** * Return the Request instance. * @@ -608,6 +622,16 @@ public function user() return call_user_func($this->getUserResolver()); } + /** + * Get the route handling the request. + * + * @return Illuminate\Routing\Route|null + */ + public function route() + { + return call_user_func($this->getRouteResolver()); + } + /** * Get the user resolver callback. * @@ -631,4 +655,27 @@ public function setUserResolver(Closure $callback) return $this; } + /** + * Get the route resolver callback. + * + * @return \Closure + */ + public function getRouteResolver() + { + return $this->routeResolver ?: function() {}; + } + + /** + * Set the route resolver callback. + * + * @param \Closure $callback + * @return $this + */ + public function setRouteResolver(Closure $callback) + { + $this->routeResolver = $callback; + + return $this; + } + }
true
Other
laravel
framework
80a06259ff82f2818c6c764d752b817a74eae9d3.json
Assign the route to the request after routing.
src/Illuminate/Routing/Router.php
@@ -551,8 +551,16 @@ public function dispatchWithoutMiddleware(Request $request) */ public function dispatchToRoute(Request $request, $runMiddleware = true) { + // First we will find a route that matches this request. We will also set the + // route resolver on the request so middlewares assigned to the route will + // receive access to this route instance for checking of the parameters. $route = $this->findRoute($request); + $request->setRouteResolver(function() use ($route) + { + return $route; + }); + $this->events->fire('router.matched', array($route, $request)); // Once we have successfully matched the incoming request to a given route we
true
Other
laravel
framework
6892e6bf4620e3bda723869602f0e5b7bc4873e6.json
Remove unused ReflectionMethod in Scanners
src/Illuminate/Events/Annotations/Scanner.php
@@ -2,7 +2,6 @@ use SplFileInfo; use ReflectionClass; -use ReflectionMethod; use Symfony\Component\Finder\Finder; use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\SimpleAnnotationReader;
true
Other
laravel
framework
6892e6bf4620e3bda723869602f0e5b7bc4873e6.json
Remove unused ReflectionMethod in Scanners
src/Illuminate/Routing/Annotations/Scanner.php
@@ -2,7 +2,6 @@ use SplFileInfo; use ReflectionClass; -use ReflectionMethod; use Symfony\Component\Finder\Finder; use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\SimpleAnnotationReader;
true
Other
laravel
framework
4a0b0569c860fd364e860471d730c1021fe4b517.json
Use braces around one-liner.
src/Illuminate/Events/Annotations/Scanner.php
@@ -36,7 +36,9 @@ public function __construct($scan, $rootNamespace) $this->rootNamespace = rtrim($rootNamespace, '\\').'\\'; foreach (Finder::create()->files()->in(__DIR__.'/Annotations') as $file) + { AnnotationRegistry::registerFile($file->getRealPath()); + } } /**
false
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/Capsule/Manager.php
@@ -2,7 +2,6 @@ use PDO; use Illuminate\Support\Fluent; -use Illuminate\Cache\CacheManager; use Illuminate\Container\Container; use Illuminate\Database\DatabaseManager; use Illuminate\Contracts\Events\Dispatcher; @@ -189,30 +188,6 @@ public function setEventDispatcher(Dispatcher $dispatcher) $this->container->instance('events', $dispatcher); } - /** - * Get the current cache manager instance. - * - * @return \Illuminate\Cache\CacheManager - */ - public function getCacheManager() - { - if ($this->container->bound('cache')) - { - return $this->container['cache']; - } - } - - /** - * Set the cache manager to be used by connections. - * - * @param \Illuminate\Cache\CacheManager $cache - * @return void - */ - public function setCacheManager(CacheManager $cache) - { - $this->container->instance('cache', $cache); - } - /** * Dynamically pass methods to the default connection. *
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/Connection.php
@@ -58,20 +58,6 @@ class Connection implements ConnectionInterface { */ protected $events; - /** - * The paginator environment instance. - * - * @var \Illuminate\Pagination\Paginator - */ - protected $paginator; - - /** - * The cache manager instance. - * - * @var \Illuminate\Cache\CacheManager - */ - protected $cache; - /** * The default fetch mode of the connection. * @@ -977,58 +963,6 @@ public function setEventDispatcher(Dispatcher $events) $this->events = $events; } - /** - * Get the paginator environment instance. - * - * @return \Illuminate\Pagination\Factory - */ - public function getPaginator() - { - if ($this->paginator instanceof Closure) - { - $this->paginator = call_user_func($this->paginator); - } - - return $this->paginator; - } - - /** - * Set the pagination environment instance. - * - * @param \Illuminate\Pagination\Factory|\Closure $paginator - * @return void - */ - public function setPaginator($paginator) - { - $this->paginator = $paginator; - } - - /** - * Get the cache manager instance. - * - * @return \Illuminate\Cache\CacheManager - */ - public function getCacheManager() - { - if ($this->cache instanceof Closure) - { - $this->cache = call_user_func($this->cache); - } - - return $this->cache; - } - - /** - * Set the cache manager instance on the connection. - * - * @param \Illuminate\Cache\CacheManager|\Closure $cache - * @return void - */ - public function setCacheManager($cache) - { - $this->cache = $cache; - } - /** * Determine if the connection in a "dry run". *
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/DatabaseManager.php
@@ -191,23 +191,8 @@ protected function prepare(Connection $connection) $connection->setEventDispatcher($this->app['events']); } - // The database connection can also utilize a cache manager instance when cache - // functionality is used on queries, which provides an expressive interface - // to caching both fluent queries and Eloquent queries that are executed. $app = $this->app; - $connection->setCacheManager(function() use ($app) - { - return $app['cache']; - }); - - // We will setup a Closure to resolve the paginator instance on the connection - // since the Paginator isn't used on every request and needs quite a few of - // our dependencies. It'll be more efficient to lazily resolve instances. - $connection->setPaginator(function() use ($app) - { - return $app['paginator']; - }); // Here we'll set a reconnector callback. This reconnector can be any callable // so we will set a Closure to reconnect from this manager with the name of
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/Eloquent/Builder.php
@@ -225,86 +225,6 @@ public function lists($column, $key = null) return $results; } - /** - * Get a paginator for the "select" statement. - * - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - public function paginate($perPage = null, $columns = array('*')) - { - $perPage = $perPage ?: $this->model->getPerPage(); - - $paginator = $this->query->getConnection()->getPaginator(); - - if (isset($this->query->groups)) - { - return $this->groupedPaginate($paginator, $perPage, $columns); - } - - return $this->ungroupedPaginate($paginator, $perPage, $columns); - } - - /** - * Get a paginator for a grouped statement. - * - * @param \Illuminate\Pagination\Factory $paginator - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - protected function groupedPaginate($paginator, $perPage, $columns) - { - $results = $this->get($columns)->all(); - - return $this->query->buildRawPaginator($paginator, $results, $perPage); - } - - /** - * Get a paginator for an ungrouped statement. - * - * @param \Illuminate\Pagination\Factory $paginator - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - protected function ungroupedPaginate($paginator, $perPage, $columns) - { - $total = $this->query->getPaginationCount(); - - // Once we have the paginator we need to set the limit and offset values for - // the query so we can get the properly paginated items. Once we have an - // array of items we can create the paginator instances for the items. - $page = $paginator->getCurrentPage($total); - - $this->query->forPage($page, $perPage); - - return $paginator->make($this->get($columns)->all(), $total, $perPage); - } - - /** - * Get a paginator only supporting simple next and previous links. - * - * This is more efficient on larger data-sets, etc. - * - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - public function simplePaginate($perPage = null, $columns = array('*')) - { - $paginator = $this->query->getConnection()->getPaginator(); - - $page = $paginator->getCurrentPage(); - - $perPage = $perPage ?: $this->model->getPerPage(); - - $this->query->skip(($page - 1) * $perPage)->take($perPage + 1); - - return $paginator->make($this->get($columns)->all(), $perPage); - } - /** * Update a record in the database. *
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/Eloquent/Model.php
@@ -47,13 +47,6 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab */ protected $primaryKey = 'id'; - /** - * The number of models to return for pagination. - * - * @var int - */ - protected $perPage = 15; - /** * Indicates if the IDs are auto-incrementing. * @@ -2017,27 +2010,6 @@ public function getMorphClass() return $this->morphClass ?: get_class($this); } - /** - * Get the number of models to return per page. - * - * @return int - */ - public function getPerPage() - { - return $this->perPage; - } - - /** - * Set the number of models to return per page. - * - * @param int $perPage - * @return void - */ - public function setPerPage($perPage) - { - $this->perPage = $perPage; - } - /** * Get the default foreign key name for the model. *
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
@@ -159,27 +159,6 @@ public function get($columns = array('*')) return $this->related->newCollection($models); } - /** - * Get a paginator for the "select" statement. - * - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - public function paginate($perPage = null, $columns = array('*')) - { - $this->query->addSelect($this->getSelectColumns($columns)); - - // When paginating results, we need to add the pivot columns to the query and - // then hydrate into the pivot objects once the results have been gathered - // from the database since this isn't performed by the Eloquent builder. - $pager = $this->query->paginate($perPage, $columns); - - $this->hydratePivotRelation($pager->getItems()); - - return $pager; - } - /** * Hydrate the pivot table relationship on the models. *
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php
@@ -233,22 +233,6 @@ protected function getSelectColumns(array $columns = array('*')) return array_merge($columns, array($this->parent->getTable().'.'.$this->firstKey)); } - /** - * Get a paginator for the "select" statement. - * - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - public function paginate($perPage = null, $columns = array('*')) - { - $this->query->addSelect($this->getSelectColumns($columns)); - - $pager = $this->query->paginate($perPage, $columns); - - return $pager; - } - /** * Get the key name of the parent model. *
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/Query/Builder.php
@@ -133,41 +133,6 @@ class Builder { */ public $lock; - /** - * The backups of fields while doing a pagination count. - * - * @var array - */ - protected $backups = array(); - - /** - * The key that should be used when caching the query. - * - * @var string - */ - protected $cacheKey; - - /** - * The number of minutes to cache the query. - * - * @var int - */ - protected $cacheMinutes; - - /** - * The tags for the query cache. - * - * @var array - */ - protected $cacheTags; - - /** - * The cache driver to be used. - * - * @var string - */ - protected $cacheDriver; - /** * All of the available clause operators. * @@ -1276,57 +1241,6 @@ public function toSql() return $this->grammar->compileSelect($this); } - /** - * Indicate that the query results should be cached. - * - * @param \DateTime|int $minutes - * @param string $key - * @return $this - */ - public function remember($minutes, $key = null) - { - list($this->cacheMinutes, $this->cacheKey) = array($minutes, $key); - - return $this; - } - - /** - * Indicate that the query results should be cached forever. - * - * @param string $key - * @return \Illuminate\Database\Query\Builder|static - */ - public function rememberForever($key = null) - { - return $this->remember(-1, $key); - } - - /** - * Indicate that the results, if cached, should use the given cache tags. - * - * @param array|mixed $cacheTags - * @return $this - */ - public function cacheTags($cacheTags) - { - $this->cacheTags = $cacheTags; - - return $this; - } - - /** - * Indicate that the results, if cached, should use the given cache driver. - * - * @param string $cacheDriver - * @return $this - */ - public function cacheDriver($cacheDriver) - { - $this->cacheDriver = $cacheDriver; - - return $this; - } - /** * Execute a query for a single record by ID. * @@ -1373,8 +1287,6 @@ public function first($columns = array('*')) */ public function get($columns = array('*')) { - if ( ! is_null($this->cacheMinutes)) return $this->getCached($columns); - return $this->getFresh($columns); } @@ -1401,91 +1313,6 @@ protected function runSelect() return $this->connection->select($this->toSql(), $this->getBindings()); } - /** - * Execute the query as a cached "select" statement. - * - * @param array $columns - * @return array - */ - public function getCached($columns = array('*')) - { - if (is_null($this->columns)) $this->columns = $columns; - - // If the query is requested to be cached, we will cache it using a unique key - // for this database connection and query statement, including the bindings - // that are used on this query, providing great convenience when caching. - list($key, $minutes) = $this->getCacheInfo(); - - $cache = $this->getCache(); - - $callback = $this->getCacheCallback($columns); - - // If the "minutes" value is less than zero, we will use that as the indicator - // that the value should be remembered values should be stored indefinitely - // and if we have minutes we will use the typical remember function here. - if ($minutes < 0) - { - return $cache->rememberForever($key, $callback); - } - - return $cache->remember($key, $minutes, $callback); - } - - /** - * Get the cache object with tags assigned, if applicable. - * - * @return \Illuminate\Cache\CacheManager - */ - protected function getCache() - { - $cache = $this->connection->getCacheManager()->driver($this->cacheDriver); - - return $this->cacheTags ? $cache->tags($this->cacheTags) : $cache; - } - - /** - * Get the cache key and cache minutes as an array. - * - * @return array - */ - protected function getCacheInfo() - { - return array($this->getCacheKey(), $this->cacheMinutes); - } - - /** - * Get a unique cache key for the complete query. - * - * @return string - */ - public function getCacheKey() - { - return $this->cacheKey ?: $this->generateCacheKey(); - } - - /** - * Generate the unique cache key for the query. - * - * @return string - */ - public function generateCacheKey() - { - $name = $this->connection->getName(); - - return md5($name.$this->toSql().serialize($this->getBindings())); - } - - /** - * Get the Closure callback used when caching queries. - * - * @param array $columns - * @return \Closure - */ - protected function getCacheCallback($columns) - { - return function() use ($columns) { return $this->getFresh($columns); }; - } - /** * Chunk the results of the query. * @@ -1580,154 +1407,6 @@ public function implode($column, $glue = null) return implode($glue, $this->lists($column)); } - /** - * Get a paginator for the "select" statement. - * - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - public function paginate($perPage = 15, $columns = array('*')) - { - $paginator = $this->connection->getPaginator(); - - if (isset($this->groups)) - { - return $this->groupedPaginate($paginator, $perPage, $columns); - } - - return $this->ungroupedPaginate($paginator, $perPage, $columns); - } - - /** - * Create a paginator for a grouped pagination statement. - * - * @param \Illuminate\Pagination\Factory $paginator - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - protected function groupedPaginate($paginator, $perPage, $columns) - { - $results = $this->get($columns); - - return $this->buildRawPaginator($paginator, $results, $perPage); - } - - /** - * Build a paginator instance from a raw result array. - * - * @param \Illuminate\Pagination\Factory $paginator - * @param array $results - * @param int $perPage - * @return \Illuminate\Pagination\Paginator - */ - public function buildRawPaginator($paginator, $results, $perPage) - { - // For queries which have a group by, we will actually retrieve the entire set - // of rows from the table and "slice" them via PHP. This is inefficient and - // the developer must be aware of this behavior; however, it's an option. - $start = ($paginator->getCurrentPage() - 1) * $perPage; - - $sliced = array_slice($results, $start, $perPage); - - return $paginator->make($sliced, count($results), $perPage); - } - - /** - * Create a paginator for an un-grouped pagination statement. - * - * @param \Illuminate\Pagination\Factory $paginator - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - protected function ungroupedPaginate($paginator, $perPage, $columns) - { - $total = $this->getPaginationCount(); - - // Once we have the total number of records to be paginated, we can grab the - // current page and the result array. Then we are ready to create a brand - // new Paginator instances for the results which will create the links. - $page = $paginator->getCurrentPage($total); - - $results = $this->forPage($page, $perPage)->get($columns); - - return $paginator->make($results, $total, $perPage); - } - - /** - * Get the count of the total records for pagination. - * - * @return int - */ - public function getPaginationCount() - { - $this->backupFieldsForCount(); - - // Because some database engines may throw errors if we leave the ordering - // statements on the query, we will "back them up" and remove them from - // the query. Once we have the count we will put them back onto this. - $total = $this->count(); - - $this->restoreFieldsForCount(); - - return $total; - } - - /** - * Get a paginator only supporting simple next and previous links. - * - * This is more efficient on larger data-sets, etc. - * - * @param int $perPage - * @param array $columns - * @return \Illuminate\Pagination\Paginator - */ - public function simplePaginate($perPage = null, $columns = array('*')) - { - $paginator = $this->connection->getPaginator(); - - $page = $paginator->getCurrentPage(); - - $perPage = $perPage ?: $this->model->getPerPage(); - - $this->skip(($page - 1) * $perPage)->take($perPage + 1); - - return $paginator->make($this->get($columns), $perPage); - } - - /** - * Backup certain fields for a pagination count. - * - * @return void - */ - protected function backupFieldsForCount() - { - foreach (array('orders', 'limit', 'offset') as $field) - { - $this->backups[$field] = $this->{$field}; - - $this->{$field} = null; - } - - } - - /** - * Restore certain fields for a pagination count. - * - * @return void - */ - protected function restoreFieldsForCount() - { - foreach (array('orders', 'limit', 'offset') as $field) - { - $this->{$field} = $this->backups[$field]; - } - - $this->backups = array(); - } - /** * Determine if any rows exist for the current query. *
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/README.md
@@ -27,9 +27,6 @@ use Illuminate\Events\Dispatcher; use Illuminate\Container\Container; $capsule->setEventDispatcher(new Dispatcher(new Container)); -// Set the cache manager instance used by connections... (optional) -$capsule->setCacheManager(...); - // Make this Capsule instance available globally via static methods... (optional) $capsule->setAsGlobal();
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Database/composer.json
@@ -18,8 +18,6 @@ "require-dev": { "illuminate/console": "5.0.*", "illuminate/filesystem": "5.0.*", - "illuminate/pagination": "5.0.*", - "illuminate/support": "5.0.*" }, "autoload": { "psr-4": {
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
src/Illuminate/Pagination/composer.json
@@ -9,10 +9,8 @@ ], "require": { "php": ">=5.4.0", - "illuminate/http": "5.0.*", + "illuminate/contracts": "5.0.*", "illuminate/support": "5.0.*", - "symfony/http-foundation": "2.6.*", - "symfony/translation": "2.6.*" }, "autoload": { "psr-4": {
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
tests/Database/DatabaseConnectionTest.php
@@ -239,29 +239,6 @@ public function testSchemaBuilderCanBeCreated() } - public function testResolvingPaginatorThroughClosure() - { - $connection = $this->getMockConnection(); - $paginator = m::mock('Illuminate\Pagination\Factory'); - $connection->setPaginator(function() use ($paginator) - { - return $paginator; - }); - $this->assertEquals($paginator, $connection->getPaginator()); - } - - - public function testResolvingCacheThroughClosure() - { - $connection = $this->getMockConnection(); - $cache = m::mock('Illuminate\Cache\CacheManager'); - $connection->setCacheManager(function() use ($cache) - { - return $cache; - }); - $this->assertEquals($cache, $connection->getCacheManager()); - } - protected function getMockConnection($methods = array(), $pdo = null) {
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
tests/Database/DatabaseEloquentBuilderTest.php
@@ -216,73 +216,6 @@ public function testMacrosAreCalledOnBuilder() } - public function testPaginateMethod() - { - $builder = m::mock('Illuminate\Database\Eloquent\Builder[get]', array($this->getMockQueryBuilder())); - $builder->setModel($this->getMockModel()); - $builder->getModel()->shouldReceive('getPerPage')->once()->andReturn(15); - $builder->getQuery()->shouldReceive('getPaginationCount')->once()->andReturn(10); - $conn = m::mock('stdClass'); - $paginator = m::mock('stdClass'); - $paginator->shouldReceive('getCurrentPage')->once()->andReturn(1); - $conn->shouldReceive('getPaginator')->once()->andReturn($paginator); - $builder->getQuery()->shouldReceive('getConnection')->once()->andReturn($conn); - $builder->getQuery()->shouldReceive('forPage')->once()->with(1, 15); - $builder->shouldReceive('get')->with(array('*'))->andReturn(new Collection(array('results'))); - $paginator->shouldReceive('make')->once()->with(array('results'), 10, 15)->andReturn(array('results')); - - $this->assertEquals(array('results'), $builder->paginate()); - } - - - public function testPaginateMethodWithGroupedQuery() - { - $query = $this->getMock('Illuminate\Database\Query\Builder', array('from', 'getConnection'), array( - m::mock('Illuminate\Database\ConnectionInterface'), - m::mock('Illuminate\Database\Query\Grammars\Grammar'), - m::mock('Illuminate\Database\Query\Processors\Processor'), - )); - $query->expects($this->once())->method('from')->will($this->returnValue('foo_table')); - $builder = $this->getMock('Illuminate\Database\Eloquent\Builder', array('get'), array($query)); - $builder->setModel($this->getMockModel()); - $builder->getModel()->shouldReceive('getPerPage')->once()->andReturn(2); - $conn = m::mock('stdClass'); - $paginator = m::mock('stdClass'); - $paginator->shouldReceive('getCurrentPage')->once()->andReturn(2); - $conn->shouldReceive('getPaginator')->once()->andReturn($paginator); - $query->expects($this->once())->method('getConnection')->will($this->returnValue($conn)); - $builder->expects($this->once())->method('get')->with($this->equalTo(array('*')))->will($this->returnValue(new Collection(array('foo', 'bar', 'baz')))); - $paginator->shouldReceive('make')->once()->with(array('baz'), 3, 2)->andReturn(array('results')); - - $this->assertEquals(array('results'), $builder->groupBy('foo')->paginate()); - } - - - public function testQuickPaginateMethod() - { - $query = $this->getMock('Illuminate\Database\Query\Builder', array('from', 'getConnection', 'skip', 'take'), array( - m::mock('Illuminate\Database\ConnectionInterface'), - m::mock('Illuminate\Database\Query\Grammars\Grammar'), - m::mock('Illuminate\Database\Query\Processors\Processor'), - )); - $query->expects($this->once())->method('from')->will($this->returnValue('foo_table')); - $builder = $this->getMock('Illuminate\Database\Eloquent\Builder', array('get'), array($query)); - $builder->setModel($this->getMockModel()); - $builder->getModel()->shouldReceive('getPerPage')->once()->andReturn(15); - $conn = m::mock('stdClass'); - $paginator = m::mock('stdClass'); - $paginator->shouldReceive('getCurrentPage')->once()->andReturn(1); - $conn->shouldReceive('getPaginator')->once()->andReturn($paginator); - $query->expects($this->once())->method('getConnection')->will($this->returnValue($conn)); - $query->expects($this->once())->method('skip')->with(0)->will($this->returnValue($query)); - $query->expects($this->once())->method('take')->with(16)->will($this->returnValue($query)); - $builder->expects($this->once())->method('get')->with($this->equalTo(array('*')))->will($this->returnValue(new Collection(array('results')))); - $paginator->shouldReceive('make')->once()->with(array('results'), 15)->andReturn(array('results')); - - $this->assertEquals(array('results'), $builder->simplePaginate()); - } - - public function testGetModelsProperlyHydratesModels() { $builder = m::mock('Illuminate\Database\Eloquent\Builder[get]', array($this->getMockQueryBuilder()));
true
Other
laravel
framework
ea6b9589514b0139508b35166b63e9fbc045c285.json
Remove caching and pagination from database.
tests/Database/DatabaseQueryBuilderTest.php
@@ -59,65 +59,6 @@ public function testBasicSelectDistinct() } - public function testSelectWithCaching() - { - $cache = m::mock('stdClass'); - $driver = m::mock('stdClass'); - $query = $this->setupCacheTestQuery($cache, $driver); - - $query = $query->remember(5); - - $driver->shouldReceive('remember') - ->once() - ->with($query->getCacheKey(), 5, m::type('Closure')) - ->andReturnUsing(function($key, $minutes, $callback) { return $callback(); }); - - - $this->assertEquals($query->get(), array('results')); - } - - - public function testSelectWithCachingForever() - { - $cache = m::mock('stdClass'); - $driver = m::mock('stdClass'); - $query = $this->setupCacheTestQuery($cache, $driver); - - $query = $query->rememberForever(); - - $driver->shouldReceive('rememberForever') - ->once() - ->with($query->getCacheKey(), m::type('Closure')) - ->andReturnUsing(function($key, $callback) { return $callback(); }); - - - - $this->assertEquals($query->get(), array('results')); - } - - - public function testSelectWithCachingAndTags() - { - $taggedCache = m::mock('StdClass'); - $cache = m::mock('stdClass'); - $driver = m::mock('stdClass'); - - $driver->shouldReceive('tags') - ->once() - ->with(array('foo','bar')) - ->andReturn($taggedCache); - - $query = $this->setupCacheTestQuery($cache, $driver); - $query = $query->cacheTags(array('foo', 'bar'))->remember(5); - - $taggedCache->shouldReceive('remember') - ->once() - ->with($query->getCacheKey(), 5, m::type('Closure')) - ->andReturnUsing(function($key, $minutes, $callback) { return $callback(); }); - - $this->assertEquals($query->get(), array('results')); - } - public function testBasicAlias() { @@ -683,78 +624,6 @@ public function testImplode() } - public function testPaginateCorrectlyCreatesPaginatorInstance() - { - $connection = m::mock('Illuminate\Database\ConnectionInterface'); - $grammar = m::mock('Illuminate\Database\Query\Grammars\Grammar'); - $processor = m::mock('Illuminate\Database\Query\Processors\Processor'); - $builder = $this->getMock('Illuminate\Database\Query\Builder', array('getPaginationCount', 'forPage', 'get'), array($connection, $grammar, $processor)); - $paginator = m::mock('Illuminate\Pagination\Factory'); - $paginator->shouldReceive('getCurrentPage')->once()->andReturn(1); - $connection->shouldReceive('getPaginator')->once()->andReturn($paginator); - $builder->expects($this->once())->method('forPage')->with($this->equalTo(1), $this->equalTo(15))->will($this->returnValue($builder)); - $builder->expects($this->once())->method('get')->with($this->equalTo(array('*')))->will($this->returnValue(array('foo'))); - $builder->expects($this->once())->method('getPaginationCount')->will($this->returnValue(10)); - $paginator->shouldReceive('make')->once()->with(array('foo'), 10, 15)->andReturn(array('results')); - - $this->assertEquals(array('results'), $builder->paginate(15, array('*'))); - } - - - public function testPaginateCorrectlyCreatesPaginatorInstanceForGroupedQuery() - { - $connection = m::mock('Illuminate\Database\ConnectionInterface'); - $grammar = m::mock('Illuminate\Database\Query\Grammars\Grammar'); - $processor = m::mock('Illuminate\Database\Query\Processors\Processor'); - $builder = $this->getMock('Illuminate\Database\Query\Builder', array('get'), array($connection, $grammar, $processor)); - $paginator = m::mock('Illuminate\Pagination\Factory'); - $paginator->shouldReceive('getCurrentPage')->once()->andReturn(2); - $connection->shouldReceive('getPaginator')->once()->andReturn($paginator); - $builder->expects($this->once())->method('get')->with($this->equalTo(array('*')))->will($this->returnValue(array('foo', 'bar', 'baz'))); - $paginator->shouldReceive('make')->once()->with(array('baz'), 3, 2)->andReturn(array('results')); - - $this->assertEquals(array('results'), $builder->groupBy('foo')->paginate(2, array('*'))); - } - - - public function testGetPaginationCountGetsResultCount() - { - unset($_SERVER['orders']); - $builder = $this->getBuilder(); - $builder->getConnection()->shouldReceive('select')->once()->with('select count(*) as aggregate from "users"', array())->andReturn(array(array('aggregate' => 1))); - $builder->getProcessor()->shouldReceive('processSelect')->once()->andReturnUsing(function($query, $results) - { - $_SERVER['orders'] = $query->orders; - return $results; - }); - $results = $builder->from('users')->orderBy('foo', 'desc')->getPaginationCount(); - - $this->assertNull($_SERVER['orders']); - unset($_SERVER['orders']); - - $this->assertEquals(array(0 => array('column' => 'foo', 'direction' => 'desc')), $builder->orders); - $this->assertEquals(1, $results); - } - - - public function testQuickPaginateCorrectlyCreatesPaginatorInstance() - { - $connection = m::mock('Illuminate\Database\ConnectionInterface'); - $grammar = m::mock('Illuminate\Database\Query\Grammars\Grammar'); - $processor = m::mock('Illuminate\Database\Query\Processors\Processor'); - $builder = $this->getMock('Illuminate\Database\Query\Builder', array('skip', 'take', 'get'), array($connection, $grammar, $processor)); - $paginator = m::mock('Illuminate\Pagination\Factory'); - $paginator->shouldReceive('getCurrentPage')->once()->andReturn(1); - $connection->shouldReceive('getPaginator')->once()->andReturn($paginator); - $builder->expects($this->once())->method('skip')->with($this->equalTo(0))->will($this->returnValue($builder)); - $builder->expects($this->once())->method('take')->with($this->equalTo(16))->will($this->returnValue($builder)); - $builder->expects($this->once())->method('get')->with($this->equalTo(array('*')))->will($this->returnValue(array('foo'))); - $paginator->shouldReceive('make')->once()->with(array('foo'), 15)->andReturn(array('results')); - - $this->assertEquals(array('results'), $builder->simplePaginate(15, array('*'))); - } - - public function testPluckMethodReturnsSingleColumn() { $builder = $this->getBuilder();
true
Other
laravel
framework
9acf685b749ac065f7b4ba52ded5eb5bcbc2bf4e.json
Fix a few bugs.
src/Illuminate/Exception/Handler.php
@@ -6,6 +6,7 @@ use ReflectionFunction; use Illuminate\Contracts\Support\ResponsePreparer; use Illuminate\Contracts\Exception\Handler as HandlerContract; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\Debug\Exception\FatalErrorException as FatalError; @@ -352,6 +353,20 @@ public function pushError(Closure $callback) $this->handlers[] = $callback; } + /** + * Register a 404 error handler. + * + * @param \Closure $callback + * @return void + */ + public function missing(Closure $callback) + { + $this->error(function(NotFoundHttpException $e) use ($callback) + { + return call_user_func($callback, $e); + }); + } + /** * Register an error handler for fatal errors. *
true
Other
laravel
framework
9acf685b749ac065f7b4ba52ded5eb5bcbc2bf4e.json
Fix a few bugs.
src/Illuminate/Foundation/Application.php
@@ -714,8 +714,6 @@ public function run(SymfonyRequest $request = null) $response = with($stack = $this->call($this->stack))->setContainer($this)->run($request); $response->send(); - - $stack->terminate($request, $response); } /** @@ -903,20 +901,6 @@ public function abort($code, $message = '', array $headers = array()) throw new HttpException($code, $message, null, $headers); } - /** - * Register a 404 error handler. - * - * @param \Closure $callback - * @return void - */ - public function missing(Closure $callback) - { - $this->error(function(NotFoundHttpException $e) use ($callback) - { - return call_user_func($callback, $e); - }); - } - /** * Get the configuration loader instance. *
true
Other
laravel
framework
638b63a7471d451251b0cd7a3914677d2715575d.json
Add helper methods for events.
src/Illuminate/Foundation/Application.php
@@ -666,6 +666,26 @@ 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'; + } + /** * Register the application stack. *
true
Other
laravel
framework
638b63a7471d451251b0cd7a3914677d2715575d.json
Add helper methods for events.
src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php
@@ -13,9 +13,9 @@ class EventServiceProvider extends ServiceProvider { */ public function boot(DispatcherContract $events) { - if (file_exists($scanned = $this->app['path.storage'].'/framework/events.scanned.php')) + if ($this->app->eventsAreScanned()) { - require $scanned; + require $this->app->getScannedEventsPath(); } foreach ($this->listen as $event => $listeners)
true
Other
laravel
framework
964c28e128a72ae4c580b7a83a3e13fa7a7c7d76.json
change Middlewares to Middleware
src/Illuminate/Foundation/Console/Optimize/config.php
@@ -103,8 +103,8 @@ $basePath.'/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Session/SessionInterface.php', - $basePath.'/vendor/laravel/framework/src/Illuminate/Session/Middlewares/Reader.php', - $basePath.'/vendor/laravel/framework/src/Illuminate/Session/Middlewares/Writer.php', + $basePath.'/vendor/laravel/framework/src/Illuminate/Session/Middleware/Reader.php', + $basePath.'/vendor/laravel/framework/src/Illuminate/Session/Middleware/Writer.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Session/Store.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Session/SessionManager.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Support/Manager.php',
false
Other
laravel
framework
cbc1b73ea9284dcc056bb11c68c76f4fd7940e8e.json
Set the container before running.
src/Illuminate/Routing/Router.php
@@ -591,7 +591,7 @@ protected function runRouteWithinStack(Route $route, Request $request, $runMiddl { return $route->run($request); - }, $runMiddleware ? $this->gatherRouteMiddlewares($route) : []))->run($request); + }, $runMiddleware ? $this->gatherRouteMiddlewares($route) : []))->setContainer($this->container)->run($request); } /**
false
Other
laravel
framework
318e39278831a9d8f95b9d1ebfa3cc9cf8c7fd82.json
Remove old file.
src/Illuminate/Foundation/Console/Optimize/config.php
@@ -56,7 +56,6 @@ $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Providers/EventServiceProvider.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php', - $basePath.'/vendor/laravel/framework/src/Illuminate/Routing/FilterServiceProvider.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Routing/RouteServiceProvider.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php', $basePath.'/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php',
false
Other
laravel
framework
b0bd7da50d2d4923734e9c3f865d2988954fc536.json
Fix app:name for middleware.
src/Illuminate/Foundation/Console/AppNameCommand.php
@@ -127,23 +127,23 @@ protected function replaceNamespace($path) */ protected function setServiceProviderNamespaceReferences() { - $this->setReferencedFilterNamespaces(); + $this->setReferencedMiddlewareNamespaces(); $this->setReferencedConsoleNamespaces(); $this->setReferencedRouteNamespaces(); } /** - * Set the namespace on the referenced filters in the filter service provider. + * Set the namespace on the referenced middleware. * * @return void */ - protected function setReferencedFilterNamespaces() + protected function setReferencedMiddlewareNamespaces() { $this->replaceIn( - $this->laravel['path'].'/Providers/FilterServiceProvider.php', - $this->currentRoot.'\\Http\\Filters', $this->argument('name').'\\Http\\Filters' + $this->laravel['path'].'/Providers/AppServiceProvider.php', + $this->currentRoot.'\\Http\\Middleware', $this->argument('name').'\\Http\\Middleware' ); }
false
Other
laravel
framework
b35bbe22db5911dc76300faed857ca268b67991e.json
Remove unneeded files.
src/Illuminate/Routing/Console/stubs/filter.after.stub
@@ -1,22 +0,0 @@ -<?php namespace {{namespace}}; - -use Illuminate\Http\Request; -use Illuminate\Http\Response; -use Illuminate\Routing\Route; - -class {{class}} { - - /** - * Run the request filter. - * - * @param Route $route - * @param Request $request - * @param Response $response - * @return mixed - */ - public function filter(Route $route, Request $request, Response $response) - { - // - } - -}
true
Other
laravel
framework
b35bbe22db5911dc76300faed857ca268b67991e.json
Remove unneeded files.
src/Illuminate/Routing/Console/stubs/filter.global.after.stub
@@ -1,20 +0,0 @@ -<?php namespace {{namespace}}; - -use Illuminate\Http\Request; -use Illuminate\Http\Response; - -class {{class}} { - - /** - * Run the request filter. - * - * @param Request $request - * @param Response $response - * @return mixed - */ - public function filter(Request $request, Response $response) - { - // - } - -}
true
Other
laravel
framework
b35bbe22db5911dc76300faed857ca268b67991e.json
Remove unneeded files.
src/Illuminate/Routing/Console/stubs/filter.global.stub
@@ -1,18 +0,0 @@ -<?php namespace {{namespace}}; - -use Illuminate\Http\Request; - -class {{class}} { - - /** - * Run the request filter. - * - * @param Request $request - * @return mixed - */ - public function filter(Request $request) - { - // - } - -}
true
Other
laravel
framework
b35bbe22db5911dc76300faed857ca268b67991e.json
Remove unneeded files.
src/Illuminate/Routing/Console/stubs/filter.stub
@@ -1,20 +0,0 @@ -<?php namespace {{namespace}}; - -use Illuminate\Http\Request; -use Illuminate\Routing\Route; - -class {{class}} { - - /** - * Run the request filter. - * - * @param Route $route - * @param Request $request - * @return mixed - */ - public function filter(Route $route, Request $request) - { - // - } - -}
true
Other
laravel
framework
c29a38f3180e60eb2482f6083f993ecd4f012030.json
Fix a couple of bugs.
src/Illuminate/Routing/Console/stubs/middleware.stub
@@ -1,7 +1,7 @@ <?php namespace {{namespace}}; use Closure; -use Illuminate\Routing\Contracts\Middleware; +use Illuminate\Contracts\Routing\Middleware; class {{class}} implements Middleware {
true
Other
laravel
framework
c29a38f3180e60eb2482f6083f993ecd4f012030.json
Fix a couple of bugs.
src/Illuminate/Routing/Router.php
@@ -710,7 +710,7 @@ protected function addGlobalFilter($filter, $callback) */ public function middleware($name, $class) { - $this->middlewares[$name] = $class; + $this->middleware[$name] = $class; return $this; }
true
Other
laravel
framework
2fee0ed98563ad207b3467edc2be6ce68dc9fa93.json
Set doc blocks.
src/Illuminate/Contracts/Routing/Middleware.php
@@ -7,9 +7,9 @@ interface Middleware { /** * Handle an incoming request. * - * @param \Symfony\Component\HttpFoundation\Request $request + * @param \Illuminate\Http\Request $request * @param \Closure $next - * @return \Symfony\Component\HttpFoundation\Response + * @return mixed */ public function handle($request, Closure $next);
true
Other
laravel
framework
2fee0ed98563ad207b3467edc2be6ce68dc9fa93.json
Set doc blocks.
src/Illuminate/Cookie/Guard.php
@@ -31,9 +31,9 @@ public function __construct(EncrypterContract $encrypter) /** * Handle an incoming request. * - * @param \Symfony\Component\HttpFoundation\Request $request + * @param \Illuminate\Http\Request $request * @param \Closure $next - * @return \Symfony\Component\HttpFoundation\Response + * @return mixed */ public function handle($request, Closure $next) {
true
Other
laravel
framework
2fee0ed98563ad207b3467edc2be6ce68dc9fa93.json
Set doc blocks.
src/Illuminate/Cookie/Queue.php
@@ -28,9 +28,9 @@ public function __construct(CookieJar $cookies) /** * Handle an incoming request. * - * @param \Symfony\Component\HttpFoundation\Request $request + * @param \Illuminate\Http\Request $request * @param \Closure $next - * @return \Symfony\Component\HttpFoundation\Response + * @return mixed */ public function handle($request, Closure $next) {
true
Other
laravel
framework
2fee0ed98563ad207b3467edc2be6ce68dc9fa93.json
Set doc blocks.
src/Illuminate/Session/Middleware/Reader.php
@@ -30,9 +30,9 @@ public function __construct(SessionManager $manager) /** * Handle an incoming request. * - * @param \Symfony\Component\HttpFoundation\Request $request + * @param \Illuminate\Http\Request $request * @param \Closure $next - * @return \Symfony\Component\HttpFoundation\Response + * @return mixed */ public function handle($request, Closure $next) {
true
Other
laravel
framework
2fee0ed98563ad207b3467edc2be6ce68dc9fa93.json
Set doc blocks.
src/Illuminate/Session/Middleware/Writer.php
@@ -33,9 +33,9 @@ public function __construct(SessionManager $manager) /** * Handle an incoming request. * - * @param \Symfony\Component\HttpFoundation\Request $request + * @param \Illuminate\Http\Request $request * @param \Closure $next - * @return \Symfony\Component\HttpFoundation\Response + * @return mixed */ public function handle($request, Closure $next) {
true
Other
laravel
framework
dfdee189937da40ac48276b270aa7b8c0ab81a24.json
Adapt test to new behavior.
tests/Foundation/FoundationApplicationTest.php
@@ -95,7 +95,7 @@ public function testDeferredServicesAreLazilyInitialized() $this->assertTrue($app->bound('foo')); $this->assertFalse(ApplicationDeferredServiceProviderStub::$initialized); $app->extend('foo', function($instance, $container) { return $instance.'bar'; }); - $this->assertTrue(ApplicationDeferredServiceProviderStub::$initialized); + $this->assertFalse(ApplicationDeferredServiceProviderStub::$initialized); $this->assertEquals('foobar', $app->make('foo')); $this->assertTrue(ApplicationDeferredServiceProviderStub::$initialized); }
false
Other
laravel
framework
a8bd58218b3617a6a3fbdbae7dc929d674968d2d.json
Remove extend() overwriting in application.
src/Illuminate/Foundation/Application.php
@@ -483,29 +483,6 @@ public function bound($abstract) return isset($this->deferredServices[$abstract]) || parent::bound($abstract); } - /** - * "Extend" an abstract type in the container. - * - * (Overriding Container::extend) - * - * @param string $abstract - * @param \Closure $closure - * @return void - * - * @throws \InvalidArgumentException - */ - public function extend($abstract, Closure $closure) - { - $abstract = $this->getAlias($abstract); - - if (isset($this->deferredServices[$abstract])) - { - $this->loadDeferredProvider($abstract); - } - - return parent::extend($abstract, $closure); - } - /** * Register a "before" application filter. *
false
Other
laravel
framework
a9dd69087a5c5a39d02b1306809211e4d230fb66.json
Add a test case for extend() before bind().
tests/Container/ContainerTest.php
@@ -214,6 +214,19 @@ public function testExtendIsLazyInitialized() } + public function testExtendCanBeCalledBeforeBind() + { + $container = new Container; + $container->extend('foo', function($old, $container) + { + return $old.'bar'; + }); + $container['foo'] = 'foo'; + + $this->assertEquals('foobar', $container->make('foo')); + } + + public function testParametersCanBePassedThroughToClosure() { $container = new Container;
false
Other
laravel
framework
669c5356e65f0712d4f71f2cd8c6345838401ccb.json
Set morphs directly
src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php
@@ -101,32 +101,29 @@ public function save(Model $model) */ public function create(array $attributes) { - $foreign = $this->getForeignAttributesForCreate(); + $instance = $this->related->newInstance($attributes); // When saving a polymorphic relationship, we need to set not only the foreign // key, but also the foreign key type, which is typically the class name of // the parent model. This makes the polymorphic item unique in the table. - $attributes = array_merge($attributes, $foreign); - - $instance = $this->related->newInstance($attributes); + $this->setForeignAttributesForCreate($instance); $instance->save(); return $instance; } /** - * Get the foreign ID and type for creating a related model. + * Set the foreign ID and type for creating a related model. * - * @return array + * @param \Illuminate\Database\Eloquent\Model $model + * @return void */ - protected function getForeignAttributesForCreate() + protected function setForeignAttributesForCreate(Model $model) { - $foreign = array($this->getPlainForeignKey() => $this->getParentKey()); - - $foreign[last(explode('.', $this->morphType))] = $this->morphClass; + $model->{$this->getPlainForeignKey()} = $this->getParentKey(); - return $foreign; + $model->{last(explode('.', $this->morphType))} = $this->morphClass; } /**
true
Other
laravel
framework
669c5356e65f0712d4f71f2cd8c6345838401ccb.json
Set morphs directly
tests/Database/DatabaseEloquentMorphTest.php
@@ -60,8 +60,10 @@ public function testCreateFunctionOnMorph() { // Doesn't matter which relation type we use since they share the code... $relation = $this->getOneRelation(); - $created = m::mock('stdClass'); - $relation->getRelated()->shouldReceive('newInstance')->once()->with(array('name' => 'taylor', 'morph_id' => 1, 'morph_type' => get_class($relation->getParent())))->andReturn($created); + $created = m::mock('Illuminate\Database\Eloquent\Model'); + $created->shouldReceive('setAttribute')->once()->with('morph_id', 1); + $created->shouldReceive('setAttribute')->once()->with('morph_type', get_class($relation->getParent())); + $relation->getRelated()->shouldReceive('newInstance')->once()->with(array('name' => 'taylor'))->andReturn($created); $created->shouldReceive('save')->once()->andReturn(true); $this->assertEquals($created, $relation->create(array('name' => 'taylor')));
true
Other
laravel
framework
059656e04a4ab0ea1fd1fe6afb2dba1cc6cfd7b4.json
Add "redirector" property on "FormRequest" Adding missing "redirector" property, that is accessed from "FormRequest::setRedirector" method. This would allow to have correct IDE auto-complete on that property within that class.
src/Illuminate/Foundation/Http/FormRequest.php
@@ -22,6 +22,13 @@ class FormRequest extends Request implements ValidatesWhenResolved { */ protected $container; + /** + * The redirector instance. + * + * @var Redirector + */ + protected $redirector; + /** * The route instance the request is dispatched to. * @@ -102,7 +109,7 @@ protected function failedValidation(Validator $validator) } /** - * Deteremine if the request passes the authorization check. + * Determine if the request passes the authorization check. * * @return bool */
false
Other
laravel
framework
68b2fd0ae1e996ff9faac977eea8dda265797745.json
Tweak a method.
src/Illuminate/Routing/ResourceRegistrar.php
@@ -194,7 +194,7 @@ protected function getResourceName($resource, $method, $options) // the resource action. Otherwise we'll just use an empty string for here. $prefix = isset($options['as']) ? $options['as'].'.' : ''; - if (empty($this->router->getGroupStack())) + if ( ! $this->router->hasGroupStack()) { return $prefix.$resource.'.'.$method; }
true
Other
laravel
framework
68b2fd0ae1e996ff9faac977eea8dda265797745.json
Tweak a method.
src/Illuminate/Routing/Router.php
@@ -1031,6 +1031,16 @@ protected function prepareResponse($request, $response) return $response->prepare($request); } + /** + * Determine if the router currently has a group stack. + * + * @return bool + */ + public function hasGroupStack() + { + return ! empty($this->groupStack); + } + /** * Get the current group stack for the router. *
true
Other
laravel
framework
9873d6fb33406f149897e75bd6fbabdd020735b8.json
Extract resource registration into its own class.
src/Illuminate/Routing/ResourceRegistrar.php
@@ -0,0 +1,388 @@ +<?php namespace Illuminate\Routing; + +class ResourceRegistrar { + + /** + * Create a new resource registrar. + * + * @param \Illuminate\Routing\Router + */ + protected $router; + + /** + * The default actions for a resourceful controller. + * + * @var array + */ + protected $resourceDefaults = array('index', 'create', 'store', 'show', 'edit', 'update', 'destroy'); + + /** + * Create a new resource registrar instance. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ + public function __construct(Router $router) + { + $this->router = $router; + } + + /** + * Route a resource to a controller. + * + * @param Router $router + * @param string $name + * @param string $controller + * @param array $options + * @return void + */ + public function register($name, $controller, array $options = array()) + { + // If the resource name contains a slash, we will assume the developer wishes to + // register these resource routes with a prefix so we will set that up out of + // the box so they don't have to mess with it. Otherwise, we will continue. + if (str_contains($name, '/')) + { + $this->prefixedResource($name, $controller, $options); + + return; + } + + // We need to extract the base resource from the resource name. Nested resources + // are supported in the framework, but we need to know what name to use for a + // place-holder on the route wildcards, which should be the base resources. + $base = $this->getResourceWildcard(last(explode('.', $name))); + + $defaults = $this->resourceDefaults; + + foreach ($this->getResourceMethods($defaults, $options) as $m) + { + $this->{'addResource'.ucfirst($m)}($name, $base, $controller, $options); + } + } + + /** + * Build a set of prefixed resource routes. + * + * @param string $name + * @param string $controller + * @param array $options + * @return void + */ + protected function prefixedResource($name, $controller, array $options) + { + list($name, $prefix) = $this->getResourcePrefix($name); + + // We need to extract the base resource from the resource name. Nested resources + // are supported in the framework, but we need to know what name to use for a + // place-holder on the route wildcards, which should be the base resources. + $callback = function($me) use ($name, $controller, $options) + { + $me->resource($name, $controller, $options); + }; + + return $this->router->group(compact('prefix'), $callback); + } + + /** + * Extract the resource and prefix from a resource name. + * + * @param string $name + * @return array + */ + protected function getResourcePrefix($name) + { + $segments = explode('/', $name); + + // To get the prefix, we will take all of the name segments and implode them on + // a slash. This will generate a proper URI prefix for us. Then we take this + // last segment, which will be considered the final resources name we use. + $prefix = implode('/', array_slice($segments, 0, -1)); + + return array(end($segments), $prefix); + } + + /** + * Get the applicable resource methods. + * + * @param array $defaults + * @param array $options + * @return array + */ + protected function getResourceMethods($defaults, $options) + { + if (isset($options['only'])) + { + return array_intersect($defaults, (array) $options['only']); + } + elseif (isset($options['except'])) + { + return array_diff($defaults, (array) $options['except']); + } + + return $defaults; + } + + /** + * Get the base resource URI for a given resource. + * + * @param string $resource + * @return string + */ + public function getResourceUri($resource) + { + if ( ! str_contains($resource, '.')) return $resource; + + // Once we have built the base URI, we'll remove the wildcard holder for this + // base resource name so that the individual route adders can suffix these + // paths however they need to, as some do not have any wildcards at all. + $segments = explode('.', $resource); + + $uri = $this->getNestedResourceUri($segments); + + return str_replace('/{'.$this->getResourceWildcard(last($segments)).'}', '', $uri); + } + + /** + * Get the URI for a nested resource segment array. + * + * @param array $segments + * @return string + */ + protected function getNestedResourceUri(array $segments) + { + // We will spin through the segments and create a place-holder for each of the + // resource segments, as well as the resource itself. Then we should get an + // entire string for the resource URI that contains all nested resources. + return implode('/', array_map(function($s) + { + return $s.'/{'.$this->getResourceWildcard($s).'}'; + + }, $segments)); + } + + /** + * Get the action array for a resource route. + * + * @param string $resource + * @param string $controller + * @param string $method + * @param array $options + * @return array + */ + protected function getResourceAction($resource, $controller, $method, $options) + { + $name = $this->getResourceName($resource, $method, $options); + + return array('as' => $name, 'uses' => $controller.'@'.$method); + } + + /** + * Get the name for a given resource. + * + * @param string $resource + * @param string $method + * @param array $options + * @return string + */ + protected function getResourceName($resource, $method, $options) + { + if (isset($options['names'][$method])) return $options['names'][$method]; + + // If a global prefix has been assigned to all names for this resource, we will + // grab that so we can prepend it onto the name when we create this name for + // the resource action. Otherwise we'll just use an empty string for here. + $prefix = isset($options['as']) ? $options['as'].'.' : ''; + + if (empty($this->router->getGroupStack())) + { + return $prefix.$resource.'.'.$method; + } + + return $this->getGroupResourceName($prefix, $resource, $method); + } + + /** + * Get the resource name for a grouped resource. + * + * @param string $prefix + * @param string $resource + * @param string $method + * @return string + */ + protected function getGroupResourceName($prefix, $resource, $method) + { + $group = str_replace('/', '.', $this->router->getLastGroupPrefix()); + + return trim("{$prefix}{$group}.{$resource}.{$method}", '.'); + } + + /** + * Format a resource wildcard for usage. + * + * @param string $value + * @return string + */ + public function getResourceWildcard($value) + { + return str_replace('-', '_', $value); + } + + /** + * Add the index method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return \Illuminate\Routing\Route + */ + protected function addResourceIndex($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name); + + $action = $this->getResourceAction($name, $controller, 'index', $options); + + return $this->router->get($uri, $action); + } + + /** + * Add the create method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return \Illuminate\Routing\Route + */ + protected function addResourceCreate($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name).'/create'; + + $action = $this->getResourceAction($name, $controller, 'create', $options); + + return $this->router->get($uri, $action); + } + + /** + * Add the store method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return \Illuminate\Routing\Route + */ + protected function addResourceStore($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name); + + $action = $this->getResourceAction($name, $controller, 'store', $options); + + return $this->router->post($uri, $action); + } + + /** + * Add the show method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return \Illuminate\Routing\Route + */ + protected function addResourceShow($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name).'/{'.$base.'}'; + + $action = $this->getResourceAction($name, $controller, 'show', $options); + + return $this->router->get($uri, $action); + } + + /** + * Add the edit method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return \Illuminate\Routing\Route + */ + protected function addResourceEdit($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name).'/{'.$base.'}/edit'; + + $action = $this->getResourceAction($name, $controller, 'edit', $options); + + return $this->router->get($uri, $action); + } + + /** + * Add the update method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return void + */ + protected function addResourceUpdate($name, $base, $controller, $options) + { + $this->addPutResourceUpdate($name, $base, $controller, $options); + + return $this->addPatchResourceUpdate($name, $base, $controller); + } + + /** + * Add the update method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return \Illuminate\Routing\Route + */ + protected function addPutResourceUpdate($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name).'/{'.$base.'}'; + + $action = $this->getResourceAction($name, $controller, 'update', $options); + + return $this->router->put($uri, $action); + } + + /** + * Add the update method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @return void + */ + protected function addPatchResourceUpdate($name, $base, $controller) + { + $uri = $this->getResourceUri($name).'/{'.$base.'}'; + + $this->router->patch($uri, $controller.'@update'); + } + + /** + * Add the destroy method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return \Illuminate\Routing\Route + */ + protected function addResourceDestroy($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name).'/{'.$base.'}'; + + $action = $this->getResourceAction($name, $controller, 'destroy', $options); + + return $this->router->delete($uri, $action); + } + +}
true
Other
laravel
framework
9873d6fb33406f149897e75bd6fbabdd020735b8.json
Extract resource registration into its own class.
src/Illuminate/Routing/Router.php
@@ -112,13 +112,6 @@ class Router implements HttpKernelInterface, RegistrarContract, RouteFiltererInt */ public static $verbs = array('GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'); - /** - * The default actions for a resourceful controller. - * - * @var array - */ - protected $resourceDefaults = array('index', 'create', 'store', 'show', 'edit', 'update', 'destroy'); - /** * Create a new Router instance. * @@ -131,8 +124,6 @@ public function __construct(Dispatcher $events, Container $container = null) $this->events = $events; $this->routes = new RouteCollection; $this->container = $container ?: new Container; - - $this->bind('_missing', function($v) { return explode('/', $v); }); } /** @@ -234,446 +225,18 @@ public function match($methods, $uri, $action) return $this->addRoute(array_map('strtoupper', (array) $methods), $uri, $action); } - /** - * Register an array of controllers with wildcard routing. - * - * @param array $controllers - * @return void - */ - public function controllers(array $controllers) - { - foreach ($controllers as $uri => $name) - { - $this->controller($uri, $name); - } - } - - /** - * Route a controller to a URI with wildcard routing. - * - * @param string $uri - * @param string $controller - * @param array $names - * @return void - */ - public function controller($uri, $controller, $names = array()) - { - $prepended = $controller; - - // First, we will check to see if a controller prefix has been registered in - // the route group. If it has, we will need to prefix it before trying to - // reflect into the class instance and pull out the method for routing. - if ( ! empty($this->groupStack)) - { - $prepended = $this->prependGroupUses($controller); - } - - $routable = $this->getInspector()->getRoutable($prepended, $uri); - - // When a controller is routed using this method, we use Reflection to parse - // out all of the routable methods for the controller, then register each - // route explicitly for the developers, so reverse routing is possible. - foreach ($routable as $method => $routes) - { - foreach ($routes as $route) - { - $this->registerInspected($route, $controller, $method, $names); - } - } - - $this->addFallthroughRoute($controller, $uri); - } - - /** - * Register an inspected controller route. - * - * @param array $route - * @param string $controller - * @param string $method - * @param array $names - * @return void - */ - protected function registerInspected($route, $controller, $method, &$names) - { - $action = array('uses' => $controller.'@'.$method); - - // If a given controller method has been named, we will assign the name to the - // controller action array, which provides for a short-cut to method naming - // so you don't have to define an individual route for these controllers. - $action['as'] = array_get($names, $method); - - $this->{$route['verb']}($route['uri'], $action); - } - - /** - * Add a fallthrough route for a controller. - * - * @param string $controller - * @param string $uri - * @return void - */ - protected function addFallthroughRoute($controller, $uri) - { - $missing = $this->any($uri.'/{_missing}', $controller.'@missingMethod'); - - $missing->where('_missing', '(.*)'); - } - /** * Route a resource to a controller. * + * @param Router $router * @param string $name * @param string $controller * @param array $options * @return void */ public function resource($name, $controller, array $options = array()) { - // If the resource name contains a slash, we will assume the developer wishes to - // register these resource routes with a prefix so we will set that up out of - // the box so they don't have to mess with it. Otherwise, we will continue. - if (str_contains($name, '/')) - { - $this->prefixedResource($name, $controller, $options); - - return; - } - - // We need to extract the base resource from the resource name. Nested resources - // are supported in the framework, but we need to know what name to use for a - // place-holder on the route wildcards, which should be the base resources. - $base = $this->getResourceWildcard(last(explode('.', $name))); - - $defaults = $this->resourceDefaults; - - foreach ($this->getResourceMethods($defaults, $options) as $m) - { - $this->{'addResource'.ucfirst($m)}($name, $base, $controller, $options); - } - } - - /** - * Build a set of prefixed resource routes. - * - * @param string $name - * @param string $controller - * @param array $options - * @return void - */ - protected function prefixedResource($name, $controller, array $options) - { - list($name, $prefix) = $this->getResourcePrefix($name); - - // We need to extract the base resource from the resource name. Nested resources - // are supported in the framework, but we need to know what name to use for a - // place-holder on the route wildcards, which should be the base resources. - $callback = function($me) use ($name, $controller, $options) - { - $me->resource($name, $controller, $options); - }; - - return $this->group(compact('prefix'), $callback); - } - - /** - * Extract the resource and prefix from a resource name. - * - * @param string $name - * @return array - */ - protected function getResourcePrefix($name) - { - $segments = explode('/', $name); - - // To get the prefix, we will take all of the name segments and implode them on - // a slash. This will generate a proper URI prefix for us. Then we take this - // last segment, which will be considered the final resources name we use. - $prefix = implode('/', array_slice($segments, 0, -1)); - - return array(end($segments), $prefix); - } - - /** - * Get the applicable resource methods. - * - * @param array $defaults - * @param array $options - * @return array - */ - protected function getResourceMethods($defaults, $options) - { - if (isset($options['only'])) - { - return array_intersect($defaults, (array) $options['only']); - } - elseif (isset($options['except'])) - { - return array_diff($defaults, (array) $options['except']); - } - - return $defaults; - } - - /** - * Get the base resource URI for a given resource. - * - * @param string $resource - * @return string - */ - public function getResourceUri($resource) - { - if ( ! str_contains($resource, '.')) return $resource; - - // Once we have built the base URI, we'll remove the wildcard holder for this - // base resource name so that the individual route adders can suffix these - // paths however they need to, as some do not have any wildcards at all. - $segments = explode('.', $resource); - - $uri = $this->getNestedResourceUri($segments); - - return str_replace('/{'.$this->getResourceWildcard(last($segments)).'}', '', $uri); - } - - /** - * Get the URI for a nested resource segment array. - * - * @param array $segments - * @return string - */ - protected function getNestedResourceUri(array $segments) - { - // We will spin through the segments and create a place-holder for each of the - // resource segments, as well as the resource itself. Then we should get an - // entire string for the resource URI that contains all nested resources. - return implode('/', array_map(function($s) - { - return $s.'/{'.$this->getResourceWildcard($s).'}'; - - }, $segments)); - } - - /** - * Get the action array for a resource route. - * - * @param string $resource - * @param string $controller - * @param string $method - * @param array $options - * @return array - */ - protected function getResourceAction($resource, $controller, $method, $options) - { - $name = $this->getResourceName($resource, $method, $options); - - return array('as' => $name, 'uses' => $controller.'@'.$method); - } - - /** - * Get the name for a given resource. - * - * @param string $resource - * @param string $method - * @param array $options - * @return string - */ - protected function getResourceName($resource, $method, $options) - { - if (isset($options['names'][$method])) return $options['names'][$method]; - - // If a global prefix has been assigned to all names for this resource, we will - // grab that so we can prepend it onto the name when we create this name for - // the resource action. Otherwise we'll just use an empty string for here. - $prefix = isset($options['as']) ? $options['as'].'.' : ''; - - if (empty($this->groupStack)) - { - return $prefix.$resource.'.'.$method; - } - - return $this->getGroupResourceName($prefix, $resource, $method); - } - - /** - * Get the resource name for a grouped resource. - * - * @param string $prefix - * @param string $resource - * @param string $method - * @return string - */ - protected function getGroupResourceName($prefix, $resource, $method) - { - $group = str_replace('/', '.', $this->getLastGroupPrefix()); - - return trim("{$prefix}{$group}.{$resource}.{$method}", '.'); - } - - /** - * Format a resource wildcard for usage. - * - * @param string $value - * @return string - */ - public function getResourceWildcard($value) - { - return str_replace('-', '_', $value); - } - - /** - * Add the index method for a resourceful route. - * - * @param string $name - * @param string $base - * @param string $controller - * @param array $options - * @return \Illuminate\Routing\Route - */ - protected function addResourceIndex($name, $base, $controller, $options) - { - $uri = $this->getResourceUri($name); - - $action = $this->getResourceAction($name, $controller, 'index', $options); - - return $this->get($uri, $action); - } - - /** - * Add the create method for a resourceful route. - * - * @param string $name - * @param string $base - * @param string $controller - * @param array $options - * @return \Illuminate\Routing\Route - */ - protected function addResourceCreate($name, $base, $controller, $options) - { - $uri = $this->getResourceUri($name).'/create'; - - $action = $this->getResourceAction($name, $controller, 'create', $options); - - return $this->get($uri, $action); - } - - /** - * Add the store method for a resourceful route. - * - * @param string $name - * @param string $base - * @param string $controller - * @param array $options - * @return \Illuminate\Routing\Route - */ - protected function addResourceStore($name, $base, $controller, $options) - { - $uri = $this->getResourceUri($name); - - $action = $this->getResourceAction($name, $controller, 'store', $options); - - return $this->post($uri, $action); - } - - /** - * Add the show method for a resourceful route. - * - * @param string $name - * @param string $base - * @param string $controller - * @param array $options - * @return \Illuminate\Routing\Route - */ - protected function addResourceShow($name, $base, $controller, $options) - { - $uri = $this->getResourceUri($name).'/{'.$base.'}'; - - $action = $this->getResourceAction($name, $controller, 'show', $options); - - return $this->get($uri, $action); - } - - /** - * Add the edit method for a resourceful route. - * - * @param string $name - * @param string $base - * @param string $controller - * @param array $options - * @return \Illuminate\Routing\Route - */ - protected function addResourceEdit($name, $base, $controller, $options) - { - $uri = $this->getResourceUri($name).'/{'.$base.'}/edit'; - - $action = $this->getResourceAction($name, $controller, 'edit', $options); - - return $this->get($uri, $action); - } - - /** - * Add the update method for a resourceful route. - * - * @param string $name - * @param string $base - * @param string $controller - * @param array $options - * @return void - */ - protected function addResourceUpdate($name, $base, $controller, $options) - { - $this->addPutResourceUpdate($name, $base, $controller, $options); - - return $this->addPatchResourceUpdate($name, $base, $controller); - } - - /** - * Add the update method for a resourceful route. - * - * @param string $name - * @param string $base - * @param string $controller - * @param array $options - * @return \Illuminate\Routing\Route - */ - protected function addPutResourceUpdate($name, $base, $controller, $options) - { - $uri = $this->getResourceUri($name).'/{'.$base.'}'; - - $action = $this->getResourceAction($name, $controller, 'update', $options); - - return $this->put($uri, $action); - } - - /** - * Add the update method for a resourceful route. - * - * @param string $name - * @param string $base - * @param string $controller - * @return void - */ - protected function addPatchResourceUpdate($name, $base, $controller) - { - $uri = $this->getResourceUri($name).'/{'.$base.'}'; - - $this->patch($uri, $controller.'@update'); - } - - /** - * Add the destroy method for a resourceful route. - * - * @param string $name - * @param string $base - * @param string $controller - * @param array $options - * @return \Illuminate\Routing\Route - */ - protected function addResourceDestroy($name, $base, $controller, $options) - { - $uri = $this->getResourceUri($name).'/{'.$base.'}'; - - $action = $this->getResourceAction($name, $controller, 'destroy', $options); - - return $this->delete($uri, $action); + (new ResourceRegistrar($this))->register($name, $controller, $options); } /** @@ -785,7 +348,7 @@ protected static function formatGroupPrefix($new, $old) * * @return string */ - protected function getLastGroupPrefix() + public function getLastGroupPrefix() { if ( ! empty($this->groupStack)) { @@ -935,34 +498,6 @@ protected function getControllerAction($action) return $action; } - /** - * Get the Closure for a controller based action. - * - * @param string $controller - * @return \Closure - */ - protected function getClassClosure($controller) - { - // Here we'll get an instance of this controller dispatcher and hand it off to - // the Closure so it will be used to resolve the class instances out of our - // IoC container instance and call the appropriate methods on the class. - $d = $this->getControllerDispatcher(); - - return function() use ($d, $controller) - { - $route = $this->current(); - - $request = $this->getCurrentRequest(); - - // Now we can split the controller and method out of the action string so that we - // can call them appropriately on the class. This controller and method are in - // in the Class@method format and we need to explode them out then use them. - list($class, $method) = explode('@', $controller); - - return $d->dispatch($route, $request, $class, $method); - }; - } - /** * Prepend the last group uses onto the use clause. * @@ -1503,6 +1038,16 @@ protected function prepareResponse($request, $response) return $response->prepare($request); } + /** + * Get the current group stack for the router. + * + * @return array + */ + public function getGroupStack() + { + return $this->groupStack; + } + /** * Run a callback with filters disable on the router. *
true
Other
laravel
framework
16f1e53a47f3edc3d7cc1c73fe1dd0e7622a4a56.json
Use the compiled config path.
src/Illuminate/View/ViewServiceProvider.php
@@ -77,7 +77,7 @@ public function registerBladeEngine($resolver) // instance to pass into the engine so it can compile the views properly. $app->bindShared('blade.compiler', function($app) { - $cache = $app['path.storage'].'/views'; + $cache = $app['config']['view.compiled']; return new BladeCompiler($app['files'], $cache); });
false
Other
laravel
framework
46aedf54af4a5c495b7c463874e3f3eb0ecb3691.json
Change some paths.
src/Illuminate/Foundation/Application.php
@@ -759,7 +759,7 @@ public function routesAreCached() */ public function getRouteCachePath() { - return $this['path.storage'].'/meta/routes.php'; + return $this['path.storage'].'/framework/routes.php'; } /**
true
Other
laravel
framework
46aedf54af4a5c495b7c463874e3f3eb0ecb3691.json
Change some paths.
src/Illuminate/Foundation/Console/ClearCompiledCommand.php
@@ -25,7 +25,7 @@ class ClearCompiledCommand extends Command { */ public function fire() { - if (file_exists($path = $this->laravel['path.storage'].'/meta/compiled.php')) + if (file_exists($path = $this->laravel['path.storage'].'/framework/compiled.php')) { @unlink($path); }
true
Other
laravel
framework
46aedf54af4a5c495b7c463874e3f3eb0ecb3691.json
Change some paths.
src/Illuminate/Foundation/Console/OptimizeCommand.php
@@ -85,7 +85,7 @@ protected function compileClasses() { $this->registerClassPreloaderCommand(); - $outputPath = $this->laravel['path.storage'].'/meta/compiled.php'; + $outputPath = $this->laravel['path.storage'].'/framework/compiled.php'; $this->callSilent('compile', array( '--config' => implode(',', $this->getClassFiles()),
true
Other
laravel
framework
2e3f5533a77837aa1b2781bc5ffa9fce01846827.json
Add a method to forget all queued event handlers.
src/Illuminate/Events/Dispatcher.php
@@ -335,4 +335,17 @@ public function forget($event) unset($this->listeners[$event], $this->sorted[$event]); } + /** + * Forget all of the queued listeners. + * + * @return void + */ + public function forgetQueued() + { + foreach ($this->listeners as $key => $value) + { + if (ends_with($key, '_queue')) $this->forget($key); + } + } + }
true
Other
laravel
framework
2e3f5533a77837aa1b2781bc5ffa9fce01846827.json
Add a method to forget all queued event handlers.
tests/Events/EventsDispatcherTest.php
@@ -57,6 +57,22 @@ public function testQueuedEventsAreFired() } + public function testQueuedEventsCanBeForgotten() + { + $_SERVER['__event.test'] = 'unset'; + $d = new Dispatcher; + $d->queue('update', array('name' => 'taylor')); + $d->listen('update', function($name) + { + $_SERVER['__event.test'] = $name; + }); + + $d->forgetQueued(); + $d->flush('update'); + $this->assertEquals('unset', $_SERVER['__event.test']); + } + + public function testWildcardListeners() { unset($_SERVER['__event.test']);
true
Other
laravel
framework
d2b1bfbbe17bd06c5af8385d1c9e336bfabc834b.json
Fix broken transaction logic when PDO changes
src/Illuminate/Database/Connection.php
@@ -831,6 +831,8 @@ public function getReadPdo() */ public function setPdo($pdo) { + if ($this->transactions >= 1) throw new \RuntimeException("Attempt to change PDO inside running transaction"); + $this->pdo = $pdo; return $this;
false
Other
laravel
framework
0735f1d658f2bf3b2f6672bf8f964890e14ed44d.json
Enable the query log for tests. DRY up code.
src/Illuminate/Container/Container.php
@@ -598,26 +598,19 @@ protected function getDependencyForCallParameter(ReflectionParameter $parameter, */ protected function callClass($target, array $parameters = array(), $defaultMethod = null) { + $segments = explode('@', $target); + // If the listener has an @ sign, we will assume it is being used to delimit // the class name from the handle method name. This allows for handlers // to run multiple handler methods in a single class for convenience. - $segments = explode('@', $target); - $method = count($segments) == 2 ? $segments[1] : $defaultMethod; if (is_null($method)) { throw new \InvalidArgumentException("Method not provided."); } - // We will make a callable of the listener instance and a method that should - // be called on that instance, then we will pass in the arguments that we - // received in this method into this listener class instance's methods. - $callable = array($this->make($segments[0]), $method); - - $dependencies = $this->getMethodDependencies($callable, $parameters); - - return call_user_func_array($callable, $dependencies); + return $this->call([$this->make($segments[0]), $method], $parameters); } /**
true
Other
laravel
framework
0735f1d658f2bf3b2f6672bf8f964890e14ed44d.json
Enable the query log for tests. DRY up code.
tests/Database/DatabaseConnectionTest.php
@@ -267,7 +267,9 @@ protected function getMockConnection($methods = array(), $pdo = null) { $pdo = $pdo ?: new DatabaseConnectionTestMockPDO; $defaults = array('getDefaultQueryGrammar', 'getDefaultPostProcessor', 'getDefaultSchemaGrammar'); - return $this->getMock('Illuminate\Database\Connection', array_merge($defaults, $methods), array($pdo)); + $connection = $this->getMock('Illuminate\Database\Connection', array_merge($defaults, $methods), array($pdo)); + $connection->enableQueryLog(); + return $connection; } }
true