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 | 304d71f8ce2d26d539076ff422d45872e2180b07.json | fix some formatting | src/Illuminate/Console/Parser.php | @@ -111,14 +111,14 @@ protected static function parseOption($token)
if (Str::contains($token, ' : ')) {
list($token, $description) = explode(' : ', $token);
-
$token = trim($token);
-
$description = trim($description);
}
$shortcut = null;
+
$matches = preg_split('/\s*\|\s*/', $token, 2);
+
if (isset($matches[1])) {
$shortcut = $matches[0];
$token = $matches[1]; | false |
Other | laravel | framework | 55887ac32840fbd88cf7ed7040c126d0742aed89.json | Add the possibility to set an option shortcut | src/Illuminate/Console/Parser.php | @@ -117,18 +117,25 @@ protected static function parseOption($token)
$description = trim($description);
}
+ $shortcut = null;
+ $matches = preg_split('/\s*\|\s*/', $token, 2);
+ if (isset($matches[1])) {
+ $shortcut = $matches[0];
+ $token = $matches[1];
+ }
+
switch (true) {
case Str::endsWith($token, '='):
- return new InputOption(trim($token, '='), null, InputOption::VALUE_OPTIONAL, $description);
+ return new InputOption(trim($token, '='), $shortcut, InputOption::VALUE_OPTIONAL, $description);
case Str::endsWith($token, '=*'):
- return new InputOption(trim($token, '=*'), null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description);
+ return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description);
case (preg_match('/(.+)\=(.+)/', $token, $matches)):
- return new InputOption($matches[1], null, InputOption::VALUE_OPTIONAL, $description, $matches[2]);
+ return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]);
default:
- return new InputOption($token, null, InputOption::VALUE_NONE, $description);
+ return new InputOption($token, $shortcut, InputOption::VALUE_NONE, $description);
}
}
} | true |
Other | laravel | framework | 55887ac32840fbd88cf7ed7040c126d0742aed89.json | Add the possibility to set an option shortcut | tests/Console/ConsoleParserTest.php | @@ -62,4 +62,46 @@ public function testBasicParameterParsing()
$this->assertTrue($results[2][0]->acceptValue());
$this->assertTrue($results[2][0]->isArray());
}
+
+ public function testShortcutNameParsing()
+ {
+ $results = Parser::parse('command:name {--o|option}');
+
+ $this->assertEquals('o', $results[2][0]->getShortcut());
+ $this->assertEquals('option', $results[2][0]->getName());
+ $this->assertFalse($results[2][0]->acceptValue());
+
+ $results = Parser::parse('command:name {--o|option=}');
+
+ $this->assertEquals('o', $results[2][0]->getShortcut());
+ $this->assertEquals('option', $results[2][0]->getName());
+ $this->assertTrue($results[2][0]->acceptValue());
+
+ $results = Parser::parse('command:name {--o|option=*}');
+
+ $this->assertEquals('command:name', $results[0]);
+ $this->assertEquals('o', $results[2][0]->getShortcut());
+ $this->assertEquals('option', $results[2][0]->getName());
+ $this->assertTrue($results[2][0]->acceptValue());
+ $this->assertTrue($results[2][0]->isArray());
+
+ $results = Parser::parse('command:name {--o|option=* : The option description.}');
+
+ $this->assertEquals('command:name', $results[0]);
+ $this->assertEquals('o', $results[2][0]->getShortcut());
+ $this->assertEquals('option', $results[2][0]->getName());
+ $this->assertEquals('The option description.', $results[2][0]->getDescription());
+ $this->assertTrue($results[2][0]->acceptValue());
+ $this->assertTrue($results[2][0]->isArray());
+
+ $results = Parser::parse('command:name
+ {--o|option=* : The option description.}');
+
+ $this->assertEquals('command:name', $results[0]);
+ $this->assertEquals('o', $results[2][0]->getShortcut());
+ $this->assertEquals('option', $results[2][0]->getName());
+ $this->assertEquals('The option description.', $results[2][0]->getDescription());
+ $this->assertTrue($results[2][0]->acceptValue());
+ $this->assertTrue($results[2][0]->isArray());
+ }
} | true |
Other | laravel | framework | 459290c88e8e5ba07fcfe2bece01c063fd2ab178.json | Fix typo in Parser.php | src/Illuminate/Console/Parser.php | @@ -56,7 +56,7 @@ protected static function parameters(array $tokens)
if (!Str::startsWith($token, '--')) {
$arguments[] = static::parseArgument($token);
} else {
- $options [] = static::parseOption(ltrim($token, '-'));
+ $options[] = static::parseOption(ltrim($token, '-'));
}
}
| false |
Other | laravel | framework | 6af7b2102fdec7e33cead64b335f58664f9a3ea9.json | fix several things | src/Illuminate/Foundation/helpers.php | @@ -326,14 +326,14 @@ function logger($message = null, array $context = [])
if (!function_exists('method_field')) {
/**
- * Generate a method spoof form field for POST method's.
+ * Generate a form field to spoof the HTTP verb used by forms.
*
- * @param string $method
+ * @param string $method
* @return string
*/
function method_field($method = "")
{
- return new Illuminate\View\Expression('<input type="hidden" name="_method" value="$method">');
+ return new Illuminate\View\Expression('<input type="hidden" name="_method" value="'.$method.'">');
}
}
| false |
Other | laravel | framework | 23c21e7958bdefc18c8b26a065f2feda48805adc.json | Create a helper as a shortcut for method spoofing
Similar to csrf_field(). | src/Illuminate/Foundation/helpers.php | @@ -324,6 +324,19 @@ function logger($message = null, array $context = [])
}
}
+if (!function_exists('method_spoof')) {
+ /**
+ * Generate a method spoof form field for POST method's.
+ *
+ * @param string $method
+ * @return string
+ */
+ function method_spoof($method = "")
+ {
+ return new Illuminate\View\Expression('<input type="hidden" name="_method" value="$method">');
+ }
+}
+
if (!function_exists('old')) {
/**
* Retrieve an old input item. | false |
Other | laravel | framework | dbc14072407800b5d3a3ccbc427f721293f9dd10.json | Use signature format for migrate make command | src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php | @@ -3,18 +3,19 @@
namespace Illuminate\Database\Console\Migrations;
use Illuminate\Foundation\Composer;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Input\InputArgument;
use Illuminate\Database\Migrations\MigrationCreator;
class MigrateMakeCommand extends BaseCommand
{
/**
- * The console command name.
+ * The console command signature.
*
* @var string
*/
- protected $name = 'make:migration';
+ protected $signature = 'make:migration {name : The name of the migration.}
+ {--create= : The table to be created.}
+ {--table= : The table to migrate.}
+ {--path= : The path to create the migration file in.}';
/**
* The console command description.
@@ -111,31 +112,4 @@ protected function getMigrationPath()
return parent::getMigrationPath();
}
- /**
- * Get the console command arguments.
- *
- * @return array
- */
- protected function getArguments()
- {
- return [
- ['name', InputArgument::REQUIRED, 'The name of the migration'],
- ];
- }
-
- /**
- * Get the console command options.
- *
- * @return array
- */
- protected function getOptions()
- {
- return [
- ['create', null, InputOption::VALUE_OPTIONAL, 'The table to be created.'],
-
- ['table', null, InputOption::VALUE_OPTIONAL, 'The table to migrate.'],
-
- ['path', null, InputOption::VALUE_OPTIONAL, 'The path to create the migration file in.'],
- ];
- }
} | false |
Other | laravel | framework | 8f2c68f838de27e38b3ae9819aba233a562f6616.json | Fix some valdiation rules
(cherry picked from commit 8b50161890a0eb697f878581cd8103f0d4470d71) | src/Illuminate/Validation/Validator.php | @@ -730,7 +730,7 @@ protected function validateSame($attribute, $value, $parameters)
$other = Arr::get($this->data, $parameters[0]);
- return isset($other) && $value == $other;
+ return isset($other) && $value === $other;
}
/**
@@ -747,7 +747,7 @@ protected function validateDifferent($attribute, $value, $parameters)
$other = Arr::get($this->data, $parameters[0]);
- return isset($other) && $value != $other;
+ return isset($other) && $value !== $other;
}
/** | true |
Other | laravel | framework | 8f2c68f838de27e38b3ae9819aba233a562f6616.json | Fix some valdiation rules
(cherry picked from commit 8b50161890a0eb697f878581cd8103f0d4470d71) | tests/Validation/ValidationValidatorTest.php | @@ -456,6 +456,9 @@ public function testValidateConfirmed()
$v = new Validator($trans, ['password' => 'foo', 'password_confirmation' => 'foo'], ['password' => 'Confirmed']);
$this->assertTrue($v->passes());
+
+ $v = new Validator($trans, ['password' => '1e2', 'password_confirmation' => '100'], ['password' => 'Confirmed']);
+ $this->assertFalse($v->passes());
}
public function testValidateSame()
@@ -469,6 +472,9 @@ public function testValidateSame()
$v = new Validator($trans, ['foo' => 'bar', 'baz' => 'bar'], ['foo' => 'Same:baz']);
$this->assertTrue($v->passes());
+
+ $v = new Validator($trans, ['foo' => '1e2', 'baz' => '100'], ['foo' => 'Same:baz']);
+ $this->assertFalse($v->passes());
}
public function testValidateDifferent()
@@ -482,6 +488,9 @@ public function testValidateDifferent()
$v = new Validator($trans, ['foo' => 'bar', 'baz' => 'bar'], ['foo' => 'Different:baz']);
$this->assertFalse($v->passes());
+
+ $v = new Validator($trans, ['foo' => '1e2', 'baz' => '100'], ['foo' => 'Different:baz']);
+ $this->assertTrue($v->passes());
}
public function testValidateAccepted() | true |
Other | laravel | framework | 652c4a589671e6e4bbae186dc716d675f3d7449e.json | Add composite index to jobs migration | src/Illuminate/Queue/Console/stubs/jobs.stub | @@ -21,6 +21,7 @@ class CreateJobsTable extends Migration
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
+ $table->index(['queue', 'reserved', 'reserved_at']);
});
}
| false |
Other | laravel | framework | 318b2dbba0e23e8858a699ade08bee72e8d4bdd4.json | Add missing dependency | src/Illuminate/Console/composer.json | @@ -16,6 +16,7 @@
"require": {
"php": ">=5.5.9",
"illuminate/contracts": "5.1.*",
+ "illuminate/support": "5.1.*",
"symfony/console": "2.7.*",
"nesbot/carbon": "~1.19"
}, | false |
Other | laravel | framework | 8b50161890a0eb697f878581cd8103f0d4470d71.json | Fix some valdiation rules | src/Illuminate/Validation/Validator.php | @@ -730,7 +730,7 @@ protected function validateSame($attribute, $value, $parameters)
$other = Arr::get($this->data, $parameters[0]);
- return isset($other) && $value == $other;
+ return isset($other) && $value === $other;
}
/**
@@ -747,7 +747,7 @@ protected function validateDifferent($attribute, $value, $parameters)
$other = Arr::get($this->data, $parameters[0]);
- return isset($other) && $value != $other;
+ return isset($other) && $value !== $other;
}
/** | true |
Other | laravel | framework | 8b50161890a0eb697f878581cd8103f0d4470d71.json | Fix some valdiation rules | tests/Validation/ValidationValidatorTest.php | @@ -456,6 +456,9 @@ public function testValidateConfirmed()
$v = new Validator($trans, ['password' => 'foo', 'password_confirmation' => 'foo'], ['password' => 'Confirmed']);
$this->assertTrue($v->passes());
+
+ $v = new Validator($trans, ['password' => '1e2', 'password_confirmation' => '100'], ['password' => 'Confirmed']);
+ $this->assertFalse($v->passes());
}
public function testValidateSame()
@@ -469,6 +472,9 @@ public function testValidateSame()
$v = new Validator($trans, ['foo' => 'bar', 'baz' => 'bar'], ['foo' => 'Same:baz']);
$this->assertTrue($v->passes());
+
+ $v = new Validator($trans, ['foo' => '1e2', 'baz' => '100'], ['foo' => 'Same:baz']);
+ $this->assertFalse($v->passes());
}
public function testValidateDifferent()
@@ -482,6 +488,9 @@ public function testValidateDifferent()
$v = new Validator($trans, ['foo' => 'bar', 'baz' => 'bar'], ['foo' => 'Different:baz']);
$this->assertFalse($v->passes());
+
+ $v = new Validator($trans, ['foo' => '1e2', 'baz' => '100'], ['foo' => 'Different:baz']);
+ $this->assertTrue($v->passes());
}
public function testValidateAccepted() | true |
Other | laravel | framework | cc7ac2b81471b4084d1dfbf44851556e705fd927.json | Add timestampsTz function to schema blueprint | src/Illuminate/Database/Schema/Blueprint.php | @@ -279,6 +279,16 @@ public function dropTimestamps()
$this->dropColumn('created_at', 'updated_at');
}
+ /**
+ * Indicate that the timestamp columns should be dropped.
+ *
+ * @return void
+ */
+ public function dropTimestampsTz()
+ {
+ $this->dropTimestamps();
+ }
+
/**
* Indicate that the soft delete column should be dropped.
*
@@ -711,6 +721,18 @@ public function timestamps()
$this->timestamp('updated_at');
}
+ /**
+ * Add creation and update timestampTz columns to the table.
+ *
+ * @return void
+ */
+ public function timestampsTz()
+ {
+ $this->timestampTz('created_at');
+
+ $this->timestampTz('updated_at');
+ }
+
/**
* Add a "deleted at" timestamp for the table.
* | true |
Other | laravel | framework | cc7ac2b81471b4084d1dfbf44851556e705fd927.json | Add timestampsTz function to schema blueprint | tests/Database/DatabaseMySqlSchemaGrammarTest.php | @@ -182,6 +182,16 @@ public function testDropTimestamps()
$this->assertEquals('alter table `users` drop `created_at`, drop `updated_at`', $statements[0]);
}
+ public function testDropTimestampsTz()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->dropTimestampsTz();
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+
+ $this->assertEquals(1, count($statements));
+ $this->assertEquals('alter table `users` drop `created_at`, drop `updated_at`', $statements[0]);
+ }
+
public function testRenameTable()
{
$blueprint = new Blueprint('users');
@@ -558,6 +568,16 @@ public function testAddingTimeStamps()
$this->assertEquals('alter table `users` add `created_at` timestamp default 0 not null, add `updated_at` timestamp default 0 not null', $statements[0]);
}
+ public function testAddingTimeStampsTz()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->timestampsTz();
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+
+ $this->assertEquals(1, count($statements));
+ $this->assertEquals('alter table `users` add `created_at` timestamp default 0 not null, add `updated_at` timestamp default 0 not null', $statements[0]);
+ }
+
public function testAddingRememberToken()
{
$blueprint = new Blueprint('users'); | true |
Other | laravel | framework | cc7ac2b81471b4084d1dfbf44851556e705fd927.json | Add timestampsTz function to schema blueprint | tests/Database/DatabasePostgresSchemaGrammarTest.php | @@ -124,6 +124,16 @@ public function testDropTimestamps()
$this->assertEquals('alter table "users" drop column "created_at", drop column "updated_at"', $statements[0]);
}
+ public function testDropTimestampsTz()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->dropTimestampsTz();
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+
+ $this->assertEquals(1, count($statements));
+ $this->assertEquals('alter table "users" drop column "created_at", drop column "updated_at"', $statements[0]);
+ }
+
public function testRenameTable()
{
$blueprint = new Blueprint('users');
@@ -453,6 +463,16 @@ public function testAddingTimeStamps()
$this->assertEquals('alter table "users" add column "created_at" timestamp(0) without time zone not null, add column "updated_at" timestamp(0) without time zone not null', $statements[0]);
}
+ public function testAddingTimeStampsTz()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->timestampsTz();
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+
+ $this->assertEquals(1, count($statements));
+ $this->assertEquals('alter table "users" add column "created_at" timestamp(0) with time zone not null, add column "updated_at" timestamp(0) with time zone not null', $statements[0]);
+ }
+
public function testAddingBinary()
{
$blueprint = new Blueprint('users'); | true |
Other | laravel | framework | cc7ac2b81471b4084d1dfbf44851556e705fd927.json | Add timestampsTz function to schema blueprint | tests/Database/DatabaseSQLiteSchemaGrammarTest.php | @@ -421,6 +421,20 @@ public function testAddingTimeStamps()
$this->assertEquals($expected, $statements);
}
+ public function testAddingTimeStampsTz()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->timestampsTz();
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+
+ $this->assertEquals(2, count($statements));
+ $expected = [
+ 'alter table "users" add column "created_at" datetime not null',
+ 'alter table "users" add column "updated_at" datetime not null',
+ ];
+ $this->assertEquals($expected, $statements);
+ }
+
public function testAddingRememberToken()
{
$blueprint = new Blueprint('users'); | true |
Other | laravel | framework | cc7ac2b81471b4084d1dfbf44851556e705fd927.json | Add timestampsTz function to schema blueprint | tests/Database/DatabaseSqlServerSchemaGrammarTest.php | @@ -114,6 +114,16 @@ public function testDropTimestamps()
$this->assertEquals('alter table "users" drop column "created_at", "updated_at"', $statements[0]);
}
+ public function testDropTimestampsTz()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->dropTimestampsTz();
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+
+ $this->assertEquals(1, count($statements));
+ $this->assertEquals('alter table "users" drop column "created_at", "updated_at"', $statements[0]);
+ }
+
public function testRenameTable()
{
$blueprint = new Blueprint('users');
@@ -422,6 +432,16 @@ public function testAddingTimeStamps()
$this->assertEquals('alter table "users" add "created_at" datetime not null, "updated_at" datetime not null', $statements[0]);
}
+ public function testAddingTimeStampsTz()
+ {
+ $blueprint = new Blueprint('users');
+ $blueprint->timestampsTz();
+ $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
+
+ $this->assertEquals(1, count($statements));
+ $this->assertEquals('alter table "users" add "created_at" datetimeoffset(0) not null, "updated_at" datetimeoffset(0) not null', $statements[0]);
+ }
+
public function testAddingRememberToken()
{
$blueprint = new Blueprint('users'); | true |
Other | laravel | framework | 35648aa3177f55c3eab3c72ff09b3bbc5c11f414.json | Use table variable in stubs | src/Illuminate/Queue/Console/stubs/failed_jobs.stub | @@ -12,7 +12,7 @@ class CreateFailedJobsTable extends Migration
*/
public function up()
{
- Schema::create('failed_jobs', function (Blueprint $table) {
+ Schema::create('{{table}}', function (Blueprint $table) {
$table->increments('id');
$table->text('connection');
$table->text('queue');
@@ -28,6 +28,6 @@ class CreateFailedJobsTable extends Migration
*/
public function down()
{
- Schema::drop('failed_jobs');
+ Schema::drop('{{table}}');
}
} | true |
Other | laravel | framework | 35648aa3177f55c3eab3c72ff09b3bbc5c11f414.json | Use table variable in stubs | src/Illuminate/Queue/Console/stubs/jobs.stub | @@ -12,7 +12,7 @@ class CreateJobsTable extends Migration
*/
public function up()
{
- Schema::create('jobs', function (Blueprint $table) {
+ Schema::create('{{table}}', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue');
$table->longText('payload');
@@ -31,6 +31,6 @@ class CreateJobsTable extends Migration
*/
public function down()
{
- Schema::drop('jobs');
+ Schema::drop('{{table}}');
}
} | true |
Other | laravel | framework | c158a2e80ed22740e7600e7cc2bd794d14ba886c.json | Add test to check passing $columns in paginate | tests/Database/DatabaseEloquentBuilderTest.php | @@ -214,6 +214,36 @@ public function testListsWithoutModelGetterJustReturnTheAttributesFoundInDatabas
$this->assertEquals(['bar', 'baz'], $builder->lists('name')->all());
}
+ public function testPaginatePassesColumnsToGetCountForPaginationMethod()
+ {
+ $totalItems = 100;
+ $itemsPerPage = 50;
+ $page = 1;
+ $database = 'SQLite';
+ $table = 'table';
+ $columns = [$table . '.column'];
+
+ $model = new EloquentBuilderTestNestedStub;
+
+ $this->mockConnectionForModel($model, $database);
+
+ $query = m::mock('Illuminate\Database\Query\Builder');
+ $query->shouldReceive('from')->once()->with($table);
+ $query->shouldReceive('forPage')->once()->with($page, $itemsPerPage)->andReturn($query);
+ $query->shouldReceive('get')->once()->andReturn($columns);
+
+ /**
+ * Add check that paginate method passes $columns param to getCountForPagination method
+ */
+ $query->shouldReceive('getCountForPagination')->once()->with($columns)->andReturn($totalItems);
+
+ $builder = new Builder($query);
+
+ $builder->setModel($model);
+
+ $builder->paginate($itemsPerPage, $columns);
+ }
+
public function testMacrosAreCalledOnBuilder()
{
unset($_SERVER['__test.builder']); | false |
Other | laravel | framework | 080d36af36189f54669c48a71cb6279e19808eb0.json | Collection::make empty array as default | src/Illuminate/Support/Collection.php | @@ -38,7 +38,7 @@ public function __construct($items = [])
* @param mixed $items
* @return static
*/
- public static function make($items = null)
+ public static function make($items = [])
{
return new static($items);
} | false |
Other | laravel | framework | 1d95529e3c98ab71eccae397da9e29ccaa53abd9.json | fix incorrect definition | src/Illuminate/Foundation/Console/VendorPublishCommand.php | @@ -24,8 +24,8 @@ class VendorPublishCommand extends Command
* @var string
*/
protected $signature = 'vendor:publish {--force : Overwrite any existing files.}
- {--provider? : The service provider that has assets you want to publish.}
- {--tag?* : One or many tags that have assets you want to publish.}';
+ {--provider= : The service provider that has assets you want to publish.}
+ {--tag=* : One or many tags that have assets you want to publish.}';
/**
* The console command description. | false |
Other | laravel | framework | 3f951978a53c965698cfced90ee201156b1697bf.json | Resolve route model binding through IoC | src/Illuminate/Routing/Router.php | @@ -940,7 +940,7 @@ public function model($key, $class, Closure $callback = null)
// 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
// throw a not found exception otherwise we will return the instance.
- $instance = new $class;
+ $instance = $this->container->make($class);
if ($model = $instance->where($instance->getRouteKeyName(), $value)->first()) {
return $model; | true |
Other | laravel | framework | 3f951978a53c965698cfced90ee201156b1697bf.json | Resolve route model binding through IoC | tests/Routing/RoutingRouteTest.php | @@ -3,6 +3,8 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Routing\Router;
+use Illuminate\Events\Dispatcher;
+use Illuminate\Container\Container;
use Symfony\Component\HttpFoundation\Response;
class RoutingRouteTest extends PHPUnit_Framework_TestCase
@@ -546,6 +548,16 @@ public function testModelBindingWithBindingClosure()
$this->assertEquals('tayloralt', $router->dispatch(Request::create('foo/TAYLOR', 'GET'))->getContent());
}
+ public function testModelBindingThroughIOC()
+ {
+ $router = new Router(new Dispatcher, $container = new Container);
+
+ $container->bind('RouteModelInterface', 'RouteModelBindingStub');
+ $router->get('foo/{bar}', function ($name) { return $name; });
+ $router->model('bar', 'RouteModelInterface');
+ $this->assertEquals('TAYLOR', $router->dispatch(Request::create('foo/taylor', 'GET'))->getContent());
+ }
+
public function testGroupMerging()
{
$old = ['prefix' => 'foo/bar/']; | true |
Other | laravel | framework | ef29f14656999bc4f841602ef271700b6561166c.json | remove superfluous newline | src/Illuminate/Database/Eloquent/Model.php | @@ -2849,7 +2849,6 @@ protected function asDateTime($value)
$format = $this->getDateFormat();
return Carbon::createFromFormat($format, $value);
-
}
/** | false |
Other | laravel | framework | 76674b8074b8e69a84022522e5678e0940af8895.json | Fix brittle test
This could fail in rare cases. | tests/Database/DatabaseEloquentRelationTest.php | @@ -30,8 +30,9 @@ public function testTouchMethodUpdatesRelatedTimestamps()
$relation = new HasOne($builder, $parent, 'foreign_key', 'id');
$related->shouldReceive('getTable')->andReturn('table');
$related->shouldReceive('getUpdatedAtColumn')->andReturn('updated_at');
- $related->shouldReceive('freshTimestampString')->andReturn(Carbon\Carbon::now());
- $builder->shouldReceive('update')->once()->with(['updated_at' => Carbon\Carbon::now()]);
+ $now = Carbon\Carbon::now();
+ $related->shouldReceive('freshTimestampString')->andReturn($now);
+ $builder->shouldReceive('update')->once()->with(['updated_at' => $now]);
$relation->touch();
} | false |
Other | laravel | framework | 37927a9f732097e484a67fac66b6aaee7dc61fef.json | Make username customizable during login. | src/Illuminate/Foundation/Auth/AuthenticatesUsers.php | @@ -29,7 +29,7 @@ public function getLogin()
public function postLogin(Request $request)
{
$this->validate($request, [
- 'email' => 'required|email', 'password' => 'required',
+ $this->loginUsername() => 'required', 'password' => 'required',
]);
$throttles = in_array(
@@ -53,9 +53,9 @@ public function postLogin(Request $request)
}
return redirect($this->loginPath())
- ->withInput($request->only('email', 'remember'))
+ ->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([
- 'email' => $this->getFailedLoginMessage(),
+ $this->loginUsername() => $this->getFailedLoginMessage(),
]);
}
@@ -67,7 +67,7 @@ public function postLogin(Request $request)
*/
protected function getCredentials(Request $request)
{
- return $request->only('email', 'password');
+ return $request->only($this->loginUsername(), 'password');
}
/**
@@ -101,4 +101,14 @@ public function loginPath()
{
return property_exists($this, 'loginPath') ? $this->loginPath : '/auth/login';
}
+
+ /**
+ * Get the login username to be used by the controller.
+ *
+ * @return string
+ */
+ public function loginUsername()
+ {
+ return property_exists($this, 'username') ? $this->username : 'email';
+ }
} | true |
Other | laravel | framework | 37927a9f732097e484a67fac66b6aaee7dc61fef.json | Make username customizable during login. | src/Illuminate/Foundation/Auth/ThrottlesLogins.php | @@ -61,9 +61,9 @@ protected function sendLockoutResponse(Request $request)
$seconds = (int) Cache::get($this->getLoginLockExpirationKey($request)) - time();
return redirect($this->loginPath())
- ->withInput($request->only('email', 'remember'))
+ ->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([
- 'email' => 'Too many login attempts. Please try again in '.$seconds.' seconds.',
+ $this->loginUsername() => 'Too many login attempts. Please try again in '.$seconds.' seconds.',
]);
}
@@ -88,7 +88,9 @@ protected function clearLoginAttempts(Request $request)
*/
protected function getLoginAttemptsKey(Request $request)
{
- return 'login:attempts:'.md5($request->email.$request->ip());
+ $username = $request->input($this->loginUsername());
+
+ return 'login:attempts:'.md5($username.$request->ip());
}
/**
@@ -99,6 +101,8 @@ protected function getLoginAttemptsKey(Request $request)
*/
protected function getLoginLockExpirationKey(Request $request)
{
- return 'login:expiration:'.md5($request->email.$request->ip());
+ $username = $request->input($this->loginUsername());
+
+ return 'login:expiration:'.md5($username.$request->ip());
}
} | true |
Other | laravel | framework | 8ebfc02b24ec8b59cd12f879e7d28d0aadfbbe91.json | add options to sort (and order) routes | src/Illuminate/Foundation/Console/RouteListCommand.php | @@ -89,6 +89,16 @@ protected function getRoutes()
$results[] = $this->getRouteInformation($route);
}
+ if ($sort = $this->option('sort')) {
+ $results = array_sort($results, function ($value) use ($sort) {
+ return $value[$sort];
+ });
+ }
+
+ if ($this->option('reverse')) {
+ $results = array_reverse($results);
+ }
+
return array_filter($results);
}
@@ -259,6 +269,10 @@ protected function getOptions()
['name', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by name.'],
['path', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by path.'],
+
+ ['reverse', 'r', InputOption::VALUE_NONE, 'Order descending alphabetically.'],
+
+ ['sort', null, InputOption::VALUE_OPTIONAL, 'The column (domain, method, uri, name, action, middleware) to sort by.', 'uri'],
];
}
} | false |
Other | laravel | framework | c238aac4a1e854594e3492b61115162b5360254d.json | pass $attributes through to factory definitions
Allow the factory definitions more knowledge about what is being created and what attributes are being overridden. | src/Illuminate/Database/Eloquent/FactoryBuilder.php | @@ -126,7 +126,7 @@ protected function makeInstance(array $attributes = [])
throw new InvalidArgumentException("Unable to locate factory with name [{$this->name}].");
}
- $definition = call_user_func($this->definitions[$this->class][$this->name], $this->faker);
+ $definition = call_user_func($this->definitions[$this->class][$this->name], $this->faker, $attributes);
return new $this->class(array_merge($definition, $attributes));
}); | false |
Other | laravel | framework | 23d6a793748de8b1394c1c5b3fa155ec265f995a.json | Add HTTP_ check | src/Illuminate/Foundation/Testing/CrawlerTrait.php | @@ -771,7 +771,9 @@ protected function transformHeadersToServerVars(array $headers)
$server = [];
foreach ($headers as $name => $value) {
- $name = 'HTTP_'.strtr(strtoupper($name), '-', '_');
+ if (!starts_with($name, 'HTTP_')) {
+ $name = 'HTTP_'.strtr(strtoupper($name), '-', '_');
+ }
$server[$name] = $value;
} | false |
Other | laravel | framework | fc063229a87ae38ea858067a5054895ac865874c.json | change some wording | src/Illuminate/Console/Scheduling/Event.php | @@ -83,7 +83,7 @@ class Event
* @var string
*/
public $output = '/dev/null';
-
+
/**
* The array of callbacks to be run before the event is started.
*
@@ -152,14 +152,14 @@ protected function runCommandInBackground()
protected function runCommandInForeground(Container $container)
{
$this->callBeforeCallbacks($container);
-
+
(new Process(
trim($this->buildCommand(), '& '), base_path(), null, null, null
))->run();
$this->callAfterCallbacks($container);
}
-
+
/**
* Call all of the "before" callbacks for the event.
*
@@ -683,16 +683,16 @@ protected function getEmailSubject()
return 'Scheduled Job Output';
}
-
+
/**
* Register a callback to ping a given URL before the job runs.
*
* @param string $url
* @return $this
*/
- public function firstPing($url)
+ public function pingBefore($url)
{
- return $this->first(function () use ($url) { (new HttpClient)->get($url); });
+ return $this->before(function () use ($url) { (new HttpClient)->get($url); });
}
/**
@@ -701,7 +701,7 @@ public function firstPing($url)
* @param \Closure $callback
* @return $this
*/
- public function first(Closure $callback)
+ public function before(Closure $callback)
{
$this->beforeCallbacks[] = $callback;
@@ -719,6 +719,17 @@ public function thenPing($url)
return $this->then(function () use ($url) { (new HttpClient)->get($url); });
}
+ /**
+ * Register a callback to be called after the operation.
+ *
+ * @param \Closure $callback
+ * @return $this
+ */
+ public function after(Closure $callback)
+ {
+ return $this->then($callback);
+ }
+
/**
* Register a callback to be called after the operation.
* | false |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Auth/DatabaseUserProvider.php | @@ -2,6 +2,7 @@
namespace Illuminate\Auth;
+use Illuminate\Support\Str;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
@@ -103,7 +104,7 @@ public function retrieveByCredentials(array $credentials)
$query = $this->conn->table($this->table);
foreach ($credentials as $key => $value) {
- if (!str_contains($key, 'password')) {
+ if (!Str::contains($key, 'password')) {
$query->where($key, $value);
}
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Auth/EloquentUserProvider.php | @@ -2,6 +2,7 @@
namespace Illuminate\Auth;
+use Illuminate\Support\Str;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
@@ -91,7 +92,7 @@ public function retrieveByCredentials(array $credentials)
$query = $this->createModel()->newQuery();
foreach ($credentials as $key => $value) {
- if (!str_contains($key, 'password')) {
+ if (!Str::contains($key, 'password')) {
$query->where($key, $value);
}
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Auth/Guard.php | @@ -3,6 +3,7 @@
namespace Illuminate\Auth;
use RuntimeException;
+use Illuminate\Support\Str;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Auth\UserProvider;
use Symfony\Component\HttpFoundation\Request;
@@ -237,7 +238,7 @@ protected function getRecallerId()
*/
protected function validRecaller($recaller)
{
- if (!is_string($recaller) || !str_contains($recaller, '|')) {
+ if (!is_string($recaller) || !Str::contains($recaller, '|')) {
return false;
}
@@ -583,7 +584,7 @@ protected function clearUserDataFromStorage()
*/
protected function refreshRememberToken(UserContract $user)
{
- $user->setRememberToken($token = str_random(60));
+ $user->setRememberToken($token = Str::random(60));
$this->provider->updateRememberToken($user, $token);
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php | @@ -3,6 +3,7 @@
namespace Illuminate\Auth\Passwords;
use Carbon\Carbon;
+use Illuminate\Support\Str;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
@@ -167,7 +168,7 @@ public function deleteExpired()
*/
public function createNewToken()
{
- return hash_hmac('sha256', str_random(40), $this->hashKey);
+ return hash_hmac('sha256', Str::random(40), $this->hashKey);
}
/** | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Console/GeneratorCommand.php | @@ -2,6 +2,7 @@
namespace Illuminate\Console;
+use Illuminate\Support\Str;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputArgument;
@@ -86,11 +87,11 @@ protected function parseName($name)
{
$rootNamespace = $this->laravel->getNamespace();
- if (starts_with($name, $rootNamespace)) {
+ if (Str::startsWith($name, $rootNamespace)) {
return $name;
}
- if (str_contains($name, '/')) {
+ if (Str::contains($name, '/')) {
$name = str_replace('/', '\\', $name);
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Console/Parser.php | @@ -2,6 +2,7 @@
namespace Illuminate\Console;
+use Illuminate\Support\Str;
use InvalidArgumentException;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
@@ -46,7 +47,7 @@ public static function parse($expression)
protected static function arguments(array $tokens)
{
return array_values(array_filter(array_map(function ($token) {
- if (starts_with($token, '{') && !starts_with($token, '{--')) {
+ if (Str::startsWith($token, '{') && !Str::startsWith($token, '{--')) {
return static::parseArgument(trim($token, '{}'));
}
}, $tokens)));
@@ -61,7 +62,7 @@ protected static function arguments(array $tokens)
protected static function options(array $tokens)
{
return array_values(array_filter(array_map(function ($token) {
- if (starts_with($token, '{--')) {
+ if (Str::startsWith($token, '{--')) {
return static::parseOption(ltrim(trim($token, '{}'), '-'));
}
}, $tokens)));
@@ -77,7 +78,7 @@ protected static function parseArgument($token)
{
$description = null;
- if (str_contains($token, ' : ')) {
+ if (Str::contains($token, ' : ')) {
list($token, $description) = explode(' : ', $token, 2);
$token = trim($token);
@@ -113,7 +114,7 @@ protected static function parseOption($token)
{
$description = null;
- if (str_contains($token, ' : ')) {
+ if (Str::contains($token, ' : ')) {
list($token, $description) = explode(' : ', $token);
$token = trim($token); | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Database/Connection.php | @@ -9,6 +9,7 @@
use LogicException;
use RuntimeException;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Database\Query\Expression;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\Query\Processors\Processor;
@@ -667,7 +668,7 @@ protected function causedByLostConnection(QueryException $e)
{
$message = $e->getPrevious()->getMessage();
- return str_contains($message, [
+ return Str::contains($message, [
'server has gone away',
'no connection to the server',
'Lost connection', | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Database/Eloquent/Builder.php | @@ -4,6 +4,7 @@
use Closure;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Pagination\Paginator;
use Illuminate\Database\Query\Expression;
use Illuminate\Pagination\LengthAwarePaginator;
@@ -516,9 +517,9 @@ protected function nestedRelations($relation)
*/
protected function isNested($name, $relation)
{
- $dots = str_contains($name, '.');
+ $dots = Str::contains($name, '.');
- return $dots && starts_with($name, $relation.'.');
+ return $dots && Str::startsWith($name, $relation.'.');
}
/** | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Database/Eloquent/Model.php | @@ -9,6 +9,7 @@
use LogicException;
use JsonSerializable;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Support\Arrayable;
@@ -782,7 +783,7 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat
// foreign key name by using the name of the relationship function, which
// when combined with an "_id" should conventionally match the columns.
if (is_null($foreignKey)) {
- $foreignKey = snake_case($relation).'_id';
+ $foreignKey = Str::snake($relation).'_id';
}
$instance = new $related;
@@ -813,7 +814,7 @@ public function morphTo($name = null, $type = null, $id = null)
if (is_null($name)) {
list(, $caller) = debug_backtrace(false, 2);
- $name = snake_case($caller['function']);
+ $name = Str::snake($caller['function']);
}
list($type, $id) = $this->getMorphs($name, $type, $id);
@@ -978,7 +979,7 @@ public function morphToMany($related, $name, $table = null, $foreignKey = null,
// appropriate query constraints then entirely manages the hydrations.
$query = $instance->newQuery();
- $table = $table ?: str_plural($name);
+ $table = $table ?: Str::plural($name);
return new MorphToMany(
$query, $this, $name, $table, $foreignKey,
@@ -1037,9 +1038,9 @@ public function joiningTable($related)
// The joining table name, by convention, is simply the snake cased models
// sorted alphabetically and concatenated with an underscore, so we can
// just sort the models and join them together to get the table name.
- $base = snake_case(class_basename($this));
+ $base = Str::snake(class_basename($this));
- $related = snake_case(class_basename($related));
+ $related = Str::snake(class_basename($related));
$models = [$related, $base];
@@ -1893,7 +1894,7 @@ public function getTable()
return $this->table;
}
- return str_replace('\\', '', snake_case(str_plural(class_basename($this))));
+ return str_replace('\\', '', Str::snake(Str::plural(class_basename($this))));
}
/**
@@ -2043,7 +2044,7 @@ public function setPerPage($perPage)
*/
public function getForeignKey()
{
- return snake_case(class_basename($this)).'_id';
+ return Str::snake(class_basename($this)).'_id';
}
/**
@@ -2246,7 +2247,7 @@ public function isFillable($key)
return false;
}
- return empty($this->fillable) && !starts_with($key, '_');
+ return empty($this->fillable) && !Str::startsWith($key, '_');
}
/**
@@ -2278,7 +2279,7 @@ public function totallyGuarded()
*/
protected function removeTableFromKey($key)
{
- if (!str_contains($key, '.')) {
+ if (!Str::contains($key, '.')) {
return $key;
}
@@ -2481,7 +2482,7 @@ public function relationsToArray()
// key so that the relation attribute is snake cased in this returned
// array to the developers, making this consistent with attributes.
if (static::$snakeAttributes) {
- $key = snake_case($key);
+ $key = Str::snake($key);
}
// If the relation value has been set, we will set it on this attributes
@@ -2637,7 +2638,7 @@ protected function getRelationshipFromMethod($method)
*/
public function hasGetMutator($key)
{
- return method_exists($this, 'get'.studly_case($key).'Attribute');
+ return method_exists($this, 'get'.Str::studly($key).'Attribute');
}
/**
@@ -2649,7 +2650,7 @@ public function hasGetMutator($key)
*/
protected function mutateAttribute($key, $value)
{
- return $this->{'get'.studly_case($key).'Attribute'}($value);
+ return $this->{'get'.Str::studly($key).'Attribute'}($value);
}
/**
@@ -2756,7 +2757,7 @@ public function setAttribute($key, $value)
// which simply lets the developers tweak the attribute as it is set on
// the model, such as "json_encoding" an listing of data for storage.
if ($this->hasSetMutator($key)) {
- $method = 'set'.studly_case($key).'Attribute';
+ $method = 'set'.Str::studly($key).'Attribute';
return $this->{$method}($value);
}
@@ -2783,7 +2784,7 @@ public function setAttribute($key, $value)
*/
public function hasSetMutator($key)
{
- return method_exists($this, 'set'.studly_case($key).'Attribute');
+ return method_exists($this, 'set'.Str::studly($key).'Attribute');
}
/**
@@ -3233,7 +3234,7 @@ public static function cacheMutatedAttributes($class)
if (strpos($method, 'Attribute') !== false &&
preg_match('/^get(.+)Attribute$/', $method, $matches)) {
if (static::$snakeAttributes) {
- $matches[1] = snake_case($matches[1]);
+ $matches[1] = Str::snake($matches[1]);
}
$mutatedAttributes[] = lcfirst($matches[1]); | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | @@ -3,6 +3,7 @@
namespace Illuminate\Database\Eloquent\Relations;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Expression;
@@ -1047,7 +1048,7 @@ protected function touchingParent()
*/
protected function guessInverseRelation()
{
- return camel_case(str_plural(class_basename($this->getParent())));
+ return Str::camel(Str::plural(class_basename($this->getParent())));
}
/** | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Database/Migrations/MigrationCreator.php | @@ -3,6 +3,7 @@
namespace Illuminate\Database\Migrations;
use Closure;
+use Illuminate\Support\Str;
use Illuminate\Filesystem\Filesystem;
class MigrationCreator
@@ -110,7 +111,7 @@ protected function populateStub($name, $stub, $table)
*/
protected function getClassName($name)
{
- return studly_case($name);
+ return Str::studly($name);
}
/** | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Database/Migrations/Migrator.php | @@ -2,6 +2,7 @@
namespace Illuminate\Database\Migrations;
+use Illuminate\Support\Str;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
@@ -318,7 +319,7 @@ public function resolve($file)
{
$file = implode('_', array_slice(explode('_', $file), 4));
- $class = studly_case($file);
+ $class = Str::studly($file);
return new $class;
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Database/Query/Builder.php | @@ -5,6 +5,7 @@
use Closure;
use BadMethodCallException;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use InvalidArgumentException;
use Illuminate\Support\Collection;
use Illuminate\Pagination\Paginator;
@@ -1008,7 +1009,7 @@ protected function addDynamic($segment, $connector, $parameters, $index)
// clause on the query. Then we'll increment the parameter index values.
$bool = strtolower($connector);
- $this->where(snake_case($segment), '=', $parameters[$index], $bool);
+ $this->where(Str::snake($segment), '=', $parameters[$index], $bool);
}
/**
@@ -1984,7 +1985,7 @@ public function useWritePdo()
*/
public function __call($method, $parameters)
{
- if (starts_with($method, 'where')) {
+ if (Str::startsWith($method, 'where')) {
return $this->dynamicWhere($method, $parameters);
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Events/Dispatcher.php | @@ -4,6 +4,7 @@
use Exception;
use ReflectionClass;
+use Illuminate\Support\Str;
use Illuminate\Container\Container;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
@@ -76,7 +77,7 @@ public function __construct(ContainerContract $container = null)
public function listen($events, $listener, $priority = 0)
{
foreach ((array) $events as $event) {
- if (str_contains($event, '*')) {
+ if (Str::contains($event, '*')) {
$this->setupWildcardListen($event, $listener);
} else {
$this->listeners[$event][$priority][] = $this->makeListener($listener);
@@ -288,7 +289,7 @@ protected function getWildcardListeners($eventName)
$wildcards = [];
foreach ($this->wildcards as $key => $listeners) {
- if (str_is($key, $eventName)) {
+ if (Str::is($key, $eventName)) {
$wildcards = array_merge($wildcards, $listeners);
}
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Foundation/Application.php | @@ -5,6 +5,7 @@
use Closure;
use RuntimeException;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
@@ -439,7 +440,7 @@ public function environment()
$patterns = is_array(func_get_arg(0)) ? func_get_arg(0) : func_get_args();
foreach ($patterns as $pattern) {
- if (str_is($pattern, $this['env'])) {
+ if (Str::is($pattern, $this['env'])) {
return true;
}
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Foundation/Console/EventGenerateCommand.php | @@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Console;
+use Illuminate\Support\Str;
use Illuminate\Console\Command;
class EventGenerateCommand extends Command
@@ -32,7 +33,7 @@ public function fire()
);
foreach ($provider->listens() as $event => $listeners) {
- if (!str_contains($event, '\\')) {
+ if (!Str::contains($event, '\\')) {
continue;
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Foundation/Console/HandlerEventCommand.php | @@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Console;
+use Illuminate\Support\Str;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
@@ -40,7 +41,7 @@ protected function buildClass($name)
$event = $this->option('event');
- if (!starts_with($event, $this->laravel->getNamespace())) {
+ if (!Str::startsWith($event, $this->laravel->getNamespace())) {
$event = $this->laravel->getNamespace().'Events\\'.$event;
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Foundation/Console/KeyGenerateCommand.php | @@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Console;
+use Illuminate\Support\Str;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
@@ -56,10 +57,10 @@ public function fire()
protected function getRandomKey($cipher)
{
if ($cipher === 'AES-128-CBC') {
- return str_random(16);
+ return Str::random(16);
}
- return str_random(32);
+ return Str::random(32);
}
/** | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Foundation/Console/ListenerMakeCommand.php | @@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Console;
+use Illuminate\Support\Str;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
@@ -40,7 +41,7 @@ protected function buildClass($name)
$event = $this->option('event');
- if (!starts_with($event, $this->laravel->getNamespace())) {
+ if (!Str::startsWith($event, $this->laravel->getNamespace())) {
$event = $this->laravel->getNamespace().'Events\\'.$event;
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Foundation/Console/ModelMakeCommand.php | @@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Console;
+use Illuminate\Support\Str;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
@@ -37,7 +38,7 @@ public function fire()
{
if (parent::fire() !== false) {
if ($this->option('migration')) {
- $table = str_plural(snake_case(class_basename($this->argument('name'))));
+ $table = Str::plural(Str::snake(class_basename($this->argument('name'))));
$this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Foundation/Console/RouteListCommand.php | @@ -3,6 +3,7 @@
namespace Illuminate\Foundation\Console;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Routing\Router;
@@ -239,8 +240,8 @@ protected function getMethodPatterns($uri, $method)
*/
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'))) {
+ if (($this->option('name') && !Str::contains($route['name'], $this->option('name'))) ||
+ $this->option('path') && !Str::contains($route['uri'], $this->option('path'))) {
return;
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Foundation/EnvironmentDetector.php | @@ -4,6 +4,7 @@
use Closure;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
class EnvironmentDetector
{
@@ -62,7 +63,7 @@ protected function detectConsoleEnvironment(Closure $callback, array $args)
protected function getEnvironmentArgument(array $args)
{
return Arr::first($args, function ($k, $v) {
- return starts_with($v, '--env');
+ return Str::startsWith($v, '--env');
});
}
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Foundation/Testing/CrawlerTrait.php | @@ -2,6 +2,7 @@
namespace Illuminate\Foundation\Testing;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use InvalidArgumentException;
use Symfony\Component\DomCrawler\Form;
@@ -325,7 +326,7 @@ protected function seeJsonContains(array $data)
$expected = $this->formatToExpectedJson($key, $value);
$this->assertTrue(
- str_contains($actual, $this->formatToExpectedJson($key, $value)),
+ Str::contains($actual, $this->formatToExpectedJson($key, $value)),
"Unable to find JSON fragment [{$expected}] within [{$actual}]."
);
}
@@ -344,7 +345,7 @@ protected function formatToExpectedJson($key, $value)
{
$expected = json_encode([$key => $value]);
- if (starts_with($expected, '{')) {
+ if (Str::startsWith($expected, '{')) {
$expected = substr($expected, 1);
}
@@ -738,11 +739,11 @@ public function route($method, $name, $routeParameters = [], $parameters = [], $
*/
protected function prepareUrlForRequest($uri)
{
- if (starts_with($uri, '/')) {
+ if (Str::startsWith($uri, '/')) {
$uri = substr($uri, 1);
}
- if (!starts_with($uri, 'http')) {
+ if (!Str::startsWith($uri, 'http')) {
$uri = $this->baseUrl.'/'.$uri;
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Http/RedirectResponse.php | @@ -3,6 +3,7 @@
namespace Illuminate\Http;
use BadMethodCallException;
+use Illuminate\Support\Str;
use Illuminate\Support\MessageBag;
use Illuminate\Support\ViewErrorBag;
use Illuminate\Session\Store as SessionStore;
@@ -190,8 +191,8 @@ public function setSession(SessionStore $session)
*/
public function __call($method, $parameters)
{
- if (starts_with($method, 'with')) {
- return $this->with(snake_case(substr($method, 4)), $parameters[0]);
+ if (Str::startsWith($method, 'with')) {
+ return $this->with(Str::snake(substr($method, 4)), $parameters[0]);
}
throw new BadMethodCallException("Method [$method] does not exist on Redirect."); | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Http/Request.php | @@ -7,6 +7,7 @@
use SplFileInfo;
use RuntimeException;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
@@ -152,7 +153,7 @@ public function segments()
public function is()
{
foreach (func_get_args() as $pattern) {
- if (str_is($pattern, urldecode($this->path()))) {
+ if (Str::is($pattern, urldecode($this->path()))) {
return true;
}
}
@@ -572,7 +573,7 @@ protected function getInputSource()
*/
public function isJson()
{
- return str_contains($this->header('CONTENT_TYPE'), '/json');
+ return Str::contains($this->header('CONTENT_TYPE'), '/json');
}
/** | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Mail/Mailer.php | @@ -6,6 +6,7 @@
use Swift_Mailer;
use Swift_Message;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use SuperClosure\Serializer;
use Psr\Log\LoggerInterface;
use InvalidArgumentException;
@@ -286,7 +287,7 @@ public function handleQueuedMessage($job, $data)
*/
protected function getQueuedCallable(array $data)
{
- if (str_contains($data['callback'], 'SerializableClosure')) {
+ if (Str::contains($data['callback'], 'SerializableClosure')) {
return unserialize($data['callback'])->getClosure();
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Queue/Console/SubscribeCommand.php | @@ -4,6 +4,7 @@
use Exception;
use RuntimeException;
+use Illuminate\Support\Str;
use Illuminate\Queue\IronQueue;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
@@ -96,7 +97,7 @@ protected function getSubscriberList()
$url = $this->argument('url');
- if (!starts_with($url, ['http://', 'https://'])) {
+ if (!Str::startsWith($url, ['http://', 'https://'])) {
$url = $this->laravel['url']->to($url);
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Queue/Jobs/Job.php | @@ -3,6 +3,7 @@
namespace Illuminate\Queue\Jobs;
use DateTime;
+use Illuminate\Support\Str;
abstract class Job
{
@@ -179,7 +180,7 @@ protected function resolveQueueableEntities($data)
*/
protected function resolveQueueableEntity($value)
{
- if (is_string($value) && starts_with($value, '::entity::')) {
+ if (is_string($value) && Str::startsWith($value, '::entity::')) {
list($marker, $type, $id) = explode('|', $value, 3);
return $this->getEntityResolver()->resolve($type, $id); | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Queue/RedisQueue.php | @@ -3,6 +3,7 @@
namespace Illuminate\Queue;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Redis\Database;
use Illuminate\Queue\Jobs\RedisJob;
use Illuminate\Contracts\Queue\Queue as QueueContract;
@@ -261,7 +262,7 @@ protected function createPayload($job, $data = '', $queue = null)
*/
protected function getRandomId()
{
- return str_random(32);
+ return Str::random(32);
}
/** | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Routing/Controller.php | @@ -4,6 +4,7 @@
use Closure;
use BadMethodCallException;
+use Illuminate\Support\Str;
use InvalidArgumentException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -137,7 +138,7 @@ protected function registerInstanceFilter($filter)
*/
protected function isInstanceFilter($filter)
{
- if (is_string($filter) && starts_with($filter, '@')) {
+ if (is_string($filter) && Str::startsWith($filter, '@')) {
if (method_exists($this, substr($filter, 1))) {
return true;
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Routing/ControllerInspector.php | @@ -4,6 +4,7 @@
use ReflectionClass;
use ReflectionMethod;
+use Illuminate\Support\Str;
class ControllerInspector
{
@@ -65,7 +66,7 @@ public function isRoutable(ReflectionMethod $method)
return false;
}
- return starts_with($method->name, $this->verbs);
+ return Str::startsWith($method->name, $this->verbs);
}
/**
@@ -104,7 +105,7 @@ protected function getIndexData($data, $prefix)
*/
public function getVerb($name)
{
- return head(explode('_', snake_case($name)));
+ return head(explode('_', Str::snake($name)));
}
/**
@@ -116,7 +117,7 @@ public function getVerb($name)
*/
public function getPlainUri($name, $prefix)
{
- return $prefix.'/'.implode('-', array_slice(explode('_', snake_case($name)), 1));
+ return $prefix.'/'.implode('-', array_slice(explode('_', Str::snake($name)), 1));
}
/** | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Routing/ResourceRegistrar.php | @@ -2,6 +2,8 @@
namespace Illuminate\Routing;
+use Illuminate\Support\Str;
+
class ResourceRegistrar
{
/**
@@ -42,7 +44,7 @@ public function register($name, $controller, array $options = [])
// 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, '/')) {
+ if (Str::contains($name, '/')) {
$this->prefixedResource($name, $controller, $options);
return;
@@ -126,7 +128,7 @@ protected function getResourceMethods($defaults, $options)
*/
public function getResourceUri($resource)
{
- if (!str_contains($resource, '.')) {
+ if (!Str::contains($resource, '.')) {
return $resource;
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Routing/Route.php | @@ -6,6 +6,7 @@
use LogicException;
use ReflectionFunction;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use UnexpectedValueException;
use Illuminate\Container\Container;
@@ -353,7 +354,7 @@ protected static function explodeArrayFilters(array $filters)
*/
public static function parseFilter($filter)
{
- if (!str_contains($filter, ':')) {
+ if (!Str::contains($filter, ':')) {
return [$filter, []];
}
@@ -619,7 +620,7 @@ protected function parseAction($action)
$action['uses'] = $this->findCallable($action);
}
- if (is_string($action['uses']) && ! str_contains($action['uses'], '@')) {
+ if (is_string($action['uses']) && ! Str::contains($action['uses'], '@')) {
throw new UnexpectedValueException(sprintf(
'Invalid route action: [%s]', $action['uses']
)); | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Routing/Router.php | @@ -4,6 +4,7 @@
use Closure;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Pipeline\Pipeline;
@@ -874,7 +875,7 @@ public function filter($name, $callback)
*/
protected function parseFilter($callback)
{
- if (is_string($callback) && !str_contains($callback, '@')) {
+ if (is_string($callback) && !Str::contains($callback, '@')) {
return $callback.'@filter';
}
@@ -1082,7 +1083,7 @@ public function findPatternFilters($request)
// To find the patterned middlewares for a request, we just need to check these
// registered patterns against the path info for the current request to this
// applications, and when it matches we will merge into these middlewares.
- if (str_is($pattern, $path)) {
+ if (Str::is($pattern, $path)) {
$merge = $this->patternsByMethod($method, $filters);
$results = array_merge($results, $merge);
@@ -1309,7 +1310,7 @@ public function currentRouteName()
public function is()
{
foreach (func_get_args() as $pattern) {
- if (str_is($pattern, $this->currentRouteName())) {
+ if (Str::is($pattern, $this->currentRouteName())) {
return true;
}
}
@@ -1353,7 +1354,7 @@ public function currentRouteAction()
public function uses()
{
foreach (func_get_args() as $pattern) {
- if (str_is($pattern, $this->currentRouteAction())) {
+ if (Str::is($pattern, $this->currentRouteAction())) {
return true;
}
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Routing/UrlGenerator.php | @@ -3,6 +3,7 @@
namespace Illuminate\Routing;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use Illuminate\Http\Request;
use InvalidArgumentException;
use Illuminate\Contracts\Routing\UrlRoutable;
@@ -212,7 +213,7 @@ protected function removeIndex($root)
{
$i = 'index.php';
- return str_contains($root, $i) ? str_replace('/'.$i, '', $root) : $root;
+ return Str::contains($root, $i) ? str_replace('/'.$i, '', $root) : $root;
}
/**
@@ -574,7 +575,7 @@ protected function getRootUrl($scheme, $root = null)
$root = $this->cachedRoot;
}
- $start = starts_with($root, 'http://') ? 'http://' : 'https://';
+ $start = Str::startsWith($root, 'http://') ? 'http://' : 'https://';
return preg_replace('~'.$start.'~', $scheme, $root, 1);
}
@@ -599,7 +600,7 @@ public function forceRootUrl($root)
*/
public function isValidUrl($path)
{
- if (starts_with($path, ['#', '//', 'mailto:', 'tel:', 'http://', 'https://'])) {
+ if (Str::startsWith($path, ['#', '//', 'mailto:', 'tel:', 'http://', 'https://'])) {
return true;
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Session/Store.php | @@ -3,6 +3,7 @@
namespace Illuminate\Session;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use SessionHandlerInterface;
use InvalidArgumentException;
use Symfony\Component\HttpFoundation\Request;
@@ -193,7 +194,7 @@ public function isValidId($id)
*/
protected function generateSessionId()
{
- return sha1(uniqid('', true).str_random(25).microtime(true));
+ return sha1(uniqid('', true).Str::random(25).microtime(true));
}
/**
@@ -609,7 +610,7 @@ public function getToken()
*/
public function regenerateToken()
{
- $this->put('_token', str_random(40));
+ $this->put('_token', Str::random(40));
}
/** | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Validation/Factory.php | @@ -3,6 +3,7 @@
namespace Illuminate\Validation;
use Closure;
+use Illuminate\Support\Str;
use Illuminate\Contracts\Container\Container;
use Symfony\Component\Translation\TranslatorInterface;
use Illuminate\Contracts\Validation\Factory as FactoryContract;
@@ -163,7 +164,7 @@ public function extend($rule, $extension, $message = null)
$this->extensions[$rule] = $extension;
if ($message) {
- $this->fallbackMessages[snake_case($rule)] = $message;
+ $this->fallbackMessages[Str::snake($rule)] = $message;
}
}
@@ -180,7 +181,7 @@ public function extendImplicit($rule, $extension, $message = null)
$this->implicitExtensions[$rule] = $extension;
if ($message) {
- $this->fallbackMessages[snake_case($rule)] = $message;
+ $this->fallbackMessages[Str::snake($rule)] = $message;
}
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/Validation/Validator.php | @@ -9,6 +9,7 @@
use DateTimeZone;
use RuntimeException;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use BadMethodCallException;
use InvalidArgumentException;
use Illuminate\Support\Fluent;
@@ -1040,7 +1041,7 @@ protected function validateUnique($attribute, $value, $parameters)
*/
protected function parseUniqueTable($table)
{
- return str_contains($table, '.') ? explode('.', $table, 2) : [null, $table];
+ return Str::contains($table, '.') ? explode('.', $table, 2) : [null, $table];
}
/**
@@ -1503,7 +1504,7 @@ protected function getDateFormat($attribute)
*/
protected function getMessage($attribute, $rule)
{
- $lowerRule = snake_case($rule);
+ $lowerRule = Str::snake($rule);
$inlineMessage = $this->getInlineMessage($attribute, $lowerRule);
@@ -1579,7 +1580,7 @@ protected function getInlineMessage($attribute, $lowerRule, $source = null)
*/
protected function getSizeMessage($attribute, $rule)
{
- $lowerRule = snake_case($rule);
+ $lowerRule = Str::snake($rule);
// There are three different types of size validations. The attribute may be
// either a number, file, or string so we will check a few things to know
@@ -1626,8 +1627,8 @@ protected function doReplacements($message, $attribute, $rule, $parameters)
{
$message = str_replace(':attribute', $this->getAttribute($attribute), $message);
- if (isset($this->replacers[snake_case($rule)])) {
- $message = $this->callReplacer($message, $attribute, snake_case($rule), $parameters);
+ if (isset($this->replacers[Str::snake($rule)])) {
+ $message = $this->callReplacer($message, $attribute, Str::snake($rule), $parameters);
} elseif (method_exists($this, $replacer = "replace{$rule}")) {
$message = $this->$replacer($message, $attribute, $rule, $parameters);
}
@@ -1682,7 +1683,7 @@ protected function getAttribute($attribute)
// If no language line has been specified for the attribute all of the
// underscores are removed from the attribute name and that will be
// used as default versions of the attribute's displayable names.
- return str_replace('_', ' ', snake_case($attribute));
+ return str_replace('_', ' ', Str::snake($attribute));
}
/**
@@ -2046,7 +2047,7 @@ protected function parseRule($rules)
*/
protected function parseArrayRule(array $rules)
{
- return [studly_case(trim(Arr::get($rules, 0))), array_slice($rules, 1)];
+ return [Str::studly(trim(Arr::get($rules, 0))), array_slice($rules, 1)];
}
/**
@@ -2068,7 +2069,7 @@ protected function parseStringRule($rules)
$parameters = $this->parseParameters($rules, $parameter);
}
- return [studly_case(trim($rules)), $parameters];
+ return [Str::studly(trim($rules)), $parameters];
}
/**
@@ -2106,7 +2107,7 @@ public function getExtensions()
public function addExtensions(array $extensions)
{
if ($extensions) {
- $keys = array_map('snake_case', array_keys($extensions));
+ $keys = array_map('\Illuminate\Support\Str::snake', array_keys($extensions));
$extensions = array_combine($keys, array_values($extensions));
}
@@ -2125,7 +2126,7 @@ public function addImplicitExtensions(array $extensions)
$this->addExtensions($extensions);
foreach ($extensions as $rule => $extension) {
- $this->implicitRules[] = studly_case($rule);
+ $this->implicitRules[] = Str::studly($rule);
}
}
@@ -2138,7 +2139,7 @@ public function addImplicitExtensions(array $extensions)
*/
public function addExtension($rule, $extension)
{
- $this->extensions[snake_case($rule)] = $extension;
+ $this->extensions[Str::snake($rule)] = $extension;
}
/**
@@ -2152,7 +2153,7 @@ public function addImplicitExtension($rule, $extension)
{
$this->addExtension($rule, $extension);
- $this->implicitRules[] = studly_case($rule);
+ $this->implicitRules[] = Str::studly($rule);
}
/**
@@ -2174,7 +2175,7 @@ public function getReplacers()
public function addReplacers(array $replacers)
{
if ($replacers) {
- $keys = array_map('snake_case', array_keys($replacers));
+ $keys = array_map('\Illuminate\Support\Str::snake', array_keys($replacers));
$replacers = array_combine($keys, array_values($replacers));
}
@@ -2191,7 +2192,7 @@ public function addReplacers(array $replacers)
*/
public function addReplacer($rule, $replacer)
{
- $this->replacers[snake_case($rule)] = $replacer;
+ $this->replacers[Str::snake($rule)] = $replacer;
}
/**
@@ -2574,7 +2575,7 @@ protected function requireParameterCount($count, $parameters, $rule)
*/
public function __call($method, $parameters)
{
- $rule = snake_case(substr($method, 8));
+ $rule = Str::snake(substr($method, 8));
if (isset($this->extensions[$rule])) {
return $this->callExtension($rule, $parameters); | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -3,6 +3,7 @@
namespace Illuminate\View\Compilers;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
class BladeCompiler extends Compiler implements CompilerInterface
{
@@ -647,7 +648,7 @@ protected function compileEndforelse($expression)
*/
protected function compileExtends($expression)
{
- if (starts_with($expression, '(')) {
+ if (Str::startsWith($expression, '(')) {
$expression = substr($expression, 1, -1);
}
@@ -666,7 +667,7 @@ protected function compileExtends($expression)
*/
protected function compileInclude($expression)
{
- if (starts_with($expression, '(')) {
+ if (Str::startsWith($expression, '(')) {
$expression = substr($expression, 1, -1);
}
| true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/View/Factory.php | @@ -4,6 +4,7 @@
use Closure;
use Illuminate\Support\Arr;
+use Illuminate\Support\Str;
use InvalidArgumentException;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\View\Engines\EngineResolver;
@@ -268,7 +269,7 @@ public function renderEach($view, $data, $iterator, $empty = 'raw|')
// view. Alternatively, the "empty view" could be a raw string that begins
// with "raw|" for convenience and to let this know that it is a string.
else {
- if (starts_with($empty, 'raw|')) {
+ if (Str::startsWith($empty, 'raw|')) {
$result = substr($empty, 4);
} else {
$result = $this->make($empty)->render();
@@ -476,11 +477,11 @@ protected function buildClassEventCallback($class, $prefix)
*/
protected function parseClassEvent($class, $prefix)
{
- if (str_contains($class, '@')) {
+ if (Str::contains($class, '@')) {
return explode('@', $class);
}
- $method = str_contains($prefix, 'composing') ? 'compose' : 'create';
+ $method = Str::contains($prefix, 'composing') ? 'compose' : 'create';
return [$class, $method];
} | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | src/Illuminate/View/View.php | @@ -5,6 +5,7 @@
use Closure;
use ArrayAccess;
use BadMethodCallException;
+use Illuminate\Support\Str;
use Illuminate\Support\MessageBag;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\View\Engines\EngineInterface;
@@ -375,8 +376,8 @@ public function __unset($key)
*/
public function __call($method, $parameters)
{
- if (starts_with($method, 'with')) {
- return $this->with(snake_case(substr($method, 4)), $parameters[0]);
+ if (Str::startsWith($method, 'with')) {
+ return $this->with(Str::snake(substr($method, 4)), $parameters[0]);
}
throw new BadMethodCallException("Method [$method] does not exist on view."); | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | tests/Encryption/EncrypterTest.php | @@ -1,5 +1,6 @@
<?php
+use Illuminate\Support\Str;
use Illuminate\Encryption\Encrypter;
class EncrypterTest extends PHPUnit_Framework_TestCase
@@ -81,7 +82,7 @@ public function testExceptionThrownWithDifferentKey()
public function testOpenSslEncrypterCanDecryptMcryptedData()
{
- $key = str_random(32);
+ $key = Str::random(32);
$encrypter = new Illuminate\Encryption\McryptEncrypter($key);
$encrypted = $encrypter->encrypt('foo');
$openSslEncrypter = new Illuminate\Encryption\Encrypter($key, 'AES-256-CBC'); | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | tests/Support/SupportHelpersTest.php | @@ -1,6 +1,7 @@
<?php
use Mockery as m;
+use Illuminate\Support\Str;
class SupportHelpersTest extends PHPUnit_Framework_TestCase
{
@@ -170,32 +171,32 @@ public function testArrayFlatten()
public function testStrIs()
{
- $this->assertTrue(str_is('*.dev', 'localhost.dev'));
- $this->assertTrue(str_is('a', 'a'));
- $this->assertTrue(str_is('/', '/'));
- $this->assertTrue(str_is('*dev*', 'localhost.dev'));
- $this->assertTrue(str_is('foo?bar', 'foo?bar'));
- $this->assertFalse(str_is('*something', 'foobar'));
- $this->assertFalse(str_is('foo', 'bar'));
- $this->assertFalse(str_is('foo.*', 'foobar'));
- $this->assertFalse(str_is('foo.ar', 'foobar'));
- $this->assertFalse(str_is('foo?bar', 'foobar'));
- $this->assertFalse(str_is('foo?bar', 'fobar'));
+ $this->assertTrue(Str::is('*.dev', 'localhost.dev'));
+ $this->assertTrue(Str::is('a', 'a'));
+ $this->assertTrue(Str::is('/', '/'));
+ $this->assertTrue(Str::is('*dev*', 'localhost.dev'));
+ $this->assertTrue(Str::is('foo?bar', 'foo?bar'));
+ $this->assertFalse(Str::is('*something', 'foobar'));
+ $this->assertFalse(Str::is('foo', 'bar'));
+ $this->assertFalse(Str::is('foo.*', 'foobar'));
+ $this->assertFalse(Str::is('foo.ar', 'foobar'));
+ $this->assertFalse(Str::is('foo?bar', 'foobar'));
+ $this->assertFalse(Str::is('foo?bar', 'fobar'));
}
public function testStrRandom()
{
- $result = str_random(20);
+ $result = Str::random(20);
$this->assertTrue(is_string($result));
$this->assertEquals(20, strlen($result));
}
public function testStartsWith()
{
- $this->assertTrue(starts_with('jason', 'jas'));
- $this->assertTrue(starts_with('jason', ['jas']));
- $this->assertFalse(starts_with('jason', 'day'));
- $this->assertFalse(starts_with('jason', ['day']));
+ $this->assertTrue(Str::startsWith('jason', 'jas'));
+ $this->assertTrue(Str::startsWith('jason', ['jas']));
+ $this->assertFalse(Str::startsWith('jason', 'day'));
+ $this->assertFalse(Str::startsWith('jason', ['day']));
}
public function testE()
@@ -217,36 +218,36 @@ public function testEndsWith()
public function testStrContains()
{
- $this->assertTrue(str_contains('taylor', 'ylo'));
- $this->assertTrue(str_contains('taylor', ['ylo']));
- $this->assertFalse(str_contains('taylor', 'xxx'));
- $this->assertFalse(str_contains('taylor', ['xxx']));
- $this->assertTrue(str_contains('taylor', ['xxx', 'taylor']));
+ $this->assertTrue(Str::contains('taylor', 'ylo'));
+ $this->assertTrue(Str::contains('taylor', ['ylo']));
+ $this->assertFalse(Str::contains('taylor', 'xxx'));
+ $this->assertFalse(Str::contains('taylor', ['xxx']));
+ $this->assertTrue(Str::contains('taylor', ['xxx', 'taylor']));
}
public function testStrFinish()
{
- $this->assertEquals('test/string/', str_finish('test/string', '/'));
- $this->assertEquals('test/string/', str_finish('test/string/', '/'));
- $this->assertEquals('test/string/', str_finish('test/string//', '/'));
+ $this->assertEquals('test/string/', Str::finish('test/string', '/'));
+ $this->assertEquals('test/string/', Str::finish('test/string/', '/'));
+ $this->assertEquals('test/string/', Str::finish('test/string//', '/'));
}
public function testSnakeCase()
{
- $this->assertEquals('foo_bar', snake_case('fooBar'));
- $this->assertEquals('foo_bar', snake_case('fooBar')); // test cache
+ $this->assertEquals('foo_bar', Str::snake('fooBar'));
+ $this->assertEquals('foo_bar', Str::snake('fooBar')); // test cache
}
public function testStrLimit()
{
$string = 'The PHP framework for web artisans.';
- $this->assertEquals('The PHP...', str_limit($string, 7));
- $this->assertEquals('The PHP', str_limit($string, 7, ''));
- $this->assertEquals('The PHP framework for web artisans.', str_limit($string, 100));
+ $this->assertEquals('The PHP...', Str::limit($string, 7));
+ $this->assertEquals('The PHP', Str::limit($string, 7, ''));
+ $this->assertEquals('The PHP framework for web artisans.', Str::limit($string, 100));
$nonAsciiString = '这是一段中文';
- $this->assertEquals('这是一...', str_limit($nonAsciiString, 6));
- $this->assertEquals('这是一', str_limit($nonAsciiString, 6, ''));
+ $this->assertEquals('这是一...', Str::limit($nonAsciiString, 6));
+ $this->assertEquals('这是一', Str::limit($nonAsciiString, 6, ''));
}
public function testCamelCase()
@@ -260,11 +261,11 @@ public function testCamelCase()
public function testStudlyCase()
{
- $this->assertEquals('FooBar', studly_case('fooBar'));
- $this->assertEquals('FooBar', studly_case('foo_bar'));
- $this->assertEquals('FooBar', studly_case('foo_bar')); // test cache
- $this->assertEquals('FooBarBaz', studly_case('foo-barBaz'));
- $this->assertEquals('FooBarBaz', studly_case('foo-bar_baz'));
+ $this->assertEquals('FooBar', Str::studly('fooBar'));
+ $this->assertEquals('FooBar', Str::studly('foo_bar'));
+ $this->assertEquals('FooBar', Str::studly('foo_bar')); // test cache
+ $this->assertEquals('FooBarBaz', Str::studly('foo-barBaz'));
+ $this->assertEquals('FooBarBaz', Str::studly('foo-bar_baz'));
}
public function testClassBasename() | true |
Other | laravel | framework | 15251e41212ee47cf2f4be13dd36d07c1a892925.json | Use Str class instead of string helper functions | tests/Support/SupportPluralizerTest.php | @@ -1,36 +1,38 @@
<?php
+use Illuminate\Support\Str;
+
class SupportPluralizerTest extends PHPUnit_Framework_TestCase
{
public function testBasicSingular()
{
- $this->assertEquals('child', str_singular('children'));
+ $this->assertEquals('child', Str::singular('children'));
}
public function testBasicPlural()
{
- $this->assertEquals('children', str_plural('child'));
+ $this->assertEquals('children', Str::plural('child'));
}
public function testCaseSensitiveSingularUsage()
{
- $this->assertEquals('Child', str_singular('Children'));
- $this->assertEquals('CHILD', str_singular('CHILDREN'));
- $this->assertEquals('Test', str_singular('Tests'));
+ $this->assertEquals('Child', Str::singular('Children'));
+ $this->assertEquals('CHILD', Str::singular('CHILDREN'));
+ $this->assertEquals('Test', Str::singular('Tests'));
}
public function testCaseSensitiveSingularPlural()
{
- $this->assertEquals('Children', str_plural('Child'));
- $this->assertEquals('CHILDREN', str_plural('CHILD'));
- $this->assertEquals('Tests', str_plural('Test'));
+ $this->assertEquals('Children', Str::plural('Child'));
+ $this->assertEquals('CHILDREN', Str::plural('CHILD'));
+ $this->assertEquals('Tests', Str::plural('Test'));
}
public function testIfEndOfWordPlural()
{
- $this->assertEquals('VortexFields', str_plural('VortexField'));
- $this->assertEquals('MatrixFields', str_plural('MatrixField'));
- $this->assertEquals('IndexFields', str_plural('IndexField'));
- $this->assertEquals('VertexFields', str_plural('VertexField'));
+ $this->assertEquals('VortexFields', Str::plural('VortexField'));
+ $this->assertEquals('MatrixFields', Str::plural('MatrixField'));
+ $this->assertEquals('IndexFields', Str::plural('IndexField'));
+ $this->assertEquals('VertexFields', Str::plural('VertexField'));
}
} | true |
Other | laravel | framework | 81332dd65c6e92ae048e1079b6e7eee7b9739e9b.json | Add verbosity levels to Output | src/Illuminate/Console/Command.php | @@ -7,7 +7,6 @@
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Question\Question;
-use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
@@ -33,7 +32,7 @@ class Command extends SymfonyCommand
/**
* The output interface implementation.
*
- * @var \Symfony\Component\Console\Style\SymfonyStyle
+ * @var \Illuminate\Console\OutputStyle
*/
protected $output;
@@ -131,7 +130,7 @@ public function run(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
- $this->output = new SymfonyStyle($input, $output);
+ $this->output = new OutputStyle($input, $output);
return parent::run($input, $output);
} | true |
Other | laravel | framework | 81332dd65c6e92ae048e1079b6e7eee7b9739e9b.json | Add verbosity levels to Output | src/Illuminate/Console/OutputStyle.php | @@ -0,0 +1,67 @@
+<?php
+
+namespace Illuminate\Console;
+
+use Symfony\Component\Console\Style\SymfonyStyle;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class OutputStyle extends SymfonyStyle
+{
+ /** @var OutputInterface */
+ private $output;
+
+ /**
+ * Create a new Console OutputStyle instance.
+ *
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ * @return void
+ */
+ public function __construct(InputInterface $input, OutputInterface $output)
+ {
+ $this->output = $output;
+
+ parent::__construct($input, $output);
+ }
+
+ /**
+ * Returns whether verbosity is quiet (-q)
+ *
+ * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise
+ */
+ public function isQuiet()
+ {
+ return $this->output->isQuiet();
+ }
+
+ /**
+ * Returns whether verbosity is verbose (-v)
+ *
+ * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise
+ */
+ public function isVerbose()
+ {
+ return $this->output->isVerbose();
+ }
+
+ /**
+ * Returns whether verbosity is very verbose (-vv)
+ *
+ * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise
+ */
+ public function isVeryVerbose()
+ {
+ return $this->output->isVeryVerbose();
+ }
+
+ /**
+ * Returns whether verbosity is debug (-vvv)
+ *
+ * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise
+ */
+ public function isDebug()
+ {
+ return $this->output->isDebug();
+ }
+} | true |
Other | laravel | framework | 2e4345ee6896aaacf79fa281ee5cc33b7ce6e548.json | change variable name. | src/Illuminate/Database/Eloquent/Factory.php | @@ -135,9 +135,9 @@ public function rawOf($class, $name, array $attributes = [])
*/
public function raw($class, array $attributes = [], $name = 'default')
{
- $attrs = call_user_func($this->definitions[$class][$name], Faker::create());
+ $raw = call_user_func($this->definitions[$class][$name], Faker::create());
- return array_merge($attrs, $attributes);
+ return array_merge($raw, $attributes);
}
/** | false |
Other | laravel | framework | 246265839b40a595a56a491a23f9a88480a9f2eb.json | Add path for the database that we tried to load
Without this information the exception isn't very helpful as the developer will have no idea where Illuminate was searching. | src/Illuminate/Database/Connectors/SQLiteConnector.php | @@ -31,7 +31,7 @@ public function connect(array $config)
// as the developer probably wants to know if the database exists and this
// SQLite driver will not throw any exception if it does not by default.
if ($path === false) {
- throw new InvalidArgumentException('Database does not exist.');
+ throw new InvalidArgumentException("Database (${config['database']}) does not exist.");
}
return $this->createConnection("sqlite:{$path}", $config, $options); | false |
Other | laravel | framework | 9976625202a101d3dfc6ee020d2afb036dd89bcc.json | Add dontSee() to CrawlerTrait. | src/Illuminate/Foundation/Testing/CrawlerTrait.php | @@ -236,6 +236,17 @@ protected function see($text, $negate = false)
return $this;
}
+ /**
+ * Assert that a given string is not seen on the page.
+ *
+ * @param string $text
+ * @return $this
+ */
+ protected function dontSee($text)
+ {
+ return $this->see($text, true);
+ }
+
/**
* Assert that the response contains JSON.
* | false |
Other | laravel | framework | 471d608150a263aac9ca25b96054eae2e61be649.json | Add Htmlable contract, HtmlString helper class | src/Illuminate/Contracts/Support/Htmlable.php | @@ -0,0 +1,13 @@
+<?php
+
+namespace Illuminate\Contracts\Support;
+
+interface Htmlable
+{
+ /**
+ * Get content as a string of HTML
+ *
+ * @return string
+ */
+ public function toHtml();
+} | true |
Other | laravel | framework | 471d608150a263aac9ca25b96054eae2e61be649.json | Add Htmlable contract, HtmlString helper class | src/Illuminate/Support/HtmlString.php | @@ -0,0 +1,46 @@
+<?php
+
+namespace Illuminate\Support;
+
+use Illuminate\Contracts\Support\Htmlable;
+
+class HtmlString implements Htmlable
+{
+ /**
+ * The HTML string
+ *
+ * @var string
+ */
+ protected $html;
+
+ /**
+ * Create a new HTML string instance.
+ *
+ * @param string $html
+ * @return void
+ */
+ public function __construct($html)
+ {
+ $this->html = $html;
+ }
+
+ /**
+ * Get the the HTML string
+ *
+ * @return string
+ */
+ public function toHtml()
+ {
+ return $this->html;
+ }
+
+ /**
+ * Get the the HTML string
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->toHtml();
+ }
+} | true |
Other | laravel | framework | 471d608150a263aac9ca25b96054eae2e61be649.json | Add Htmlable contract, HtmlString helper class | src/Illuminate/Support/helpers.php | @@ -426,11 +426,15 @@ function dd()
/**
* Escape HTML entities in a string.
*
- * @param string $value
+ * @param \Illuminate\Support\Htmlable|string $value
* @return string
*/
function e($value)
{
+ if ($value instanceof Illuminate\Contracts\Support\Htmlable) {
+ return $value->toHtml();
+ }
+
return htmlentities($value, ENT_QUOTES, 'UTF-8', false);
}
} | true |
Other | laravel | framework | 471d608150a263aac9ca25b96054eae2e61be649.json | Add Htmlable contract, HtmlString helper class | tests/Support/SupportHelpersTest.php | @@ -1,7 +1,14 @@
<?php
+use Mockery as m;
+
class SupportHelpersTest extends PHPUnit_Framework_TestCase
{
+ public function tearDown()
+ {
+ m::close();
+ }
+
public function testArrayBuild()
{
$this->assertEquals(['foo' => 'bar'], array_build(['foo' => 'bar'], function ($key, $value) {
@@ -191,6 +198,15 @@ public function testStartsWith()
$this->assertFalse(starts_with('jason', ['day']));
}
+ public function testE()
+ {
+ $str = 'A \'quote\' is <b>bold</b>';
+ $this->assertEquals('A 'quote' is <b>bold</b>', e($str));
+ $html = m::mock('Illuminate\Support\HtmlString');
+ $html->shouldReceive('toHtml')->andReturn($str);
+ $this->assertEquals($str, e($html));
+ }
+
public function testEndsWith()
{
$this->assertTrue(ends_with('jason', 'on')); | true |
Other | laravel | framework | 471d608150a263aac9ca25b96054eae2e61be649.json | Add Htmlable contract, HtmlString helper class | tests/Support/SupportHtmlStringTest.php | @@ -0,0 +1,20 @@
+<?php
+
+use Illuminate\Support\HtmlString;
+
+class SupportHtmlStringTest extends PHPUnit_Framework_TestCase
+{
+ public function testToHtml()
+ {
+ $str = '<h1>foo</h1>';
+ $html = new HtmlString('<h1>foo</h1>');
+ $this->assertEquals($str, $html->toHtml());
+ }
+
+ public function testToString()
+ {
+ $str = '<h1>foo</h1>';
+ $html = new HtmlString('<h1>foo</h1>');
+ $this->assertEquals($str, (string) $html);
+ }
+} | true |
Other | laravel | framework | cb5757acb1da0ba8d837213f1d182d508eddb9e8.json | Remove unused use statements. | src/Illuminate/Encryption/Encrypter.php | @@ -3,7 +3,6 @@
namespace Illuminate\Encryption;
use RuntimeException;
-use Illuminate\Support\Str;
use Illuminate\Contracts\Encryption\EncryptException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract; | true |
Other | laravel | framework | cb5757acb1da0ba8d837213f1d182d508eddb9e8.json | Remove unused use statements. | src/Illuminate/Encryption/McryptEncrypter.php | @@ -3,7 +3,6 @@
namespace Illuminate\Encryption;
use Exception;
-use Illuminate\Support\Str;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;
| true |
Other | laravel | framework | cb5757acb1da0ba8d837213f1d182d508eddb9e8.json | Remove unused use statements. | src/Illuminate/Http/ResponseTrait.php | @@ -2,8 +2,6 @@
namespace Illuminate\Http;
-use Symfony\Component\HttpFoundation\Cookie;
-
trait ResponseTrait
{
/** | true |
Other | laravel | framework | 401167c3a4957f108820b13ae877118a22f14c3d.json | Fix wrong class name in return docblock. | src/Illuminate/Database/Eloquent/Factory.php | @@ -143,7 +143,7 @@ public function raw($class, array $attributes = [], $name = 'default')
*
* @param string $class
* @param string $name
- * @return \Illuminate\Database\Factory\Builder
+ * @return \Illuminate\Database\Eloquent\FactoryBuilder
*/
public function of($class, $name = 'default')
{ | false |
Other | laravel | framework | 275739483a335a78ad814b441b740e7bf35b0844.json | Fix basepath on chrooted environments | src/Illuminate/Foundation/Application.php | @@ -252,7 +252,7 @@ public function hasBeenBootstrapped()
*/
public function setBasePath($basePath)
{
- $this->basePath = $basePath;
+ $this->basePath = rtrim($basePath, DIRECTORY_SEPARATOR);
$this->bindPathsInContainer();
| false |
Other | laravel | framework | b5accc88525e592aea50c717ded962bec2938314.json | Add a test for testValidateMimetypes | tests/Validation/ValidationValidatorTest.php | @@ -990,6 +990,18 @@ public function testValidateImage()
$this->assertTrue($v->passes());
}
+ public function testValidateMimetypes()
+ {
+ $trans = $this->getRealTranslator();
+ $uploadedFile = [__FILE__, '', null, null, null, true];
+
+ $file = $this->getMock('Symfony\Component\HttpFoundation\File\UploadedFile', ['guessExtension'], $uploadedFile);
+ $file->expects($this->any())->method('validateMimetypes')->will($this->returnValue('php'));
+ $v = new Validator($trans, [], ['x' => 'mimetypes:text/x-php']);
+ $v->setFiles(['x' => $file]);
+ $this->assertTrue($v->passes());
+ }
+
public function testValidateMime()
{
$trans = $this->getRealTranslator(); | false |
Other | laravel | framework | 331dc60cd7ed387ef264d22899fb3c7c756e4453.json | Allow validateIn for type array | src/Illuminate/Validation/Validator.php | @@ -962,6 +962,10 @@ protected function getSize($attribute, $value)
*/
protected function validateIn($attribute, $value, $parameters)
{
+ if (is_array($value) && in_array('array', $this->rules[$attribute])) {
+ return count(array_diff($value, $parameters)) == 0;
+ }
+
return in_array((string) $value, $parameters);
}
| false |
Other | laravel | framework | 19e84aeb4c8e82f0e96d1d30ff12fa2afad36c85.json | fix app name | src/Illuminate/Foundation/Console/AppNameCommand.php | @@ -236,7 +236,7 @@ protected function setPhpSpecNamespace()
protected function setDatabaseFactoryNamespaces()
{
$this->replaceIn(
- $this->laravel->databasePath().'/factories', $this->currentRoot, $this->argument('name')
+ $this->laravel->databasePath().'/factories/ModelFactory.php', $this->currentRoot, $this->argument('name')
);
}
| false |
Other | laravel | framework | 603aad0f53efcffcc609e8f010fd5f3022e61711.json | Use methods from contract | src/Illuminate/Foundation/Bootstrap/RegisterFacades.php | @@ -20,6 +20,6 @@ public function bootstrap(Application $app)
Facade::setFacadeApplication($app);
- AliasLoader::getInstance($app['config']['app.aliases'])->register();
+ AliasLoader::getInstance($app->make('config')->get('app.aliases'))->register();
}
} | true |
Other | laravel | framework | 603aad0f53efcffcc609e8f010fd5f3022e61711.json | Use methods from contract | src/Illuminate/Foundation/Bootstrap/SetRequestForConsole.php | @@ -15,7 +15,7 @@ class SetRequestForConsole
*/
public function bootstrap(Application $app)
{
- $url = $app['config']->get('app.url', 'http://localhost');
+ $url = $app->make('config')->get('app.url', 'http://localhost');
$app->instance('request', Request::create($url, 'GET', [], [], [], $_SERVER));
} | true |
Other | laravel | framework | 6020b7c2937df9cae48b5f4e3ebd0c623d1c79b1.json | Fix some compiled stuff. | src/Illuminate/Foundation/Console/Optimize/config.php | @@ -41,7 +41,7 @@
$basePath.'/vendor/laravel/framework/src/Illuminate/Contracts/Auth/UserProvider.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Container/Container.php',
- $basePath.'/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php',
+ $basePath.'/vendor/symfony/http-kernel/HttpKernelInterface.php',
$basePath.'/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/TerminableInterface.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Application.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/EnvironmentDetector.php',
@@ -53,24 +53,26 @@
$basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php',
- $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesAndRegistersUsers.php',
+ $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php',
+ $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Auth/RedirectsUsers.php',
+ $basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Auth/RegistersUsers.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ResetsPasswords.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Http/Request.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Http/Middleware/FrameGuard.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionBagInterface.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php',
+ $basePath.'/vendor/symfony/http-foundation/Request.php',
+ $basePath.'/vendor/symfony/http-foundation/ParameterBag.php',
+ $basePath.'/vendor/symfony/http-foundation/FileBag.php',
+ $basePath.'/vendor/symfony/http-foundation/ServerBag.php',
+ $basePath.'/vendor/symfony/http-foundation/HeaderBag.php',
+ $basePath.'/vendor/symfony/http-foundation/Session/SessionInterface.php',
+ $basePath.'/vendor/symfony/http-foundation/Session/SessionBagInterface.php',
+ $basePath.'/vendor/symfony/http-foundation/Session/Attribute/AttributeBagInterface.php',
+ $basePath.'/vendor/symfony/http-foundation/Session/Attribute/AttributeBag.php',
+ $basePath.'/vendor/symfony/http-foundation/Session/Storage/MetadataBag.php',
+ $basePath.'/vendor/symfony/http-foundation/AcceptHeaderItem.php',
+ $basePath.'/vendor/symfony/http-foundation/AcceptHeader.php',
$basePath.'/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Support/AggregateServiceProvider.php',
@@ -117,10 +119,10 @@
$basePath.'/vendor/laravel/framework/src/Illuminate/Routing/Router.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Routing/Route.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php',
- $basePath.'/vendor/symfony/routing/Symfony/Component/Routing/CompiledRoute.php',
- $basePath.'/vendor/symfony/routing/Symfony/Component/Routing/RouteCompilerInterface.php',
- $basePath.'/vendor/symfony/routing/Symfony/Component/Routing/RouteCompiler.php',
- $basePath.'/vendor/symfony/routing/Symfony/Component/Routing/Route.php',
+ $basePath.'/vendor/symfony/routing/CompiledRoute.php',
+ $basePath.'/vendor/symfony/routing/RouteCompilerInterface.php',
+ $basePath.'/vendor/symfony/routing/RouteCompiler.php',
+ $basePath.'/vendor/symfony/routing/Route.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Routing/Controller.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Routing/ControllerInspector.php',
@@ -147,6 +149,7 @@
$basePath.'/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php',
+ $basePath.'/vendor/laravel/framework/src/Illuminate/Encryption/BaseEncrypter.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Support/Facades/Log.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php',
@@ -178,11 +181,11 @@
$basePath.'/vendor/laravel/framework/src/Illuminate/View/Compilers/CompilerInterface.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/View/Compilers/Compiler.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php',
+ $basePath.'/vendor/symfony/http-foundation/Response.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Http/ResponseTrait.php',
$basePath.'/vendor/laravel/framework/src/Illuminate/Http/Response.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php',
- $basePath.'/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php',
+ $basePath.'/vendor/symfony/http-foundation/ResponseHeaderBag.php',
+ $basePath.'/vendor/symfony/http-foundation/Cookie.php',
$basePath.'/vendor/symfony/finder/Symfony/Component/Finder/SplFileInfo.php',
$basePath.'/vendor/symfony/finder/Symfony/Component/Finder/Expression/Regex.php',
$basePath.'/vendor/symfony/finder/Symfony/Component/Finder/Expression/ValueInterface.php', | false |
Other | laravel | framework | 5796036e3f0114fd3dfdecd26b0dfd1e896faf38.json | Remove middleware contract from core middleware. | src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php | @@ -4,9 +4,8 @@
use Closure;
use Illuminate\Contracts\Auth\Guard;
-use Illuminate\Contracts\Routing\Middleware;
-class AuthenticateWithBasicAuth implements Middleware
+class AuthenticateWithBasicAuth
{
/**
* The guard instance. | true |
Other | laravel | framework | 5796036e3f0114fd3dfdecd26b0dfd1e896faf38.json | Remove middleware contract from core middleware. | src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php | @@ -3,10 +3,9 @@
namespace Illuminate\Cookie\Middleware;
use Closure;
-use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
-class AddQueuedCookiesToResponse implements Middleware
+class AddQueuedCookiesToResponse
{
/**
* The cookie jar instance. | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.