Skip to content

Commit 5757476

Browse files
feat: add Laravel 12 support (#355)
* Bump dependencies for Laravel 12 * Update config.yml * Update composer.json * phpstan * Update TestCase.php --------- Co-authored-by: Shift <[email protected]>
1 parent a8eb07d commit 5757476

11 files changed

+29
-24
lines changed

.circleci/config.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,10 @@ workflows:
9595
- test:
9696
matrix:
9797
parameters:
98-
version: ['8.2']
98+
version: ['8.2', '8.3', '8.4']
9999
laravel: ['^11.0']
100+
- test:
101+
matrix:
102+
parameters:
103+
version: ['8.2', '8.3', '8.4']
104+
laravel: ['^12.0']

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
"php": "^8.0",
2626
"ext-json": "*",
2727
"algolia/algoliasearch-client-php": "^3.0.0",
28-
"illuminate/console": "^9.0|^10.0|^11.0",
29-
"illuminate/contracts": "^9.0|^10.0|^11.0",
30-
"illuminate/database": "^9.0|^10.0|^11.0",
31-
"illuminate/filesystem": "^9.0|^10.0|^11.0",
32-
"illuminate/support": "^9.0|^10.0|^11.0",
28+
"illuminate/console": "^9.0|^10.0|^11.0|^12.0",
29+
"illuminate/contracts": "^9.0|^10.0|^11.0|^12.0",
30+
"illuminate/database": "^9.0|^10.0|^11.0|^12.0",
31+
"illuminate/filesystem": "^9.0|^10.0|^11.0|^12.0",
32+
"illuminate/support": "^9.0|^10.0|^11.0|^12.0",
3333
"laravel/scout": "^9.0|^10.0",
3434
"riimu/kit-phpencoder": "^2.4"
3535
},
@@ -39,10 +39,10 @@
3939
"require-dev": {
4040
"fakerphp/faker": "^1.13",
4141
"mockery/mockery": "^1.4",
42-
"nunomaduro/larastan": "^1.0|^2.0",
43-
"orchestra/testbench": "^4.9|^5.9|^6.6|^7.0|^8.0|^9.0",
44-
"phpstan/phpstan": "^1.3",
45-
"phpunit/phpunit": "^8.0|^9.0|^10.5",
42+
"larastan/larastan": "^1.0|^2.0|^3.0",
43+
"orchestra/testbench": "^4.9|^5.9|^6.6|^7.0|^8.0|^9.0|^10.0",
44+
"phpstan/phpstan": "^1.3|^2.1",
45+
"phpunit/phpunit": "^8.0|^9.0|^10.5|^11.5.3",
4646
"laravel/legacy-factories": "^1.1"
4747
},
4848
"autoload-dev": {

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- vendor/nunomaduro/larastan/extension.neon
2+
- vendor/larastan/larastan/extension.neon
33
parameters:
44
level: 5
55
paths:

src/Exceptions/ModelNotDefinedInAggregatorException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ModelNotDefinedInAggregatorException extends RuntimeException
2121
/**
2222
* {@inheritdoc}
2323
*/
24-
public function __construct(string $message = '', int $code = 0, Throwable $previous = null)
24+
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
2525
{
2626
if (empty($message)) {
2727
$message = 'Model not defined in aggregator.';

src/Exceptions/SettingsNotFound.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class SettingsNotFound extends Exception
2121
/**
2222
* {@inheritdoc}
2323
*/
24-
public function __construct(string $message = '', int $code = 0, Throwable $previous = null)
24+
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
2525
{
2626
if (empty($message)) {
2727
$message = 'Settings not found.';

src/ScoutExtendedServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private function registerCommands(): void
125125
*/
126126
private function registerMacros(): void
127127
{
128-
\Illuminate\Database\Eloquent\Builder::macro('transform', function (array $array, array $transformers = null) {
128+
\Illuminate\Database\Eloquent\Builder::macro('transform', function (array $array, ?array $transformers = null) {
129129
foreach ($transformers ?? UpdateJob::getTransformers() as $transformer) {
130130
$array = app($transformer)->transform($this->getModel(), $array);
131131
}

src/Searchable/AggregatorCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function unsearchable(): void
4747
/**
4848
* Prepare the instance for serialization.
4949
*
50-
* @return array []string
50+
* @return string[]
5151
*/
5252
public function __sleep()
5353
{

src/Searchable/ObjectIdEncrypter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ObjectIdEncrypter
3737
*
3838
* @return string
3939
*/
40-
public static function encrypt($searchable, int $part = null): string
40+
public static function encrypt($searchable, ?int $part = null): string
4141
{
4242
$scoutKey = method_exists($searchable, 'getScoutKey') ? $searchable->getScoutKey() : $searchable->getKey();
4343

@@ -89,7 +89,7 @@ private static function getSearchableExploded(string $objectId): array
8989
{
9090
$parts = explode(self::$separator, $objectId);
9191

92-
if (! is_array($parts) || count($parts) < 2) {
92+
if (count($parts) < 2) {
9393
throw new ShouldReimportSearchableException('ObjectID seems invalid. You may need to
9494
re-import your data using the `scout-reimport` Artisan command.');
9595
}

src/Settings/LocalFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function isCustomRanking(string $key, $value): bool
223223
*/
224224
public function isDisableTypoToleranceOnAttributes(string $key, $value): bool
225225
{
226-
return is_string($key) && Str::is(self::$disableTypoToleranceOnAttributesKeys, $key);
226+
return Str::is(self::$disableTypoToleranceOnAttributesKeys, $key);
227227
}
228228

229229
/**
@@ -236,7 +236,7 @@ public function isDisableTypoToleranceOnAttributes(string $key, $value): bool
236236
*/
237237
public function isUnretrievableAttributes(string $key, $value): bool
238238
{
239-
return is_string($key) && Str::is(self::$unretrievableAttributes, $key);
239+
return Str::is(self::$unretrievableAttributes, $key);
240240
}
241241

242242
/**

src/Splitters/HtmlSplitter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ class HtmlSplitter implements SplitterContract
3535
/**
3636
* Creates a new instance of the class.
3737
*
38-
* @param array $tags
38+
* @param array|null $tags
3939
*
4040
* @return void
4141
*/
42-
public function __construct(array $tags = null)
42+
public function __construct(?array $tags = null)
4343
{
4444
if ($tags !== null) {
4545
$this->tags = $tags;

tests/TestCase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function defaults(): array
8181
return $defaults;
8282
}
8383

84-
protected function assertLocalHas(array $settings, string $settingsPath = null): void
84+
protected function assertLocalHas(array $settings, ?string $settingsPath = null): void
8585
{
8686
if ($settingsPath === null) {
8787
$settingsPath = config_path('scout-users.php');
@@ -145,7 +145,7 @@ protected function mockClient(): MockInterface
145145
return $clientMock;
146146
}
147147

148-
protected function mockIndex(string $model, array $settings = [], array $userData = null): MockInterface
148+
protected function mockIndex(string $model, array $settings = [], ?array $userData = null): MockInterface
149149
{
150150
$indexMock = mock(SearchIndex::class);
151151
$indexName = class_exists($model) ? (new $model)->searchableAs() : $model;
@@ -173,7 +173,7 @@ protected function mockIndex(string $model, array $settings = [], array $userDat
173173
return $indexMock;
174174
}
175175

176-
protected function assertSettingsSet($indexMock, array $settings, array $userData = null): void
176+
protected function assertSettingsSet($indexMock, array $settings, ?array $userData = null): void
177177
{
178178
if (! empty($settings)) {
179179
$indexMock->shouldReceive('setSettings')->once()->with($settings)->andReturn($this->mockResponse());

0 commit comments

Comments
 (0)