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 | df40910d1e010d33d42cb450edca0e4e9da5ee67.json | Fix some docblocks | src/Illuminate/Database/Eloquent/Relations/MorphPivot.php | @@ -124,7 +124,7 @@ public function newQueryForRestoration($ids)
/**
* Get a new query to restore multiple models by their queueable IDs.
*
- * @param array<int> $ids
+ * @param array $ids
* @return \Illuminate\Database\Eloquent\Builder
*/
protected function newQueryForCollectionRestoration(array $ids) | true |
Other | laravel | framework | df40910d1e010d33d42cb450edca0e4e9da5ee67.json | Fix some docblocks | src/Illuminate/Database/Migrations/Migrator.php | @@ -622,7 +622,7 @@ protected function note($message)
/**
* Fire the given event for the migration.
*
- * @param \Illuminate\Contracts\Database\Events\Migration $event
+ * @param \Illuminate\Contracts\Database\Events\MigrationEvent $event
* @return void
*/
public function fireMigrationEvent($event) | true |
Other | laravel | framework | df40910d1e010d33d42cb450edca0e4e9da5ee67.json | Fix some docblocks | src/Illuminate/Database/Seeder.php | @@ -108,7 +108,7 @@ public function setCommand(Command $command)
/**
* Run the database seeds.
*
- * @return dynamic
+ * @return mixed
*
* @throws \InvalidArgumentException
*/ | true |
Other | laravel | framework | eb73a500f8bf3a42c3ca80845484589796ae5a55.json | Improve ForeignKeyDefinition meta class | src/Illuminate/Database/Schema/ForeignKeyDefinition.php | @@ -5,10 +5,12 @@
use Illuminate\Support\Fluent;
/**
- * @method ForeignKeyDefinition references(string $table) Specify the referenced table
- * @method ForeignKeyDefinition on(string $column) Specify the referenced column
+ * @method ForeignKeyDefinition references(string|array $columns) Specify the referenced column(s)
+ * @method ForeignKeyDefinition on(string $table) Specify the referenced table
* @method ForeignKeyDefinition onDelete(string $action) Add an ON DELETE action
* @method ForeignKeyDefinition onUpdate(string $action) Add an ON UPDATE action
+ * @method ForeignKeyDefinition deferrable(bool $value = true) Set the foreign key as deferrable (PostgreSQL)
+ * @method ForeignKeyDefinition initiallyImmediate(bool $value = true) Set the default time to check the constraint (PostgreSQL)
*/
class ForeignKeyDefinition extends Fluent
{ | false |
Other | laravel | framework | 469cd39793e3c514ac6e6472c065786b8802f4d9.json | add the `resource` method to the Gate contract
this would need to be notes in the 5.9 upgrade guide (probably as a low priority). | src/Illuminate/Contracts/Auth/Access/Gate.php | @@ -126,4 +126,14 @@ public function forUser($user);
* @return array
*/
public function abilities();
+
+ /**
+ * Define abilities for a resource.
+ *
+ * @param string $name
+ * @param string $class
+ * @param array|null $abilities
+ * @return $this
+ */
+ public function resource($name, $class, array $abilities = null);
} | false |
Other | laravel | framework | 5c129ba119b6fce2a723cbe00e6dece0d4199c6b.json | call container instance directly | src/Illuminate/Notifications/Messages/MailMessage.php | @@ -4,6 +4,7 @@
use Traversable;
use Illuminate\Mail\Markdown;
+use Illuminate\Container\Container;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Renderable;
@@ -281,6 +282,8 @@ protected function arrayOfAddresses($address)
*/
public function render()
{
- return app(Markdown::class)->render($this->markdown, $this->data());
+ return Container::getInstance()
+ ->make(Markdown::class)
+ ->render($this->markdown, $this->data());
}
} | false |
Other | laravel | framework | 841a28067b03979603e41dd80729cb8581a91e95.json | Fix a styling issue. | src/Illuminate/Database/Schema/Builder.php | @@ -4,9 +4,9 @@
use Closure;
use LogicException;
+use RuntimeException;
use Doctrine\DBAL\Types\Type;
use Illuminate\Database\Connection;
-use RuntimeException;
class Builder
{ | false |
Other | laravel | framework | 5cd131b48b5e8ba4ce36106ce9feaaf57889b1d1.json | Apply fixes from StyleCI (#28374) | src/Illuminate/Database/ConfigurationUrlParser.php | @@ -80,7 +80,7 @@ protected function getDriver($url)
$alias = $url['scheme'] ?? null;
if (! $alias) {
- return null;
+ return;
}
return static::$driverAliases[$alias] ?? $alias; | false |
Other | laravel | framework | a43424de299ec02e9e08a05c78d460ec1d054cd3.json | Move debug methods to the base query builder | src/Illuminate/Database/Eloquent/Builder.php | @@ -1293,16 +1293,6 @@ public function getMacro($name)
return Arr::get($this->localMacros, $name);
}
- /**
- * Debug the current query builder instance.
- *
- * @return void
- */
- public function dd()
- {
- dd($this->toSql(), $this->getBindings());
- }
-
/**
* Dynamically access builder proxies.
* | true |
Other | laravel | framework | a43424de299ec02e9e08a05c78d460ec1d054cd3.json | Move debug methods to the base query builder | src/Illuminate/Database/Query/Builder.php | @@ -2999,4 +2999,24 @@ public function __call($method, $parameters)
static::throwBadMethodCallException($method);
}
+
+ /**
+ * Debug the current query builder instance.
+ *
+ * @return void
+ */
+ public function dump()
+ {
+ dump($this->toSql(), $this->getBindings());
+ }
+
+ /**
+ * Debug the current query builder instance.
+ *
+ * @return void
+ */
+ public function dd()
+ {
+ dd($this->toSql(), $this->getBindings());
+ }
} | true |
Other | laravel | framework | 7c75c1321bc4e29bf8c7b11fb2e3b83466549b96.json | Fix dispatcher issue. | src/Illuminate/Database/Migrations/Migrator.php | @@ -4,11 +4,11 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
+use Illuminate\Events\Dispatcher;
use Illuminate\Support\Collection;
use Illuminate\Console\OutputStyle;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
-use Illuminate\Events\Dispatcher;
class Migrator
{
@@ -622,9 +622,11 @@ protected function note($message)
* @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
* @return void
*/
- public static function setEventDispatcher(Dispatcher $dispatcher)
+ public function setEventDispatcher(Dispatcher $dispatcher)
{
static::$dispatcher = $dispatcher;
+
+ return $this;
}
/** | false |
Other | laravel | framework | dc4ee4d34ff174c95b748ccfef271effe1b370d2.json | Add events to migrations | src/Illuminate/Database/MigrationServiceProvider.php | @@ -51,7 +51,11 @@ protected function registerMigrator()
$this->app->singleton('migrator', function ($app) {
$repository = $app['migration.repository'];
- return new Migrator($repository, $app['db'], $app['files']);
+ $migrator = new Migrator($repository, $app['db'], $app['files']);
+
+ $migrator->setEventDispatcher($app['events']);
+
+ return $migrator;
});
}
| true |
Other | laravel | framework | dc4ee4d34ff174c95b748ccfef271effe1b370d2.json | Add events to migrations | src/Illuminate/Database/Migrations/Migrator.php | @@ -8,9 +8,17 @@
use Illuminate\Console\OutputStyle;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Database\ConnectionResolverInterface as Resolver;
+use Illuminate\Events\Dispatcher;
class Migrator
{
+ /**
+ * The event dispatcher instance.
+ *
+ * @var \Illuminate\Contracts\Events\Dispatcher
+ */
+ protected static $dispatcher;
+
/**
* The migration repository implementation.
*
@@ -140,6 +148,8 @@ public function runPending(array $migrations, array $options = [])
$step = $options['step'] ?? false;
+ $this->fireMigrationEvent('beforeAll:up');
+
// Once we have the array of migrations, we will spin through them and run the
// migrations "up" so the changes are made to the databases. We'll then log
// that the migration was run so we don't repeat it next time we execute.
@@ -150,6 +160,8 @@ public function runPending(array $migrations, array $options = [])
$batch++;
}
}
+
+ $this->fireMigrationEvent('afterAll:up');
}
/**
@@ -239,6 +251,8 @@ protected function rollbackMigrations(array $migrations, $paths, array $options)
$this->requireFiles($files = $this->getMigrationFiles($paths));
+ $this->fireMigrationEvent('beforeAll:down');
+
// Next we will run through all of the migrations and call the "down" method
// which will reverse each migration in order. This getLast method on the
// repository already returns these migration's names in reverse order.
@@ -259,6 +273,8 @@ protected function rollbackMigrations(array $migrations, $paths, array $options)
);
}
+ $this->fireMigrationEvent('afterAll:down');
+
return $rolledBack;
}
@@ -357,7 +373,15 @@ protected function runMigration($migration, $method)
$callback = function () use ($migration, $method) {
if (method_exists($migration, $method)) {
+ $this->fireMigrationEvent("before:{$method}", [
+ 'migration' => $migration,
+ ]);
+
$migration->{$method}();
+
+ $this->fireMigrationEvent("after:{$method}", [
+ 'migration' => $migration,
+ ]);
}
};
@@ -591,4 +615,31 @@ protected function note($message)
$this->output->writeln($message);
}
}
+
+ /**
+ * Set the event dispatcher instance.
+ *
+ * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
+ * @return void
+ */
+ public static function setEventDispatcher(Dispatcher $dispatcher)
+ {
+ static::$dispatcher = $dispatcher;
+ }
+
+ /**
+ * Fire the given event for the model.
+ *
+ * @param string $event
+ * @param array $params
+ * @return mixed
+ */
+ public function fireMigrationEvent($name, $params = [])
+ {
+ if (! isset(static::$dispatcher)) {
+ return true;
+ }
+
+ return static::$dispatcher->dispatch("migrations.{$name}", $params);
+ }
} | true |
Other | laravel | framework | 200c0c0cff33f58c38377d7e16cd01122cfc5715.json | Add the `dd` method to the query builder | src/Illuminate/Database/Eloquent/Builder.php | @@ -13,6 +13,7 @@
use Illuminate\Database\Concerns\BuildsQueries;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Query\Builder as QueryBuilder;
+use Illuminate\Database\Eloquent\Concerns\HasDebugMethods;
/**
* @property-read HigherOrderBuilderProxy $orWhere
@@ -21,7 +22,7 @@
*/
class Builder
{
- use BuildsQueries, Concerns\QueriesRelationships, ForwardsCalls;
+ use BuildsQueries, Concerns\QueriesRelationships, ForwardsCalls, HasDebugMethods;
/**
* The base query builder instance. | true |
Other | laravel | framework | 200c0c0cff33f58c38377d7e16cd01122cfc5715.json | Add the `dd` method to the query builder | src/Illuminate/Database/Eloquent/Concerns/HasDebugMethods.php | @@ -0,0 +1,16 @@
+<?php
+
+namespace Illuminate\Database\Eloquent\Concerns;
+
+trait HasDebugMethods
+{
+ /**
+ * Debug the current query builder instance.
+ *
+ * @return void
+ */
+ public function dd()
+ {
+ dd($this->toSql(), $this->getBindings());
+ }
+} | true |
Other | laravel | framework | 4c26157dac948f83e7ec252520760e66dd26ad85.json | Add missing period at the end of a paragraph. | README.md | @@ -20,7 +20,7 @@ Laravel is a web application framework with expressive, elegant syntax. We belie
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
-Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb combination of simplicity, elegance, and innovation gives you a complete toolset required to build any application with which you are tasked
+Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb combination of simplicity, elegance, and innovation gives you a complete toolset required to build any application with which you are tasked.
## Learning Laravel
| false |
Other | laravel | framework | 1b568d02e6e17e324e462a5259c67528767cbcbb.json | Add docblocs and change self to static. | src/Illuminate/Database/UrlParser.php | @@ -8,10 +8,16 @@
use function array_merge;
use function preg_replace;
use Illuminate\Support\Arr;
+use InvalidArgumentException;
class UrlParser
{
- private static $driverAliases = [
+ /**
+ * The drivers aliases map.
+ *
+ * @var array
+ */
+ protected static $driverAliases = [
'mssql' => 'sqlsrv',
'mysql2' => 'mysql', // Amazon RDS, for some weird reason
'postgres' => 'pgsql',
@@ -20,23 +26,38 @@ class UrlParser
];
/**
+ * The different components of parsed url.
+ *
* @var array
*/
protected $parsedUrl;
+ /**
+ * Get all of the current drivers aliases.
+ *
+ * @return array
+ */
public static function getDriverAliases(): array
{
- return self::$driverAliases;
+ return static::$driverAliases;
}
+ /**
+ * Add the driver alias to the driver aliases array.
+ *
+ * @param string $alias
+ * @param string $driver
+ * @return void
+ */
public static function addDriverAlias($alias, $driver)
{
- self::$driverAliases[$alias] = $driver;
+ static::$driverAliases[$alias] = $driver;
}
/**
- * @param array|string $config
+ * Transform the url string or config array with url key to a parsed classic config array.
*
+ * @param array|string $config
* @return array
*/
public function parseDatabaseConfigWithUrl($config): array
@@ -61,6 +82,12 @@ public function parseDatabaseConfigWithUrl($config): array
);
}
+ /**
+ * Decode the string url, to an array of all of its components.
+ *
+ * @param string $url
+ * @return array
+ */
protected function parseUrl($url): array
{
// sqlite3?:///... => sqlite3?://null/... or else the URL will be invalid
@@ -69,12 +96,19 @@ protected function parseUrl($url): array
$parsedUrl = parse_url($url);
if ($parsedUrl === false) {
- throw new \InvalidArgumentException('Malformed parameter "url".');
+ throw new InvalidArgumentException('Malformed parameter "url".');
}
return $this->parseStringsToNativeTypes(array_map('rawurldecode', $parsedUrl));
}
+ /**
+ * Convert string casted values to there native types.
+ * Ex: 'false' => false, '42' => 42, 'foo' => 'foo'
+ *
+ * @param string $url
+ * @return mixed
+ */
protected function parseStringsToNativeTypes($value)
{
if (is_array($value)) {
@@ -94,11 +128,16 @@ protected function parseStringsToNativeTypes($value)
return $value;
}
+ /**
+ * Return the main attributes of the database connection config from url.
+ *
+ * @return array
+ */
protected function getMainAttributes(): array
{
return array_filter([
'driver' => $this->getDriver(),
- 'database' => $this->getNormalizedPath(),
+ 'database' => $this->getDatabase(),
'host' => $this->getInUrl('host'),
'port' => $this->getInUrl('port'),
'username' => $this->getInUrl('user'),
@@ -108,6 +147,11 @@ protected function getMainAttributes(): array
});
}
+ /**
+ * Find connection driver from url.
+ *
+ * @return string|null
+ */
protected function getDriver()
{
$alias = $this->getInUrl('scheme');
@@ -116,15 +160,26 @@ protected function getDriver()
return null;
}
- return self::$driverAliases[$alias] ?? $alias;
+ return static::$driverAliases[$alias] ?? $alias;
}
+ /**
+ * Get a component of the parsed url.
+ *
+ * @param string $key
+ * @return string|null
+ */
protected function getInUrl($key)
{
return $this->parsedUrl[$key] ?? null;
}
- protected function getNormalizedPath()
+ /**
+ * Find connection database from url.
+ *
+ * @return string|null
+ */
+ protected function getDatabase()
{
$path = $this->getInUrl('path');
@@ -135,6 +190,11 @@ protected function getNormalizedPath()
return substr($path, 1);
}
+ /**
+ * Return all the options added to the url with query params.
+ *
+ * @return array
+ */
protected function getOtherOptions(): array
{
$queryString = $this->getInUrl('query'); | false |
Other | laravel | framework | 95d7e8250a728674962abeb2f09f0eebe31ac292.json | Apply @driesvints suggestions from code review.
Co-Authored-By: mathieutu <oss@mathieutu.dev> | src/Illuminate/Database/DatabaseManager.php | @@ -151,7 +151,9 @@ protected function configuration($name)
throw new InvalidArgumentException("Database [{$name}] not configured.");
}
- return $this->app->make(UrlParser::class)->parseDatabaseConfigWithUrl($config);
+ $urlParser = new UrlParser;
+
+ return $urlParser->parseDatabaseConfigWithUrl($config);
}
/** | true |
Other | laravel | framework | 95d7e8250a728674962abeb2f09f0eebe31ac292.json | Apply @driesvints suggestions from code review.
Co-Authored-By: mathieutu <oss@mathieutu.dev> | src/Illuminate/Database/UrlParser.php | @@ -22,14 +22,14 @@ class UrlParser
/**
* @var array
*/
- private $parsedUrl;
+ protected $parsedUrl;
public static function getDriverAliases(): array
{
return self::$driverAliases;
}
- public static function addDriverAlias(string $alias, string $driver)
+ public static function addDriverAlias($alias, $driver)
{
self::$driverAliases[$alias] = $driver;
}
@@ -61,7 +61,7 @@ public function parseDatabaseConfigWithUrl($config): array
);
}
- private function parseUrl(string $url): array
+ protected function parseUrl($url): array
{
// sqlite3?:///... => sqlite3?://null/... or else the URL will be invalid
$url = preg_replace('#^(sqlite3?):///#', '$1://null/', $url);
@@ -75,7 +75,7 @@ private function parseUrl(string $url): array
return $this->parseStringsToNativeTypes(array_map('rawurldecode', $parsedUrl));
}
- private function parseStringsToNativeTypes($value)
+ protected function parseStringsToNativeTypes($value)
{
if (is_array($value)) {
return array_map([$this, 'parseStringsToNativeTypes'], $value);
@@ -94,7 +94,7 @@ private function parseStringsToNativeTypes($value)
return $value;
}
- private function getMainAttributes(): array
+ protected function getMainAttributes(): array
{
return array_filter([
'driver' => $this->getDriver(),
@@ -108,7 +108,7 @@ private function getMainAttributes(): array
});
}
- private function getDriver(): ?string
+ protected function getDriver()
{
$alias = $this->getInUrl('scheme');
@@ -119,12 +119,12 @@ private function getDriver(): ?string
return self::$driverAliases[$alias] ?? $alias;
}
- private function getInUrl(string $key): ?string
+ protected function getInUrl($key)
{
return $this->parsedUrl[$key] ?? null;
}
- private function getNormalizedPath(): ?string
+ protected function getNormalizedPath()
{
$path = $this->getInUrl('path');
@@ -135,7 +135,7 @@ private function getNormalizedPath(): ?string
return substr($path, 1);
}
- private function getOtherOptions(): array
+ protected function getOtherOptions(): array
{
$queryString = $this->getInUrl('query');
| true |
Other | laravel | framework | 95d7e8250a728674962abeb2f09f0eebe31ac292.json | Apply @driesvints suggestions from code review.
Co-Authored-By: mathieutu <oss@mathieutu.dev> | tests/Database/DatabaseConnectionFactoryTest.php | @@ -13,7 +13,6 @@
class DatabaseConnectionFactoryTest extends TestCase
{
- /** @var DB */
protected $db;
protected function setUp(): void | true |
Other | laravel | framework | 7604cfb4d6104999b05a15f2215e21252c8c2cc2.json | Fix recursive replacements in Str::replaceArray() | src/Illuminate/Support/Str.php | @@ -327,11 +327,15 @@ public static function random($length = 16)
*/
public static function replaceArray($search, array $replace, $subject)
{
- foreach ($replace as $value) {
- $subject = static::replaceFirst($search, $value, $subject);
+ $segments = explode($search, $subject);
+
+ $result = array_shift($segments);
+
+ foreach ($segments as $segment) {
+ $result .= (array_shift($replace) ?? $search).$segment;
}
- return $subject;
+ return $result;
}
/** | true |
Other | laravel | framework | 7604cfb4d6104999b05a15f2215e21252c8c2cc2.json | Fix recursive replacements in Str::replaceArray() | tests/Support/SupportStrTest.php | @@ -248,6 +248,7 @@ public function testReplaceArray()
$this->assertEquals('foo/bar/baz/?', Str::replaceArray('?', ['foo', 'bar', 'baz'], '?/?/?/?'));
$this->assertEquals('foo/bar', Str::replaceArray('?', ['foo', 'bar', 'baz'], '?/?'));
$this->assertEquals('?/?/?', Str::replaceArray('x', ['foo', 'bar', 'baz'], '?/?/?'));
+ $this->assertEquals('foo?/bar/baz', Str::replaceArray('?', ['foo?', 'bar', 'baz'], '?/?/?'));
}
public function testReplaceFirst() | true |
Other | laravel | framework | c3c58f89451a92b95796b0df76b6de041636c709.json | Apply fixes from StyleCI (#28337) | src/Illuminate/Auth/Console/AuthMakeCommand.php | @@ -126,7 +126,7 @@ protected function compileControllerStub()
protected function getViewPath($path)
{
return implode(DIRECTORY_SEPARATOR, [
- config('view.paths')[0] ?? resource_path('views'), $path
+ config('view.paths')[0] ?? resource_path('views'), $path,
]);
}
} | false |
Other | laravel | framework | f7dc3f4e6a1fcb6fede971ab22427ff6d7cfa0ce.json | Add some more tests. | tests/Database/DatabaseConnectionFactoryTest.php | @@ -13,6 +13,7 @@
class DatabaseConnectionFactoryTest extends TestCase
{
+ /** @var DB */
protected $db;
protected function setUp(): void
@@ -48,17 +49,47 @@ protected function tearDown(): void
public function testConnectionCanBeCreated()
{
- $this->assertInstanceOf(PDO::class, $this->db->connection()->getPdo());
- $this->assertInstanceOf(PDO::class, $this->db->connection()->getReadPdo());
- $this->assertInstanceOf(PDO::class, $this->db->connection('read_write')->getPdo());
- $this->assertInstanceOf(PDO::class, $this->db->connection('read_write')->getReadPdo());
- $this->assertInstanceOf(PDO::class, $this->db->connection('url')->getPdo());
- $this->assertInstanceOf(PDO::class, $this->db->connection('url')->getReadPdo());
+ $this->assertInstanceOf(PDO::class, $this->db->getConnection()->getPdo());
+ $this->assertInstanceOf(PDO::class, $this->db->getConnection()->getReadPdo());
+ $this->assertInstanceOf(PDO::class, $this->db->getConnection('read_write')->getPdo());
+ $this->assertInstanceOf(PDO::class, $this->db->getConnection('read_write')->getReadPdo());
+ $this->assertInstanceOf(PDO::class, $this->db->getConnection('url')->getPdo());
+ $this->assertInstanceOf(PDO::class, $this->db->getConnection('url')->getReadPdo());
+ }
+
+ public function testConnectionFromUrlHasProperConfig()
+ {
+ $this->db->addConnection([
+ 'url' => 'mysql://root:pass@db/local?strict=true',
+ 'unix_socket' => '',
+ 'charset' => 'utf8mb4',
+ 'collation' => 'utf8mb4_unicode_ci',
+ 'prefix' => '',
+ 'prefix_indexes' => true,
+ 'strict' => false,
+ 'engine' => null,
+ ], 'url-config');
+
+ $this->assertEquals([
+ 'name' => 'url-config',
+ 'driver' => 'mysql',
+ 'database' => 'local',
+ 'host' => 'db',
+ 'username' => 'root',
+ 'password' => 'pass',
+ 'unix_socket' => '',
+ 'charset' => 'utf8mb4',
+ 'collation' => 'utf8mb4_unicode_ci',
+ 'prefix' => '',
+ 'prefix_indexes' => true,
+ 'strict' => true,
+ 'engine' => null,
+ ], $this->db->getConnection('url-config')->getConfig());
}
public function testSingleConnectionNotCreatedUntilNeeded()
{
- $connection = $this->db->connection();
+ $connection = $this->db->getConnection();
$pdo = new ReflectionProperty(get_class($connection), 'pdo');
$pdo->setAccessible(true);
$readPdo = new ReflectionProperty(get_class($connection), 'readPdo');
@@ -70,7 +101,7 @@ public function testSingleConnectionNotCreatedUntilNeeded()
public function testReadWriteConnectionsNotCreatedUntilNeeded()
{
- $connection = $this->db->connection('read_write');
+ $connection = $this->db->getConnection('read_write');
$pdo = new ReflectionProperty(get_class($connection), 'pdo');
$pdo->setAccessible(true);
$readPdo = new ReflectionProperty(get_class($connection), 'readPdo');
@@ -114,8 +145,8 @@ public function testSqliteForeignKeyConstraints()
'url' => 'sqlite:///:memory:?foreign_key_constraints=true',
], 'constraints_set');
- $this->assertEquals(0, $this->db->connection()->select('PRAGMA foreign_keys')[0]->foreign_keys);
+ $this->assertEquals(0, $this->db->getConnection()->select('PRAGMA foreign_keys')[0]->foreign_keys);
- $this->assertEquals(1, $this->db->connection('constraints_set')->select('PRAGMA foreign_keys')[0]->foreign_keys);
+ $this->assertEquals(1, $this->db->getConnection('constraints_set')->select('PRAGMA foreign_keys')[0]->foreign_keys);
}
} | true |
Other | laravel | framework | f7dc3f4e6a1fcb6fede971ab22427ff6d7cfa0ce.json | Add some more tests. | tests/Database/DatabaseUrlParserTest.php | @@ -301,7 +301,7 @@ public function databaseUrls()
'Full example from doc with url overwriting parameters' => [
[
- 'url' => 'pgsql://root:pass@db/local',
+ 'url' => 'mysql://root:pass@db/local',
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => '3306',
@@ -318,7 +318,7 @@ public function databaseUrls()
'options' => ['foo' => 'bar'],
],
[
- 'driver' => 'pgsql',
+ 'driver' => 'mysql',
'host' => 'db',
'port' => '3306',
'database' => 'local', | true |
Other | laravel | framework | c91d6a515f68d7860d313627416a7158078830e3.json | Parse Database Url when creating connection. | src/Illuminate/Database/DatabaseManager.php | @@ -151,7 +151,7 @@ protected function configuration($name)
throw new InvalidArgumentException("Database [{$name}] not configured.");
}
- return $config;
+ return $this->app->make(UrlParser::class)->parseDatabaseConfigWithUrl($config);
}
/** | true |
Other | laravel | framework | c91d6a515f68d7860d313627416a7158078830e3.json | Parse Database Url when creating connection. | tests/Database/DatabaseConnectionFactoryTest.php | @@ -24,6 +24,10 @@ protected function setUp(): void
'database' => ':memory:',
]);
+ $this->db->addConnection([
+ 'url' => 'sqlite:///:memory:',
+ ], 'url');
+
$this->db->addConnection([
'driver' => 'sqlite',
'read' => [
@@ -48,6 +52,8 @@ public function testConnectionCanBeCreated()
$this->assertInstanceOf(PDO::class, $this->db->connection()->getReadPdo());
$this->assertInstanceOf(PDO::class, $this->db->connection('read_write')->getPdo());
$this->assertInstanceOf(PDO::class, $this->db->connection('read_write')->getReadPdo());
+ $this->assertInstanceOf(PDO::class, $this->db->connection('url')->getPdo());
+ $this->assertInstanceOf(PDO::class, $this->db->connection('url')->getReadPdo());
}
public function testSingleConnectionNotCreatedUntilNeeded()
@@ -105,9 +111,7 @@ public function testCustomConnectorsCanBeResolvedViaContainer()
public function testSqliteForeignKeyConstraints()
{
$this->db->addConnection([
- 'driver' => 'sqlite',
- 'database' => ':memory:',
- 'foreign_key_constraints' => true,
+ 'url' => 'sqlite:///:memory:?foreign_key_constraints=true',
], 'constraints_set');
$this->assertEquals(0, $this->db->connection()->select('PRAGMA foreign_keys')[0]->foreign_keys); | true |
Other | laravel | framework | cfbaea07d799bbb8ae5791ddaca738adcc46092e.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Auth/EloquentUserProvider.php | @@ -65,7 +65,7 @@ public function retrieveByToken($identifier, $token)
$model = $model->where($model->getAuthIdentifierName(), $identifier)->first();
if (! $model) {
- return null;
+ return;
}
$rememberToken = $model->getRememberToken(); | true |
Other | laravel | framework | cfbaea07d799bbb8ae5791ddaca738adcc46092e.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php | @@ -133,7 +133,7 @@ protected function whenLoaded($relationship, $value = null, $default = null)
}
if ($this->resource->{$relationship} === null) {
- return null;
+ return;
}
return value($value); | true |
Other | laravel | framework | cfbaea07d799bbb8ae5791ddaca738adcc46092e.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/Console/Scheduling/CacheOverlappingStrategyTest.php | @@ -7,7 +7,7 @@
use Illuminate\Console\Scheduling\Event;
use Illuminate\Console\Scheduling\CacheMutex;
-class CacheMutexTest extends TestCase
+class CacheOverlappingStrategyTest extends TestCase
{
/**
* @var CacheMutex | true |
Other | laravel | framework | cfbaea07d799bbb8ae5791ddaca738adcc46092e.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/Notifications/NotificationMailMessageTest.php | @@ -5,7 +5,7 @@
use PHPUnit\Framework\TestCase;
use Illuminate\Notifications\Messages\MailMessage;
-class NotificationsMailMessageTest extends TestCase
+class NotificationMailMessageTest extends TestCase
{
public function setUp()
{ | true |
Other | laravel | framework | cfbaea07d799bbb8ae5791ddaca738adcc46092e.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/View/Blade/BladeEndSectionTest.php | @@ -2,7 +2,7 @@
namespace Illuminate\Tests\View\Blade;
-class BladeStopTest extends AbstractBladeTestCase
+class BladeEndSectionTest extends AbstractBladeTestCase
{
public function testStopSectionsAreCompiled()
{ | true |
Other | laravel | framework | cfbaea07d799bbb8ae5791ddaca738adcc46092e.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/View/Blade/BladeIfIEmptyStatementsTest.php | @@ -2,7 +2,7 @@
namespace Illuminate\Tests\View\Blade;
-class BladeIfEmptyStatementsTest extends AbstractBladeTestCase
+class BladeIfIEmptyStatementsTest extends AbstractBladeTestCase
{
public function testIfStatementsAreCompiled()
{ | true |
Other | laravel | framework | cfbaea07d799bbb8ae5791ddaca738adcc46092e.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/View/ViewFileViewFinderTest.php | @@ -5,7 +5,7 @@
use Mockery as m;
use PHPUnit\Framework\TestCase;
-class ViewFinderTest extends TestCase
+class ViewFileViewFinderTest extends TestCase
{
public function tearDown()
{ | true |
Other | laravel | framework | cfbaea07d799bbb8ae5791ddaca738adcc46092e.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/View/fixtures/section-exception-layout.php | @@ -1 +1 @@
-<?php echo $__env->yieldContent('content'); ?>
+<?php echo $__env->yieldContent('content'); | true |
Other | laravel | framework | 1e4b8a50d5075eb6693b908c57e75d87aadb3537.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/View/fixtures/section-exception-layout.php | @@ -1 +1,3 @@
-<?php echo $__env->yieldContent('content');
+<?php
+
+echo $__env->yieldContent('content'); | false |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Auth/Access/Gate.php | @@ -527,7 +527,6 @@ protected function resolveAuthCallback($user, $ability, array $arguments)
}
return function () {
- return null;
};
}
@@ -653,7 +652,7 @@ protected function resolvePolicyCallback($user, $ability, array $arguments, $pol
protected function callPolicyBefore($policy, $user, $ability, $arguments)
{
if (! method_exists($policy, 'before')) {
- return null;
+ return;
}
if ($this->canBeCalledWithUser($user, $policy, 'before')) {
@@ -680,7 +679,7 @@ protected function callPolicyMethod($policy, $method, $user, array $arguments)
}
if (! is_callable([$policy, $method])) {
- return null;
+ return;
}
if ($this->canBeCalledWithUser($user, $policy, $method)) { | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Auth/EloquentUserProvider.php | @@ -68,7 +68,7 @@ public function retrieveByToken($identifier, $token)
)->first();
if (! $retrievedModel) {
- return null;
+ return;
}
$rememberToken = $retrievedModel->getRememberToken(); | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php | @@ -294,8 +294,6 @@ protected function retrieveUser($request, $channel)
return $user;
}
}
-
- return null;
}
/** | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Cache/ArrayStore.php | @@ -24,7 +24,7 @@ class ArrayStore extends TaggableStore
public function get($key)
{
if (! isset($this->storage[$key])) {
- return null;
+ return;
}
$item = $this->storage[$key];
@@ -34,7 +34,7 @@ public function get($key)
if ($expiresAt !== 0 && $this->currentTime() > $expiresAt) {
$this->forget($key);
- return null;
+ return;
}
return $item['value']; | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Cache/DynamoDbStore.php | @@ -151,7 +151,6 @@ public function many(array $keys)
$now = Carbon::now();
return array_merge(collect(array_flip($keys))->map(function () {
- return null;
})->all(), collect($response['Responses'][$this->table])->mapWithKeys(function ($response) use ($now) {
if ($this->isExpired($response, $now)) {
$value = null; | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Cache/NullStore.php | @@ -21,7 +21,6 @@ class NullStore extends TaggableStore
*/
public function get($key)
{
- return null;
}
/** | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Database/Eloquent/Collection.php | @@ -141,7 +141,7 @@ public function loadMissing($relations)
* @param array $path
* @return void
*/
- protected function loadMissingRelation(Collection $models, array $path)
+ protected function loadMissingRelation(self $models, array $path)
{
$relation = array_shift($path);
| true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Foundation/Console/Presets/bootstrap-stubs/_variables.scss | @@ -1,17 +1,16 @@
-
// Body
$body-bg: #f8fafc;
// Typography
-$font-family-sans-serif: "Nunito", sans-serif;
+$font-family-sans-serif: 'Nunito', sans-serif;
$font-size-base: 0.9rem;
$line-height-base: 1.6;
// Colors
$blue: #3490dc;
$indigo: #6574cd;
$purple: #9561e2;
-$pink: #f66D9b;
+$pink: #f66d9b;
$red: #e3342f;
$orange: #f6993f;
$yellow: #ffed4a; | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Foundation/Console/Presets/bootstrap-stubs/app.scss | @@ -1,4 +1,3 @@
-
// Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');
@@ -9,6 +8,6 @@
@import '~bootstrap/scss/bootstrap';
.navbar-laravel {
- background-color: #fff;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
+ background-color: #fff;
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
} | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php | @@ -167,7 +167,7 @@ protected function whenLoaded($relationship, $value = null, $default = null)
}
if ($this->resource->{$relationship} === null) {
- return null;
+ return;
}
return value($value); | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Mail/resources/views/html/themes/default.css | @@ -1,13 +1,15 @@
/* Base */
-body, body *:not(html):not(style):not(br):not(tr):not(code) {
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
+body,
+body *:not(html):not(style):not(br):not(tr):not(code) {
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,
+ 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
box-sizing: border-box;
}
body {
- background-color: #F8FAFC;
- color: #74787E;
+ background-color: #f8fafc;
+ color: #74787e;
height: 100%;
hyphens: auto;
line-height: 1.4;
@@ -30,7 +32,7 @@ blockquote {
}
a {
- color: #3869D4;
+ color: #3869d4;
}
a img {
@@ -40,31 +42,31 @@ a img {
/* Typography */
h1 {
- color: #3D4852;
+ color: #3d4852;
font-size: 19px;
font-weight: bold;
margin-top: 0;
text-align: left;
}
h2 {
- color: #3D4852;
+ color: #3d4852;
font-size: 16px;
font-weight: bold;
margin-top: 0;
text-align: left;
}
h3 {
- color: #3D4852;
+ color: #3d4852;
font-size: 14px;
font-weight: bold;
margin-top: 0;
text-align: left;
}
p {
- color: #3D4852;
+ color: #3d4852;
font-size: 16px;
line-height: 1.5em;
margin-top: 0;
@@ -82,7 +84,7 @@ img {
/* Layout */
.wrapper {
- background-color: #F8FAFC;
+ background-color: #f8fafc;
margin: 0;
padding: 0;
width: 100%;
@@ -118,9 +120,9 @@ img {
/* Body */
.body {
- background-color: #FFFFFF;
- border-bottom: 1px solid #EDEFF2;
- border-top: 1px solid #EDEFF2;
+ background-color: #ffffff;
+ border-bottom: 1px solid #edeff2;
+ border-top: 1px solid #edeff2;
margin: 0;
padding: 0;
width: 100%;
@@ -130,7 +132,7 @@ img {
}
.inner-body {
- background-color: #FFFFFF;
+ background-color: #ffffff;
margin: 0 auto;
padding: 0;
width: 570px;
@@ -142,7 +144,7 @@ img {
/* Subcopy */
.subcopy {
- border-top: 1px solid #EDEFF2;
+ border-top: 1px solid #edeff2;
margin-top: 25px;
padding-top: 25px;
}
@@ -164,7 +166,7 @@ img {
}
.footer p {
- color: #AEAEAE;
+ color: #aeaeae;
font-size: 12px;
text-align: center;
}
@@ -180,13 +182,13 @@ img {
}
.table th {
- border-bottom: 1px solid #EDEFF2;
+ border-bottom: 1px solid #edeff2;
padding-bottom: 8px;
margin: 0;
}
.table td {
- color: #74787E;
+ color: #74787e;
font-size: 15px;
line-height: 18px;
padding: 10px 0;
@@ -212,37 +214,37 @@ img {
.button {
border-radius: 3px;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.16);
- color: #FFF;
+ color: #fff;
display: inline-block;
text-decoration: none;
-webkit-text-size-adjust: none;
}
.button-blue,
.button-primary {
- background-color: #3490DC;
- border-top: 10px solid #3490DC;
- border-right: 18px solid #3490DC;
- border-bottom: 10px solid #3490DC;
- border-left: 18px solid #3490DC;
+ background-color: #3490dc;
+ border-top: 10px solid #3490dc;
+ border-right: 18px solid #3490dc;
+ border-bottom: 10px solid #3490dc;
+ border-left: 18px solid #3490dc;
}
.button-green,
.button-success {
- background-color: #38C172;
- border-top: 10px solid #38C172;
- border-right: 18px solid #38C172;
- border-bottom: 10px solid #38C172;
- border-left: 18px solid #38C172;
+ background-color: #38c172;
+ border-top: 10px solid #38c172;
+ border-right: 18px solid #38c172;
+ border-bottom: 10px solid #38c172;
+ border-left: 18px solid #38c172;
}
.button-red,
.button-error {
- background-color: #E3342F;
- border-top: 10px solid #E3342F;
- border-right: 18px solid #E3342F;
- border-bottom: 10px solid #E3342F;
- border-left: 18px solid #E3342F;
+ background-color: #e3342f;
+ border-top: 10px solid #e3342f;
+ border-right: 18px solid #e3342f;
+ border-bottom: 10px solid #e3342f;
+ border-left: 18px solid #e3342f;
}
/* Panels */
@@ -252,7 +254,7 @@ img {
}
.panel-content {
- background-color: #F1F5F8;
+ background-color: #f1f5f8;
padding: 16px;
}
@@ -268,8 +270,8 @@ img {
/* Promotions */
.promotion {
- background-color: #FFFFFF;
- border: 2px dashed #9BA2AB;
+ background-color: #ffffff;
+ border: 2px dashed #9ba2ab;
margin: 0;
margin-bottom: 25px;
margin-top: 25px; | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | src/Illuminate/Queue/DatabaseQueue.php | @@ -199,8 +199,6 @@ public function pop($queue = null)
if ($job = $this->getNextAvailableJob($queue)) {
return $this->marshalJob($queue, $job);
}
-
- return null;
});
}
| true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/Auth/AuthAccessGateTest.php | @@ -31,7 +31,6 @@ public function test_basic_closures_can_be_defined()
public function test_before_can_take_an_array_callback_as_object()
{
$gate = new Gate(new Container, function () {
- return null;
});
$gate->before([new AccessGateTestBeforeCallback, 'allowEverything']);
@@ -42,7 +41,6 @@ public function test_before_can_take_an_array_callback_as_object()
public function test_before_can_take_an_array_callback_as_object_static()
{
$gate = new Gate(new Container, function () {
- return null;
});
$gate->before([new AccessGateTestBeforeCallback, 'allowEverythingStatically']);
@@ -53,7 +51,6 @@ public function test_before_can_take_an_array_callback_as_object_static()
public function test_before_can_take_an_array_callback_with_static_method()
{
$gate = new Gate(new Container, function () {
- return null;
});
$gate->before([AccessGateTestBeforeCallback::class, 'allowEverythingStatically']);
@@ -64,7 +61,6 @@ public function test_before_can_take_an_array_callback_with_static_method()
public function test_before_can_allow_guests()
{
$gate = new Gate(new Container, function () {
- return null;
});
$gate->before(function (?StdClass $user) {
@@ -77,7 +73,6 @@ public function test_before_can_allow_guests()
public function test_after_can_allow_guests()
{
$gate = new Gate(new Container, function () {
- return null;
});
$gate->after(function (?StdClass $user) {
@@ -90,7 +85,6 @@ public function test_after_can_allow_guests()
public function test_closures_can_allow_guest_users()
{
$gate = new Gate(new Container, function () {
- return null;
});
$gate->define('foo', function (?StdClass $user) {
@@ -110,7 +104,6 @@ public function test_policies_can_allow_guests()
unset($_SERVER['__laravel.testBefore']);
$gate = new Gate(new Container, function () {
- return null;
});
$gate->policy(AccessGateTestDummy::class, AccessGateTestPolicyThatAllowsGuests::class);
@@ -134,7 +127,6 @@ public function test_policy_before_not_called_with_guests_if_it_doesnt_allow_the
$_SERVER['__laravel.testBefore'] = false;
$gate = new Gate(new Container, function () {
- return null;
});
$gate->policy(AccessGateTestDummy::class, AccessGateTestPolicyWithNonGuestBefore::class);
@@ -154,7 +146,6 @@ public function test_before_and_after_callbacks_can_allow_guests()
$_SERVER['__laravel.gateAfter2'] = false;
$gate = new Gate(new Container, function () {
- return null;
});
$gate->before(function (?StdClass $user) {
@@ -726,7 +717,6 @@ public function hasAbilitiesTestDataProvider()
public function test_classes_can_be_defined_as_callbacks_using_at_notation_for_guests()
{
$gate = new Gate(new Container, function () {
- return null;
});
$gate->define('foo', AccessGateTestClassForGuest::class.'@foo'); | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/Database/DatabaseEloquentBuilderTest.php | @@ -1286,27 +1286,27 @@ class EloquentBuilderTestModelSelfRelatedStub extends Model
public function parentFoo()
{
- return $this->belongsTo(EloquentBuilderTestModelSelfRelatedStub::class, 'parent_id', 'id', 'parent');
+ return $this->belongsTo(self::class, 'parent_id', 'id', 'parent');
}
public function childFoo()
{
- return $this->hasOne(EloquentBuilderTestModelSelfRelatedStub::class, 'parent_id', 'id');
+ return $this->hasOne(self::class, 'parent_id', 'id');
}
public function childFoos()
{
- return $this->hasMany(EloquentBuilderTestModelSelfRelatedStub::class, 'parent_id', 'id', 'children');
+ return $this->hasMany(self::class, 'parent_id', 'id', 'children');
}
public function parentBars()
{
- return $this->belongsToMany(EloquentBuilderTestModelSelfRelatedStub::class, 'self_pivot', 'child_id', 'parent_id', 'parent_bars');
+ return $this->belongsToMany(self::class, 'self_pivot', 'child_id', 'parent_id', 'parent_bars');
}
public function childBars()
{
- return $this->belongsToMany(EloquentBuilderTestModelSelfRelatedStub::class, 'self_pivot', 'parent_id', 'child_id', 'child_bars');
+ return $this->belongsToMany(self::class, 'self_pivot', 'parent_id', 'child_id', 'child_bars');
}
public function bazes() | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/Database/DatabaseEloquentIntegrationTest.php | @@ -1600,17 +1600,17 @@ class EloquentTestUser extends Eloquent
public function friends()
{
- return $this->belongsToMany(EloquentTestUser::class, 'friends', 'user_id', 'friend_id');
+ return $this->belongsToMany(self::class, 'friends', 'user_id', 'friend_id');
}
public function friendsOne()
{
- return $this->belongsToMany(EloquentTestUser::class, 'friends', 'user_id', 'friend_id')->wherePivot('user_id', 1);
+ return $this->belongsToMany(self::class, 'friends', 'user_id', 'friend_id')->wherePivot('user_id', 1);
}
public function friendsTwo()
{
- return $this->belongsToMany(EloquentTestUser::class, 'friends', 'user_id', 'friend_id')->wherePivot('user_id', 2);
+ return $this->belongsToMany(self::class, 'friends', 'user_id', 'friend_id')->wherePivot('user_id', 2);
}
public function posts()
@@ -1718,12 +1718,12 @@ public function photos()
public function childPosts()
{
- return $this->hasMany(EloquentTestPost::class, 'parent_id');
+ return $this->hasMany(self::class, 'parent_id');
}
public function parentPost()
{
- return $this->belongsTo(EloquentTestPost::class, 'parent_id');
+ return $this->belongsTo(self::class, 'parent_id');
}
}
| true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/Integration/Database/EloquentCollectionLoadMissingTest.php | @@ -99,7 +99,7 @@ class Comment extends Model
public function parent()
{
- return $this->belongsTo(Comment::class);
+ return $this->belongsTo(self::class);
}
public function revisions() | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/Integration/Database/EloquentModelLoadMissingTest.php | @@ -54,7 +54,7 @@ class Comment extends Model
public function parent()
{
- return $this->belongsTo(Comment::class);
+ return $this->belongsTo(self::class);
}
}
| true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/Integration/Support/Fixtures/NullableManager.php | @@ -13,6 +13,5 @@ class NullableManager extends Manager
*/
public function getDefaultDriver()
{
- return null;
}
} | true |
Other | laravel | framework | 4ead2b347a909d990fd26cb33069070b09f802a2.json | Apply fixes from StyleCI
[ci skip] [skip ci] | tests/View/fixtures/section-exception-layout.php | @@ -1 +1 @@
-<?php echo $__env->yieldContent('content'); ?>
+<?php echo $__env->yieldContent('content'); | true |
Other | laravel | framework | a71b6683440be1285e62d69c3e933244b9277620.json | Add styleci config | .styleci.yml | @@ -0,0 +1,4 @@
+php:
+ preset: laravel
+js: true
+css: true | false |
Other | laravel | framework | e83ae1de159776599d2c8d4f63a40bf5188472f4.json | Update auth stubs with @error blade directive | src/Illuminate/Auth/Console/stubs/make/views/auth/login.stub | @@ -15,27 +15,27 @@
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
- <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
+ <input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
- @if ($errors->has('email'))
+ @error('email')
<span class="invalid-feedback" role="alert">
- <strong>{{ $errors->first('email') }}</strong>
+ <strong>{{ $message }}</strong>
</span>
- @endif
+ @enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
- <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required autocomplete="current-password">
+ <input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
- @if ($errors->has('password'))
+ @error('password')
<span class="invalid-feedback" role="alert">
- <strong>{{ $errors->first('password') }}</strong>
+ <strong>{{ $message }}</strong>
</span>
- @endif
+ @enderror
</div>
</div>
| true |
Other | laravel | framework | e83ae1de159776599d2c8d4f63a40bf5188472f4.json | Update auth stubs with @error blade directive | src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/email.stub | @@ -21,13 +21,13 @@
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
- <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
+ <input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
- @if ($errors->has('email'))
+ @error('email')
<span class="invalid-feedback" role="alert">
- <strong>{{ $errors->first('email') }}</strong>
+ <strong>{{ $message }}</strong>
</span>
- @endif
+ @enderror
</div>
</div>
| true |
Other | laravel | framework | e83ae1de159776599d2c8d4f63a40bf5188472f4.json | Update auth stubs with @error blade directive | src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub | @@ -17,27 +17,27 @@
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
- <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ $email ?? old('email') }}" required autocomplete="email" autofocus>
+ <input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ $email ?? old('email') }}" required autocomplete="email" autofocus>
- @if ($errors->has('email'))
+ @error('email')
<span class="invalid-feedback" role="alert">
- <strong>{{ $errors->first('email') }}</strong>
+ <strong>{{ $message }}</strong>
</span>
- @endif
+ @enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
- <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required autocomplete="new-password">
+ <input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
- @if ($errors->has('password'))
+ @error('password')
<span class="invalid-feedback" role="alert">
- <strong>{{ $errors->first('password') }}</strong>
+ <strong>{{ $message }}</strong>
</span>
- @endif
+ @enderror
</div>
</div>
| true |
Other | laravel | framework | e83ae1de159776599d2c8d4f63a40bf5188472f4.json | Update auth stubs with @error blade directive | src/Illuminate/Auth/Console/stubs/make/views/auth/register.stub | @@ -15,41 +15,41 @@
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
- <input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
+ <input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
- @if ($errors->has('name'))
+ @error('name')
<span class="invalid-feedback" role="alert">
- <strong>{{ $errors->first('name') }}</strong>
+ <strong>{{ $message }}</strong>
</span>
- @endif
+ @enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
- <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autocomplete="email">
+ <input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
- @if ($errors->has('email'))
+ @error('email')
<span class="invalid-feedback" role="alert">
- <strong>{{ $errors->first('email') }}</strong>
+ <strong>{{ $message }}</strong>
</span>
- @endif
+ @enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
- <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required autocomplete="new-password">
+ <input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
- @if ($errors->has('password'))
+ @error('password')
<span class="invalid-feedback" role="alert">
- <strong>{{ $errors->first('password') }}</strong>
+ <strong>{{ $message }}</strong>
</span>
- @endif
+ @enderror
</div>
</div>
| true |
Other | laravel | framework | c7a46f0c13b7f6b764c55bb741672bc557eada80.json | Apply fixes from StyleCI (#28264) | tests/Queue/QueueWorkerTest.php | @@ -243,7 +243,6 @@ public function test_job_based_max_retries()
$this->assertNull($job->failedWith);
}
-
public function test_job_based_failed_delay()
{
$job = new WorkerFakeJob(function ($job) {
@@ -259,7 +258,6 @@ public function test_job_based_failed_delay()
$this->assertEquals(10, $job->releaseAfter);
}
-
/**
* Helpers...
*/ | false |
Other | laravel | framework | 46dd880e745421afb5e5f3a703096c3346e56b0f.json | implement method support | src/Illuminate/Queue/Queue.php | @@ -124,7 +124,7 @@ protected function createObjectPayload($job, $queue)
'displayName' => $this->getDisplayName($job),
'job' => 'Illuminate\Queue\CallQueuedHandler@call',
'maxTries' => $job->tries ?? null,
- 'delay' => $job->delay ?? null,
+ 'delay' => $this->getJobRetryDelay($job),
'timeout' => $job->timeout ?? null,
'timeoutAt' => $this->getJobExpiration($job),
'data' => [
@@ -153,6 +153,24 @@ protected function getDisplayName($job)
? $job->displayName() : get_class($job);
}
+ /**
+ * Get the retry delay for an object-based queue handler.
+ *
+ * @param mixed $job
+ * @return mixed
+ */
+ public function getJobRetryDelay($job)
+ {
+ if (! method_exists($job, 'retryAfter') && ! isset($job->retryAfter)) {
+ return;
+ }
+
+ $delay = $job->retryAfter ?? $job->retryAfter();
+
+ return $delay instanceof DateTimeInterface
+ ? $this->secondsUntil($delay) : $delay;
+ }
+
/**
* Get the expiration timestamp for an object-based queue handler.
* | true |
Other | laravel | framework | 46dd880e745421afb5e5f3a703096c3346e56b0f.json | implement method support | tests/Queue/QueueWorkerTest.php | @@ -243,6 +243,23 @@ public function test_job_based_max_retries()
$this->assertNull($job->failedWith);
}
+
+ public function test_job_based_failed_delay()
+ {
+ $job = new WorkerFakeJob(function ($job) {
+ throw new \Exception('Something went wrong.');
+ });
+
+ $job->attempts = 1;
+ $job->delaySeconds = 10;
+
+ $worker = $this->getWorker('default', ['queue' => [$job]]);
+ $worker->runNextJob('default', 'queue', $this->workerOptions(['delay' => 3]));
+
+ $this->assertEquals(10, $job->releaseAfter);
+ }
+
+
/**
* Helpers...
*/
@@ -353,6 +370,7 @@ class WorkerFakeJob implements QueueJobContract
public $releaseAfter;
public $released = false;
public $maxTries;
+ public $delaySeconds;
public $timeoutAt;
public $attempts = 0;
public $failedWith;
@@ -389,6 +407,11 @@ public function maxTries()
return $this->maxTries;
}
+ public function delaySeconds()
+ {
+ return $this->delaySeconds;
+ }
+
public function timeoutAt()
{
return $this->timeoutAt; | true |
Other | laravel | framework | e9831b3b683c2135834ba5650f81ac531af7a244.json | Add wherePivotIn Test | tests/Integration/Database/EloquentBelongsToManyTest.php | @@ -524,13 +524,13 @@ public function test_where_pivot_on_string()
$post = Post::create(['title' => Str::random()]);
DB::table('posts_tags')->insert([
- ['post_id' => $post->id, 'tag_id' => $tag->id, 'flag' => 'empty'],
+ ['post_id' => $post->id, 'tag_id' => $tag->id, 'flag' => 'foo'],
]);
- $relationTag = $post->tags()->wherePivot('flag', 'empty')->first();
+ $relationTag = $post->tags()->wherePivot('flag', 'foo')->first();
$this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
- $relationTag = $post->tags()->wherePivot('flag', '=', 'empty')->first();
+ $relationTag = $post->tags()->wherePivot('flag', '=', 'foo')->first();
$this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
}
@@ -550,6 +550,19 @@ public function test_where_pivot_on_boolean()
$this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
}
+ public function test_where_pivot_in_method()
+ {
+ $tag = Tag::create(['name' => Str::random()]);
+ $post = Post::create(['title' => Str::random()]);
+
+ DB::table('posts_tags')->insert([
+ ['post_id' => $post->id, 'tag_id' => $tag->id, 'flag' => 'foo'],
+ ]);
+
+ $relationTag = $post->tags()->wherePivotIn('flag', ['foo'])->first();
+ $this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
+ }
+
public function test_can_update_existing_pivot()
{
$tag = Tag::create(['name' => Str::random()]); | false |
Other | laravel | framework | 2d40c94d4db099df09fec943ef3bbced03b97b78.json | Add wherePivot Tests | tests/Integration/Database/EloquentBelongsToManyTest.php | @@ -518,6 +518,38 @@ public function test_can_touch_related_models()
$this->assertNotEquals('2017-10-10 10:10:10', Tag::find(300)->updated_at);
}
+ public function test_where_pivot_on_string()
+ {
+ $tag = Tag::create(['name' => Str::random()]);
+ $post = Post::create(['title' => Str::random()]);
+
+ DB::table('posts_tags')->insert([
+ ['post_id' => $post->id, 'tag_id' => $tag->id, 'flag' => 'empty'],
+ ]);
+
+ $relationTag = $post->tags()->wherePivot('flag', 'empty')->first();
+ $this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
+
+ $relationTag = $post->tags()->wherePivot('flag', '=', 'empty')->first();
+ $this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
+ }
+
+ public function test_where_pivot_on_boolean()
+ {
+ $tag = Tag::create(['name' => Str::random()]);
+ $post = Post::create(['title' => Str::random()]);
+
+ DB::table('posts_tags')->insert([
+ ['post_id' => $post->id, 'tag_id' => $tag->id, 'flag' => true],
+ ]);
+
+ $relationTag = $post->tags()->wherePivot('flag', true)->first();
+ $this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
+
+ $relationTag = $post->tags()->wherePivot('flag', '=', true)->first();
+ $this->assertEquals($relationTag->getAttributes(), $tag->getAttributes());
+ }
+
public function test_can_update_existing_pivot()
{
$tag = Tag::create(['name' => Str::random()]); | false |
Other | laravel | framework | 1bcad051b668b06ba3366560242d4f112e3a1860.json | Fix a styling issue. | src/Illuminate/Database/Schema/Builder.php | @@ -324,7 +324,7 @@ public function blueprintResolver(Closure $resolver)
*
* @param string $class
* @param string $name
- * @param string $type
+ * @param string $type
* @return void
*
* @throws \Doctrine\DBAL\DBALException | true |
Other | laravel | framework | 1bcad051b668b06ba3366560242d4f112e3a1860.json | Fix a styling issue. | src/Illuminate/Database/Schema/MySqlBuilder.php | @@ -10,8 +10,7 @@ class MySqlBuilder extends Builder
/**
* MySqlBuilder constructor.
*
- * @param Connection $connection
- *
+ * @param \Illuminate\Database\Connection $connection
* @throws \Doctrine\DBAL\DBALException
*/
public function __construct(Connection $connection) | true |
Other | laravel | framework | 1bcad051b668b06ba3366560242d4f112e3a1860.json | Fix a styling issue. | src/Illuminate/Database/Schema/Types/TinyInteger.php | @@ -18,7 +18,7 @@ class TinyInteger extends Type
* Gets the SQL declaration snippet for a field of this type.
*
* @param array $fieldDeclaration
- * @param AbstractPlatform $platform
+ * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return string
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) | true |
Other | laravel | framework | db8419641c6ccdc7d6e4673267027aba92868b53.json | Fix a styling issue. | tests/Integration/Database/SchemaBuilderTest.php | @@ -3,11 +3,11 @@
namespace Illuminate\Tests\Integration\Database\SchemaTest;
use Doctrine\DBAL\Types\Type;
-use Illuminate\Database\Schema\Grammars\SQLiteGrammar;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Types\TinyInteger;
+use Illuminate\Database\Schema\Grammars\SQLiteGrammar;
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
/**
@@ -58,7 +58,7 @@ public function test_register_custom_DBAL_type()
'DROP TABLE test',
'CREATE TABLE test (test_column TINYINT NOT NULL COLLATE BINARY)',
'INSERT INTO test (test_column) SELECT test_column FROM __temp__test',
- 'DROP TABLE __temp__test'
+ 'DROP TABLE __temp__test',
];
$statements = $blueprint->toSql($this->getConnection(), new SQLiteGrammar()); | false |
Other | laravel | framework | 6cece2455c5894f4bd6202747fce244cc6c693f2.json | Apply fixes from StyleCI (#28222) | src/Illuminate/Routing/RedirectController.php | @@ -24,7 +24,7 @@ public function __invoke(Request $request, UrlGenerator $url)
$destination = $parameters->pop();
$route = (new Route('GET', $destination, [
- 'as' => 'laravel_route_redirect_destination'
+ 'as' => 'laravel_route_redirect_destination',
]))->bind($request);
$parameters = $parameters->only( | false |
Other | laravel | framework | de5d0c4830edf3ac3c697e6c7d31e63c9309e4da.json | Fix a styling issue. | src/Illuminate/Database/Schema/Types/TinyInteger.php | @@ -61,4 +61,4 @@ public function getName()
{
return self::NAME;
}
-}
\ No newline at end of file
+} | false |
Other | laravel | framework | c97a8572eca62441705d7d39af3ecae000c35386.json | Fix a styling issue. | src/Illuminate/Database/Schema/Builder.php | @@ -3,8 +3,8 @@
namespace Illuminate\Database\Schema;
use Closure;
-use Doctrine\DBAL\Types\Type;
use LogicException;
+use Doctrine\DBAL\Types\Type;
use Illuminate\Database\Connection;
class Builder
@@ -337,7 +337,7 @@ public function registerCustomDBALType($class, $name, $type)
if (! Type::hasType($name)) {
Type::addType($name, $class);
-
+
$this->connection
->getDoctrineSchemaManager()
->getDatabasePlatform() | true |
Other | laravel | framework | c97a8572eca62441705d7d39af3ecae000c35386.json | Fix a styling issue. | src/Illuminate/Database/Schema/Types/TinyInteger.php | @@ -2,8 +2,8 @@
namespace Illuminate\Database\Schema\Types;
-use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
class TinyInteger extends Type
{ | true |
Other | laravel | framework | c97a8572eca62441705d7d39af3ecae000c35386.json | Fix a styling issue. | tests/Integration/Database/SchemaBuilderTest.php | @@ -3,10 +3,10 @@
namespace Illuminate\Tests\Integration\Database\SchemaTest;
use Doctrine\DBAL\Types\Type;
-use Illuminate\Database\Schema\Types\TinyInteger;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Schema\Types\TinyInteger;
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
/** | true |
Other | laravel | framework | 7c0d0f6baea9c89255e5da5a7df5ec0a0c5d9b82.json | Fix a styling issue. | src/Illuminate/Database/Schema/Builder.php | @@ -334,9 +334,10 @@ public function registerCustomDBALType($class, $name, $type)
if (! $this->connection->isDoctrineAvailable()) {
return;
}
-
+
if (! Type::hasType($name)) {
Type::addType($name, $class);
+
$this->connection
->getDoctrineSchemaManager()
->getDatabasePlatform() | false |
Other | laravel | framework | eb5de12c443b10c8eb4936a5d09977adc43a2a54.json | Fix a styling issue. | src/Illuminate/Database/Schema/Builder.php | @@ -334,6 +334,7 @@ public function registerCustomDBALType($class, $name, $type)
if (! $this->connection->isDoctrineAvailable()) {
return;
}
+
if (! Type::hasType($name)) {
Type::addType($name, $class);
$this->connection | false |
Other | laravel | framework | f4b4844682f05c0740b1c8f94e16c332b8cd5933.json | Add getViews method to return views | src/Illuminate/View/FileViewFinder.php | @@ -319,4 +319,14 @@ public function getExtensions()
{
return $this->extensions;
}
+
+ /**
+ * Get registered views.
+ *
+ * @return array
+ */
+ public function getViews()
+ {
+ return $this->views;
+ }
} | false |
Other | laravel | framework | 4b9d3e78e6de2d7439eeecb3f1115e8048e64f90.json | handle duplicates method in eloquent collections | src/Illuminate/Database/Eloquent/Collection.php | @@ -305,6 +305,19 @@ public function diff($items)
return $diff;
}
+ /**
+ * Get the comparison function to detect duplicates.
+ *
+ * @param bool $strict
+ * @return \Closure
+ */
+ protected function duplicateComparator($strict)
+ {
+ return function ($a, $b) {
+ return $a->is($b);
+ };
+ }
+
/**
* Intersect the collection with the given items.
* | true |
Other | laravel | framework | 4b9d3e78e6de2d7439eeecb3f1115e8048e64f90.json | handle duplicates method in eloquent collections | src/Illuminate/Support/Collection.php | @@ -420,12 +420,7 @@ public function duplicates($callback = null, $strict = false)
$uniqueItems = $items->unique(null, $strict);
- $compare = $strict ? function ($a, $b) {
- return $a === $b;
- }
- : function ($a, $b) {
- return $a == $b;
- };
+ $compare = $this->duplicateComparator($strict);
$duplicates = new static;
@@ -451,6 +446,25 @@ public function duplicatesStrict($callback = null)
return $this->duplicates($callback, true);
}
+ /**
+ * Get the comparison function to detect duplicates.
+ *
+ * @param bool $strict
+ * @return \Closure
+ */
+ protected function duplicateComparator($strict)
+ {
+ if ($strict) {
+ return function ($a, $b) {
+ return $a === $b;
+ };
+ }
+
+ return function ($a, $b) {
+ return $a == $b;
+ };
+ }
+
/**
* Execute a callback over each item.
* | true |
Other | laravel | framework | 4b9d3e78e6de2d7439eeecb3f1115e8048e64f90.json | handle duplicates method in eloquent collections | tests/Database/DatabaseEloquentCollectionTest.php | @@ -245,6 +245,28 @@ public function testCollectionDiffsWithGivenCollection()
$this->assertEquals(new Collection([$one]), $c1->diff($c2));
}
+ public function testCollectionReturnsDuplicateBasedOnlyOnKeys()
+ {
+ $one = new TestEloquentCollectionModel();
+ $two = new TestEloquentCollectionModel();
+ $three = new TestEloquentCollectionModel();
+ $four = new TestEloquentCollectionModel();
+ $one->id = 1;
+ $one->someAttribute = '1';
+ $two->id = 1;
+ $two->someAttribute = '2';
+ $three->id = 1;
+ $three->someAttribute = '3';
+ $four->id = 2;
+ $four->someAttribute = '4';
+
+ $duplicates = Collection::make([$one, $two, $three, $four])->duplicates()->all();
+ $this->assertSame([1 => $two, 2 => $three], $duplicates);
+
+ $duplicates = Collection::make([$one, $two, $three, $four])->duplicatesStrict()->all();
+ $this->assertSame([1 => $two, 2 => $three], $duplicates);
+ }
+
public function testCollectionIntersectsWithGivenCollection()
{
$one = m::mock(Model::class); | true |
Other | laravel | framework | eabf73c99cd4d7fc8c767cd707884608e70215f7.json | Add static `rename` method to facade docblocks
This method is statically accessible from the schema facade. But IDE's are not recognizing it. | src/Illuminate/Support/Facades/Schema.php | @@ -7,6 +7,7 @@
* @method static \Illuminate\Database\Schema\Builder drop(string $table)
* @method static \Illuminate\Database\Schema\Builder dropIfExists(string $table)
* @method static \Illuminate\Database\Schema\Builder table(string $table, \Closure $callback)
+ * @method static \Illuminate\Database\Schema\Builder rename(string $from, string $to)
* @method static void defaultStringLength(int $length)
* @method static \Illuminate\Database\Schema\Builder disableForeignKeyConstraints()
* @method static \Illuminate\Database\Schema\Builder enableForeignKeyConstraints() | false |
Other | laravel | framework | 039a9745315f50e69d41b96a18e5b6131e8e164a.json | add unit tests | tests/Integration/Database/QueryBuilderTest.php | @@ -36,12 +36,14 @@ public function testWhereDate()
public function testWhereDay()
{
$this->assertSame(1, DB::table('posts')->whereDay('created_at', '02')->count());
+ $this->assertSame(1, DB::table('posts')->whereDay('created_at', 2)->count());
$this->assertSame(1, DB::table('posts')->whereDay('created_at', new Carbon('2018-01-02'))->count());
}
public function testWhereMonth()
{
$this->assertSame(1, DB::table('posts')->whereMonth('created_at', '01')->count());
+ $this->assertSame(1, DB::table('posts')->whereMonth('created_at', 1)->count());
$this->assertSame(1, DB::table('posts')->whereMonth('created_at', new Carbon('2018-01-02'))->count());
}
| false |
Other | laravel | framework | 73e63ed88ab1fdd39d24f3f2a2b5d32d9eb3b30d.json | Fix issue #28184 | src/Illuminate/Database/Query/Builder.php | @@ -1198,6 +1198,8 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and')
$value = $value->format('d');
}
+ $value = str_pad($value, 2, '0', STR_PAD_LEFT);
+
return $this->addDateBasedWhere('Day', $column, $operator, $value, $boolean);
}
@@ -1237,6 +1239,8 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and')
$value = $value->format('m');
}
+ $value = str_pad($value, 2, '0', STR_PAD_LEFT);
+
return $this->addDateBasedWhere('Month', $column, $operator, $value, $boolean);
}
| false |
Other | laravel | framework | dc4d98966c4ab4cce090b4feba5cb7f61d5b3f79.json | add duplicates method to collection | src/Illuminate/Support/Collection.php | @@ -407,6 +407,49 @@ public function diffKeysUsing($items, callable $callback)
return new static(array_diff_ukey($this->items, $this->getArrayableItems($items), $callback));
}
+ /**
+ * Retrieve duplicate items from the collection.
+ *
+ * @param callable|null $callback
+ * @param bool $strict
+ * @return static
+ */
+ public function duplicates($callback = null, $strict = false)
+ {
+ $items = $this->map($this->valueRetriever($callback));
+
+ $uniqueItems = $items->unique(null, $strict);
+
+ $compare = $strict ? function ($a, $b) {
+ return $a === $b;
+ } : function ($a, $b) {
+ return $a == $b;
+ };
+
+ $duplicates = new static;
+
+ foreach ($items as $key => $value) {
+ if ($uniqueItems->isNotEmpty() && $compare($value, $uniqueItems->first())) {
+ $uniqueItems->shift();
+ } else {
+ $duplicates[$key] = $value;
+ }
+ }
+
+ return $duplicates;
+ }
+
+ /**
+ * Retrieve duplicate items from the collection using strict comparison.
+ *
+ * @param callable|null $callback
+ * @return static
+ */
+ public function duplicatesStrict($callback = null)
+ {
+ return $this->duplicates($callback, true);
+ }
+
/**
* Execute a callback over each item.
* | true |
Other | laravel | framework | dc4d98966c4ab4cce090b4feba5cb7f61d5b3f79.json | add duplicates method to collection | tests/Support/SupportCollectionTest.php | @@ -745,6 +745,60 @@ public function testDiffAssocUsing()
$this->assertEquals(['b' => 'brown', 'c' => 'blue', 'red'], $c1->diffAssocUsing($c2, 'strcasecmp')->all());
}
+ public function testDuplicates()
+ {
+ $duplicates = Collection::make([1, 2, 1, 'laravel', null, 'laravel', 'php', null])->duplicates()->all();
+ $this->assertSame([2 => 1, 5 => 'laravel', 7 => null], $duplicates);
+
+ // does loose comparison
+ $duplicates = Collection::make([2, '2', [], null])->duplicates()->all();
+ $this->assertSame([1 => '2', 3 => null], $duplicates);
+
+ // works with mix of primitives
+ $duplicates = Collection::make([1, '2', ['laravel'], ['laravel'], null, '2'])->duplicates()->all();
+ $this->assertSame([3 => ['laravel'], 5 => '2'], $duplicates);
+
+ // works with mix of objects and primitives **excepts numbers**.
+ $expected = new Collection(['laravel']);
+ $duplicates = Collection::make([new Collection(['laravel']), $expected, $expected, [], '2', '2'])->duplicates()->all();
+ $this->assertSame([1 => $expected, 2 => $expected, 5 => '2'], $duplicates);
+ }
+
+ public function testDuplicatesWithKey()
+ {
+ $items = [['framework' => 'vue'], ['framework' => 'laravel'], ['framework' => 'laravel']];
+ $duplicates = Collection::make($items)->duplicates('framework')->all();
+ $this->assertSame([2 => 'laravel'], $duplicates);
+ }
+
+ public function testDuplicatesWithCallback()
+ {
+ $items = [['framework' => 'vue'], ['framework' => 'laravel'], ['framework' => 'laravel']];
+ $duplicates = Collection::make($items)->duplicates(function ($item) {
+ return $item['framework'];
+ })->all();
+ $this->assertSame([2 => 'laravel'], $duplicates);
+ }
+
+ public function testDuplicatesWithStrict()
+ {
+ $duplicates = Collection::make([1, 2, 1, 'laravel', null, 'laravel', 'php', null])->duplicatesStrict()->all();
+ $this->assertSame([2 => 1, 5 => 'laravel', 7 => null], $duplicates);
+
+ // does strict comparison
+ $duplicates = Collection::make([2, '2', [], null])->duplicatesStrict()->all();
+ $this->assertSame([], $duplicates);
+
+ // works with mix of primitives
+ $duplicates = Collection::make([1, '2', ['laravel'], ['laravel'], null, '2'])->duplicatesStrict()->all();
+ $this->assertSame([3 => ['laravel'], 5 => '2'], $duplicates);
+
+ // works with mix of primitives, objects, and numbers
+ $expected = new Collection(['laravel']);
+ $duplicates = Collection::make([new Collection(['laravel']), $expected, $expected, [], '2', '2'])->duplicatesStrict()->all();
+ $this->assertSame([2 => $expected, 5 => '2'], $duplicates);
+ }
+
public function testEach()
{
$c = new Collection($original = [1, 2, 'foo' => 'bar', 'bam' => 'baz']); | true |
Other | laravel | framework | dc8e71e174952f6810a9846a208395a17eee7569.json | track the exit code of scheduled event commands | src/Illuminate/Console/Scheduling/Event.php | @@ -143,6 +143,13 @@ class Event
*/
public $mutex;
+ /**
+ * The command exit status code.
+ *
+ * @var int
+ */
+ public $exitCode;
+
/**
* Create a new event instance.
*
@@ -208,7 +215,7 @@ protected function runCommandInForeground(Container $container)
{
$this->callBeforeCallbacks($container);
- Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
+ $this->exitCode = Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
$this->callAfterCallbacks($container);
} | false |
Other | laravel | framework | 6dd859397c614349f87fda660827900ab4363522.json | Add view path to end of compiled blade view
This re-adds the functionality that was added in https://github.com/laravel/framework/pull/27544 and https://github.com/laravel/framework/pull/27976 and removed again in https://github.com/laravel/framework/commit/33ce7bbb6a7f536036b58b66cc760fbb9eda80de.
The main difference with this approach is that it takes into account the issue from https://github.com/laravel/framework/issues/27996. By not introducing a newline it doesn't changes anything to the rendered view itself. The path is now applied as the final piece of code. This doesn't allows IDE's to rely on it being the last line though. Instead we use /**PATH and ENDPATH**/ to make sure we have an easy way for the IDE to pick up the path it needs. | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -122,6 +122,10 @@ public function compile($path = null)
$this->files->get($this->getPath())
);
+ if (! empty($this->getPath())) {
+ $contents .= "<?php /**PATH {$this->getPath()} ENDPATH**/ ?>";
+ }
+
$this->files->put(
$this->getCompiledPath($this->getPath()), $contents
); | true |
Other | laravel | framework | 6dd859397c614349f87fda660827900ab4363522.json | Add view path to end of compiled blade view
This re-adds the functionality that was added in https://github.com/laravel/framework/pull/27544 and https://github.com/laravel/framework/pull/27976 and removed again in https://github.com/laravel/framework/commit/33ce7bbb6a7f536036b58b66cc760fbb9eda80de.
The main difference with this approach is that it takes into account the issue from https://github.com/laravel/framework/issues/27996. By not introducing a newline it doesn't changes anything to the rendered view itself. The path is now applied as the final piece of code. This doesn't allows IDE's to rely on it being the last line though. Instead we use /**PATH and ENDPATH**/ to make sure we have an easy way for the IDE to pick up the path it needs. | tests/View/ViewBladeCompilerTest.php | @@ -49,15 +49,15 @@ public function testCompileCompilesFileAndReturnsContents()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
$compiler->compile('foo');
}
public function testCompileCompilesAndGetThePath()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
$compiler->compile('foo');
$this->assertEquals('foo', $compiler->getPath());
}
@@ -73,7 +73,7 @@ public function testCompileWithPathSetBefore()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
// set path before compilation
$compiler->setPath('foo');
// trigger compilation with null $path
@@ -97,7 +97,7 @@ public function testIncludePathToTemplate()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World<?php /**PATH foo ENDPATH**/ ?>');
$compiler->compile('foo');
}
| true |
Other | laravel | framework | 621ca8a3fd8fe9ea35ed97d80ae7d2a0de79d08a.json | Apply fixes from StyleCI (#28114) | tests/View/ViewBladeCompilerTest.php | @@ -49,15 +49,15 @@ public function testCompileCompilesFileAndReturnsContents()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World");
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
$compiler->compile('foo');
}
public function testCompileCompilesAndGetThePath()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World");
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
$compiler->compile('foo');
$this->assertEquals('foo', $compiler->getPath());
}
@@ -73,7 +73,7 @@ public function testCompileWithPathSetBefore()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World");
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
// set path before compilation
$compiler->setPath('foo');
// trigger compilation with null $path
@@ -97,7 +97,7 @@ public function testIncludePathToTemplate()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World");
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', 'Hello World');
$compiler->compile('foo');
}
| false |
Other | laravel | framework | 33ce7bbb6a7f536036b58b66cc760fbb9eda80de.json | remove path hint | src/Illuminate/View/Compilers/BladeCompiler.php | @@ -122,10 +122,6 @@ public function compile($path = null)
$this->files->get($this->getPath())
);
- if (! empty($this->getPath())) {
- $contents .= "\n<?php /* {$this->getPath()} */ ?>";
- }
-
$this->files->put(
$this->getCompiledPath($this->getPath()), $contents
); | true |
Other | laravel | framework | 33ce7bbb6a7f536036b58b66cc760fbb9eda80de.json | remove path hint | tests/View/ViewBladeCompilerTest.php | @@ -49,15 +49,15 @@ public function testCompileCompilesFileAndReturnsContents()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World\n<?php /* foo */ ?>");
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World");
$compiler->compile('foo');
}
public function testCompileCompilesAndGetThePath()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World\n<?php /* foo */ ?>");
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World");
$compiler->compile('foo');
$this->assertEquals('foo', $compiler->getPath());
}
@@ -73,7 +73,7 @@ public function testCompileWithPathSetBefore()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World\n<?php /* foo */ ?>");
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World");
// set path before compilation
$compiler->setPath('foo');
// trigger compilation with null $path
@@ -97,7 +97,7 @@ public function testIncludePathToTemplate()
{
$compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
$files->shouldReceive('get')->once()->with('foo')->andReturn('Hello World');
- $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World\n<?php /* foo */ ?>");
+ $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('foo').'.php', "Hello World");
$compiler->compile('foo');
}
| true |
Other | laravel | framework | 8587940d2f13e79e0ae4bed72cc744662742ef8b.json | Apply fixes from StyleCI (#28084) | tests/Foundation/Fixtures/EventDiscovery/Events/EventOne.php | @@ -2,4 +2,6 @@
namespace Illuminate\Tests\Foundation\Fixtures\EventDiscovery\Events;
-class EventOne {}
+class EventOne
+{
+} | true |
Other | laravel | framework | 8587940d2f13e79e0ae4bed72cc744662742ef8b.json | Apply fixes from StyleCI (#28084) | tests/Foundation/Fixtures/EventDiscovery/Events/EventTwo.php | @@ -2,4 +2,6 @@
namespace Illuminate\Tests\Foundation\Fixtures\EventDiscovery\Events;
-class EventTwo {}
+class EventTwo
+{
+} | true |
Other | laravel | framework | 7ea01d451274e7851e6f3292a84d078cdd06a12a.json | Improve tests for arguments in ability checks
Use `assertSame` because `assertEquals` doesn't compare object references.
Add assertions that the arguments are passed to the after callbacks. | tests/Auth/AuthAccessGateTest.php | @@ -348,11 +348,16 @@ public function test_a_single_argument_can_be_passed_when_checking_abilities()
});
$gate->define('foo', function ($user, $x) use ($dummy) {
- $this->assertEquals($dummy, $x);
+ $this->assertSame($dummy, $x);
return true;
});
+ $gate->after(function ($user, $ability, $result, array $arguments) use ($dummy) {
+ $this->assertCount(1, $arguments);
+ $this->assertSame($dummy, $arguments[0]);
+ });
+
$this->assertTrue($gate->check('foo', $dummy));
}
@@ -369,12 +374,17 @@ public function test_multiple_arguments_can_be_passed_when_checking_abilities()
});
$gate->define('foo', function ($user, $x, $y) use ($dummy1, $dummy2) {
- $this->assertEquals($dummy1, $x);
- $this->assertEquals($dummy2, $y);
+ $this->assertSame($dummy1, $x);
+ $this->assertSame($dummy2, $y);
return true;
});
+ $gate->after(function ($user, $ability, $result, array $arguments) use ($dummy1, $dummy2) {
+ $this->assertCount(2, $arguments);
+ $this->assertSame([$dummy1, $dummy2], $arguments);
+ });
+
$this->assertTrue($gate->check('foo', [$dummy1, $dummy2]));
}
| false |
Other | laravel | framework | 7d24f9183fcd2bb7159470a9454fe74fd88e12f5.json | add replicating model event | src/Illuminate/Database/Eloquent/Concerns/HasEvents.php | @@ -96,7 +96,7 @@ public function getObservableEvents()
return array_merge(
[
'retrieved', 'creating', 'created', 'updating', 'updated',
- 'saving', 'saved', 'restoring', 'restored',
+ 'saving', 'saved', 'restoring', 'restored', 'replicating',
'deleting', 'deleted', 'forceDeleted',
],
$this->observables
@@ -303,6 +303,17 @@ public static function created($callback)
static::registerModelEvent('created', $callback);
}
+ /**
+ * Register a replicating model event with the dispatcher.
+ *
+ * @param \Closure|string $callback
+ * @return void
+ */
+ public static function replicating($callback)
+ {
+ static::registerModelEvent('replicating', $callback);
+ }
+
/**
* Register a deleting model event with the dispatcher.
* | true |
Other | laravel | framework | 7d24f9183fcd2bb7159470a9454fe74fd88e12f5.json | add replicating model event | src/Illuminate/Database/Eloquent/Model.php | @@ -1175,6 +1175,8 @@ public function replicate(array $except = null)
$instance->setRawAttributes($attributes);
$instance->setRelations($this->relations);
+
+ $instance->fireModelEvent('replicating', false);
});
}
| true |
Other | laravel | framework | 7d24f9183fcd2bb7159470a9454fe74fd88e12f5.json | add replicating model event | tests/Database/DatabaseEloquentModelTest.php | @@ -1507,6 +1507,18 @@ public function testReplicateCreatesANewModelInstanceWithSameAttributeValues()
$this->assertNull($replicated->updated_at);
}
+ public function testReplicatingEventIsFiredWhenReplicatingModel()
+ {
+ $model = new EloquentModelStub;
+
+ $model->setEventDispatcher($events = m::mock(Dispatcher::class));
+ $events->shouldReceive('dispatch')->once()->with('eloquent.replicating: '.get_class($model), m::on(function ($m) use ($model) {
+ return $model->is($m);
+ }));
+
+ $model->replicate();
+ }
+
public function testIncrementOnExistingModelCallsQueryAndSetsAttribute()
{
$model = m::mock(EloquentModelStub::class.'[newQueryWithoutRelationships]'); | true |
Other | laravel | framework | e965a0a8b94fd79303eb2b1846605d4a9bc56be0.json | Add Env class | src/Illuminate/Support/Env.php | @@ -0,0 +1,55 @@
+<?php
+
+namespace Illuminate\Support;
+
+use PhpOption\Option;
+use Dotenv\Environment\DotenvFactory;
+use Dotenv\Environment\Adapter\PutenvAdapter;
+use Dotenv\Environment\Adapter\EnvConstAdapter;
+use Dotenv\Environment\Adapter\ServerConstAdapter;
+
+class Env
+{
+ /**
+ * Gets the value of an environment variable.
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public static function get($key, $default = null)
+ {
+ static $variables;
+
+ if ($variables === null) {
+ $variables = (new DotenvFactory([new EnvConstAdapter, new PutenvAdapter, new ServerConstAdapter]))->createImmutable();
+ }
+
+ return Option::fromValue($variables->get($key))
+ ->map(function ($value) {
+ switch (strtolower($value)) {
+ case 'true':
+ case '(true)':
+ return true;
+ case 'false':
+ case '(false)':
+ return false;
+ case 'empty':
+ case '(empty)':
+ return '';
+ case 'null':
+ case '(null)':
+ return;
+ }
+
+ if (preg_match('/\A([\'"])(.*)\1\z/', $value, $matches)) {
+ return $matches[2];
+ }
+
+ return $value;
+ })
+ ->getOrCall(function () use ($default) {
+ return value($default);
+ });
+ }
+} | true |
Other | laravel | framework | e965a0a8b94fd79303eb2b1846605d4a9bc56be0.json | Add Env class | src/Illuminate/Support/helpers.php | @@ -1,14 +1,11 @@
<?php
-use PhpOption\Option;
use Illuminate\Support\Arr;
+use Illuminate\Support\Env;
use Illuminate\Support\Optional;
use Illuminate\Support\Collection;
-use Dotenv\Environment\DotenvFactory;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\HigherOrderTapProxy;
-use Dotenv\Environment\Adapter\EnvConstAdapter;
-use Dotenv\Environment\Adapter\ServerConstAdapter;
if (! function_exists('append_config')) {
/**
@@ -265,38 +262,7 @@ function e($value, $doubleEncode = true)
*/
function env($key, $default = null)
{
- static $variables;
-
- if ($variables === null) {
- $variables = (new DotenvFactory([new EnvConstAdapter, new ServerConstAdapter]))->createImmutable();
- }
-
- return Option::fromValue($variables->get($key))
- ->map(function ($value) {
- switch (strtolower($value)) {
- case 'true':
- case '(true)':
- return true;
- case 'false':
- case '(false)':
- return false;
- case 'empty':
- case '(empty)':
- return '';
- case 'null':
- case '(null)':
- return;
- }
-
- if (preg_match('/\A([\'"])(.*)\1\z/', $value, $matches)) {
- return $matches[2];
- }
-
- return $value;
- })
- ->getOrCall(function () use ($default) {
- return value($default);
- });
+ return Env::get($key, $default);
}
}
| true |
Other | laravel | framework | e965a0a8b94fd79303eb2b1846605d4a9bc56be0.json | Add Env class | tests/Support/SupportHelpersTest.php | @@ -6,6 +6,7 @@
use ArrayAccess;
use Mockery as m;
use RuntimeException;
+use Illuminate\Support\Env;
use PHPUnit\Framework\TestCase;
use Illuminate\Support\Optional;
use Illuminate\Contracts\Support\Htmlable;
@@ -531,6 +532,7 @@ public function testEnv()
{
$_SERVER['foo'] = 'bar';
$this->assertSame('bar', env('foo'));
+ $this->assertSame('bar', Env::get('foo'));
}
public function testEnvTrue() | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.