Skip to content

Commit

Permalink
Merge branch '11.x'
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Sep 26, 2024
2 parents 9d3b365 + 296f3f8 commit e0cf931
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 21 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"fruitcake/php-cors": "^1.3",
"guzzlehttp/guzzle": "^7.8",
"guzzlehttp/uri-template": "^1.0",
"laravel/prompts": "dev-l12",
"laravel/prompts": "^0.3.0",
"laravel/serializable-closure": "^1.3",
"league/commonmark": "^2.2.1",
"league/flysystem": "^3.8.0",
Expand Down
2 changes: 0 additions & 2 deletions phpstan.types.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ parameters:
level: max
paths:
- types
ignoreErrors:
- identifier: argument.templateType
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public function getOrPut($key, $value)
*
* @param (callable(TValue, TKey): TGroupKey)|array|string $groupBy
* @param bool $preserveKeys
* @return static<TGroupKey, static<($preserveKeys is true ? TKey : int), TValue>>
* @return static<($groupBy is string ? array-key : ($groupBy is array ? array-key : TGroupKey)), static<($preserveKeys is true ? TKey : int), TValue>>
*/
public function groupBy($groupBy, $preserveKeys = false)
{
Expand Down Expand Up @@ -542,7 +542,7 @@ public function groupBy($groupBy, $preserveKeys = false)
* @template TNewKey of array-key
*
* @param (callable(TValue, TKey): TNewKey)|array|string $keyBy
* @return static<TNewKey, TValue>
* @return static<($keyBy is string ? array-key : ($keyBy is array ? array-key : TNewKey)), TValue>
*/
public function keyBy($keyBy)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/Enumerable.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public function get($key, $default = null);
*
* @param (callable(TValue, TKey): TGroupKey)|array|string $groupBy
* @param bool $preserveKeys
* @return static<TGroupKey, static<($preserveKeys is true ? TKey : int), TValue>>
* @return static<($groupBy is string ? array-key : ($groupBy is array ? array-key : TGroupKey)), static<($preserveKeys is true ? TKey : int), TValue>>
*/
public function groupBy($groupBy, $preserveKeys = false);

Expand All @@ -532,7 +532,7 @@ public function groupBy($groupBy, $preserveKeys = false);
* @template TNewKey of array-key
*
* @param (callable(TValue, TKey): TNewKey)|array|string $keyBy
* @return static<TNewKey, TValue>
* @return static<($keyBy is string ? array-key : ($keyBy is array ? array-key : TNewKey)), TValue>
*/
public function keyBy($keyBy);

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public function get($key, $default = null)
*
* @param (callable(TValue, TKey): TGroupKey)|array|string $groupBy
* @param bool $preserveKeys
* @return static<TGroupKey, static<($preserveKeys is true ? TKey : int), TValue>>
* @return static<($groupBy is string ? array-key : ($groupBy is array ? array-key : TGroupKey)), static<($preserveKeys is true ? TKey : int), TValue>>
*/
public function groupBy($groupBy, $preserveKeys = false)
{
Expand All @@ -561,7 +561,7 @@ public function groupBy($groupBy, $preserveKeys = false)
* @template TNewKey of array-key
*
* @param (callable(TValue, TKey): TNewKey)|array|string $keyBy
* @return static<TNewKey, TValue>
* @return static<($keyBy is string ? array-key : ($keyBy is array ? array-key : TNewKey)), TValue>
*/
public function keyBy($keyBy)
{
Expand Down
12 changes: 12 additions & 0 deletions src/Illuminate/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,18 @@ public function computed($column, $expression)
return $this->addColumn('computed', $column, compact('expression'));
}

/**
* Create a new vector column on the table.
*
* @param string $column
* @param int $dimensions
* @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function vector($column, $dimensions)
{
return $this->addColumn('vector', $column, compact('dimensions'));
}

/**
* Add the proper columns for a polymorphic table.
*
Expand Down
11 changes: 11 additions & 0 deletions src/Illuminate/Database/Schema/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,17 @@ protected function typeComputed(Fluent $column)
throw new RuntimeException('This database driver does not support the computed type.');
}

/**
* Create the column definition for a vector type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeVector(Fluent $column)
{
throw new RuntimeException('This database driver does not support the vector type.');
}

/**
* Add the column modifiers to the definition.
*
Expand Down
11 changes: 11 additions & 0 deletions src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,17 @@ protected function typeComputed(Fluent $column)
throw new RuntimeException('This database driver requires a type, see the virtualAs / storedAs modifiers.');
}

/**
* Create the column definition for a vector type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeVector(Fluent $column)
{
return "vector($column->dimensions)";
}

/**
* Get the SQL for a generated virtual column modifier.
*
Expand Down
11 changes: 11 additions & 0 deletions src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,17 @@ protected function typeGeography(Fluent $column)
return 'geography';
}

/**
* Create the column definition for a vector type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeVector(Fluent $column)
{
return "vector($column->dimensions)";
}

/**
* Get the SQL for a collation column modifier.
*
Expand Down
12 changes: 7 additions & 5 deletions src/Illuminate/Foundation/Configuration/ApplicationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,14 @@ public function withMiddleware(?callable $callback = null)
*/
public function withCommands(array $commands = [])
{
if (empty($commands) && is_file($this->app->basePath('routes/console.php'))) {
$commands = [$this->app->basePath('routes/console.php')];
}
if (empty($commands)) {
if (is_file($this->app->basePath('routes/console.php'))) {
$commands = [$this->app->basePath('routes/console.php')];
}

if (empty($commands) && is_dir($this->app->path('Console/Commands'))) {
$commands = [$this->app->path('Console/Commands')];
if (is_dir($this->app->path('Console/Commands'))) {
$commands = [...$commands, $this->app->path('Console/Commands')];
}
}

$this->app->afterResolving(ConsoleKernel::class, function ($kernel) use ($commands) {
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/ListenerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function getStub()
*/
protected function alreadyExists($rawName)
{
return class_exists($rawName);
return class_exists($this->qualifyClass($rawName));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/VendorPublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class VendorPublishCommand extends Command
/**
* The provider to publish.
*
* @var string
* @var string|null
*/
protected $provider = null;

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Http/FileHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait FileHelpers
/**
* The cache copy of the file's hash name.
*
* @var string
* @var string|null
*/
protected $hashName = null;

Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Support/Process/PhpExecutableFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Support\Process;

use Symfony\Component\Process\ExecutableFinder;
use Symfony\Component\Process\PhpExecutableFinder as SymfonyPhpExecutableFinder;

class PhpExecutableFinder extends SymfonyPhpExecutableFinder
Expand Down
12 changes: 8 additions & 4 deletions src/Illuminate/Testing/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use Symfony\Component\HttpFoundation\StreamedResponse;

/**
* @template TResponse of \Symfony\Component\HttpFoundation\Response
*
* @mixin \Illuminate\Http\Response
*/
class TestResponse implements ArrayAccess
Expand All @@ -46,7 +48,7 @@ class TestResponse implements ArrayAccess
/**
* The response to delegate to.
*
* @var \Illuminate\Http\Response
* @var TResponse
*/
public $baseResponse;

Expand All @@ -67,7 +69,7 @@ class TestResponse implements ArrayAccess
/**
* Create a new test response instance.
*
* @param \Illuminate\Http\Response $response
* @param TResponse $response
* @param \Illuminate\Http\Request|null $request
* @return void
*/
Expand All @@ -81,9 +83,11 @@ public function __construct($response, $request = null)
/**
* Create a new TestResponse from another response.
*
* @param \Illuminate\Http\Response $response
* @template R of TResponse
*
* @param R $response
* @param \Illuminate\Http\Request|null $request
* @return static
* @return static<R>
*/
public static function fromBaseResponse($response, $request = null)
{
Expand Down
10 changes: 10 additions & 0 deletions tests/Database/DatabaseMySqlSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,16 @@ public function testAddingComment()
$this->assertSame("alter table `users` add `foo` varchar(255) not null comment 'Escape \\' when using words like it\\'s'", $statements[0]);
}

public function testAddingVector()
{
$blueprint = new Blueprint('embeddings');
$blueprint->vector('embedding', 384);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('alter table `embeddings` add `embedding` vector(384) not null', $statements[0]);
}

public function testCreateDatabase()
{
$connection = $this->getConnection();
Expand Down
10 changes: 10 additions & 0 deletions tests/Database/DatabasePostgresSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ public function testBasicCreateTable()
], $statements);
}

public function testAddingVector()
{
$blueprint = new Blueprint('embeddings');
$blueprint->vector('embedding', 384);
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('alter table "embeddings" add column "embedding" vector(384) not null', $statements[0]);
}

public function testCreateTableWithAutoIncrementStartingValue()
{
$blueprint = new Blueprint('users');
Expand Down
25 changes: 25 additions & 0 deletions types/Testing/TestResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Response;
use Illuminate\Testing\TestResponse;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;

use function PHPStan\Testing\assertType;

$response = TestResponse::fromBaseResponse(response('Laravel', 200));
assertType(Response::class, $response->baseResponse);

$response = TestResponse::fromBaseResponse(response()->redirectTo(''));
assertType(RedirectResponse::class, $response->baseResponse);

$response = TestResponse::fromBaseResponse(response()->download(''));
assertType(BinaryFileResponse::class, $response->baseResponse);

$response = TestResponse::fromBaseResponse(response()->json());
assertType(JsonResponse::class, $response->baseResponse);

$response = TestResponse::fromBaseResponse(response()->streamDownload(fn () => 1));
assertType(StreamedResponse::class, $response->baseResponse);

0 comments on commit e0cf931

Please sign in to comment.