Skip to content

Commit 1e49c5e

Browse files
authored
Merge pull request #2344 from divine/l9
feat: initial laravel 9 compatibility
2 parents 6cdd309 + b6a76f9 commit 1e49c5e

37 files changed

+218
-43
lines changed

Diff for: .github/workflows/build-ci.yml

+9-18
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
php-cs-fixer:
1111
runs-on: ubuntu-latest
1212
env:
13-
PHP_CS_FIXER_VERSION: v2.18.7
13+
PHP_CS_FIXER_VERSION: v3.6.0
1414
strategy:
1515
matrix:
1616
php:
17-
- '7.4'
17+
- '8.0'
1818
steps:
1919
- name: Checkout
2020
uses: actions/checkout@v2
@@ -35,19 +35,14 @@ jobs:
3535
strategy:
3636
matrix:
3737
include:
38-
- { os: ubuntu-latest, php: 7.2, mongodb: 3.6, experimental: true }
39-
- { os: ubuntu-latest, php: 7.2, mongodb: '4.0', experimental: true }
40-
- { os: ubuntu-latest, php: 7.2, mongodb: 4.2, experimental: true }
41-
- { os: ubuntu-latest, php: 7.2, mongodb: 4.4, experimental: true }
42-
- { os: ubuntu-latest, php: 7.3, mongodb: 3.6, experimental: false }
43-
- { os: ubuntu-latest, php: 7.3, mongodb: '4.0', experimental: false }
44-
- { os: ubuntu-latest, php: 7.3, mongodb: 4.2, experimental: false }
45-
- { os: ubuntu-latest, php: 7.3, mongodb: 4.4, experimental: false }
46-
- { os: ubuntu-latest, php: 7.4, mongodb: 3.6, experimental: false }
47-
- { os: ubuntu-latest, php: 7.4, mongodb: '4.0', experimental: false }
48-
- { os: ubuntu-latest, php: 7.4, mongodb: 4.2, experimental: false }
49-
- { os: ubuntu-latest, php: 7.4, mongodb: 4.4, experimental: false }
38+
- { os: ubuntu-latest, php: 8.0, mongodb: '4.0', experimental: false }
39+
- { os: ubuntu-latest, php: 8.0, mongodb: 4.2, experimental: false }
5040
- { os: ubuntu-latest, php: 8.0, mongodb: 4.4, experimental: false }
41+
- { os: ubuntu-latest, php: 8.0, mongodb: '5.0', experimental: false }
42+
- { os: ubuntu-latest, php: 8.1, mongodb: '4.0', experimental: false }
43+
- { os: ubuntu-latest, php: 8.1, mongodb: 4.2, experimental: false }
44+
- { os: ubuntu-latest, php: 8.1, mongodb: 4.4, experimental: false }
45+
- { os: ubuntu-latest, php: 8.1, mongodb: '5.0', experimental: false }
5146
services:
5247
mongo:
5348
image: mongo:${{ matrix.mongodb }}
@@ -78,22 +73,18 @@ jobs:
7873
env:
7974
DEBUG: ${{secrets.DEBUG}}
8075
- name: Download Composer cache dependencies from cache
81-
if: (!startsWith(matrix.php, '7.2'))
8276
id: composer-cache
8377
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
8478
- name: Cache Composer dependencies
85-
if: (!startsWith(matrix.php, '7.2'))
8679
uses: actions/cache@v1
8780
with:
8881
path: ${{ steps.composer-cache.outputs.dir }}
8982
key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}
9083
restore-keys: ${{ matrix.os }}-composer-
9184
- name: Install dependencies
92-
if: (!startsWith(matrix.php, '7.2'))
9385
run: |
9486
composer install --no-interaction
9587
- name: Run tests
96-
if: (!startsWith(matrix.php, '7.2'))
9788
run: |
9889
./vendor/bin/phpunit --coverage-clover coverage.xml
9990
env:

Diff for: .gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
.DS_Store
55
.idea/
66
.phpunit.result.cache
7-
/.php_cs
8-
/.php_cs.cache
7+
/.php-cs-fixer.php
8+
/.php-cs-fixer.cache
99
/vendor
1010
composer.lock
1111
composer.phar

Diff for: .php_cs.dist renamed to .php-cs-fixer.dist.php

+24-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
],
2626
],
2727
'cast_spaces' => true,
28-
'class_definition' => true,
28+
'class_definition' => false,
2929
'clean_namespace' => true,
3030
'compact_nullable_typehint' => true,
3131
'concat_space' => [
@@ -46,16 +46,22 @@
4646
'heredoc_to_nowdoc' => true,
4747
'include' => true,
4848
'indentation_type' => true,
49+
'integer_literal_case' => true,
50+
'braces' => false,
4951
'lowercase_cast' => true,
50-
'lowercase_constants' => true,
52+
'constant_case' => [
53+
'case' => 'lower',
54+
],
5155
'lowercase_keywords' => true,
5256
'lowercase_static_reference' => true,
5357
'magic_constant_casing' => true,
5458
'magic_method_casing' => true,
55-
'method_argument_space' => true,
59+
'method_argument_space' => [
60+
'on_multiline' => 'ignore',
61+
],
5662
'class_attributes_separation' => [
5763
'elements' => [
58-
'method',
64+
'method' => 'one',
5965
],
6066
],
6167
'visibility_required' => [
@@ -74,7 +80,6 @@
7480
'tokens' => [
7581
'throw',
7682
'use',
77-
'use_trait',
7883
'extra',
7984
],
8085
],
@@ -87,6 +92,7 @@
8792
'multiline_whitespace_before_semicolons' => true,
8893
'no_short_bool_cast' => true,
8994
'no_singleline_whitespace_before_semicolons' => true,
95+
'no_space_around_double_colon' => true,
9096
'no_spaces_after_function_name' => true,
9197
'no_spaces_around_offset' => [
9298
'positions' => [
@@ -120,7 +126,9 @@
120126
'phpdoc_summary' => true,
121127
'phpdoc_trim' => true,
122128
'phpdoc_no_alias_tag' => [
123-
'type' => 'var',
129+
'replacements' => [
130+
'type' => 'var',
131+
],
124132
],
125133
'phpdoc_types' => true,
126134
'phpdoc_var_without_name' => true,
@@ -130,7 +138,6 @@
130138
'no_mixed_echo_print' => [
131139
'use' => 'echo',
132140
],
133-
'braces' => true,
134141
'return_type_declaration' => [
135142
'space_before' => 'none',
136143
],
@@ -153,22 +160,28 @@
153160
'switch_case_space' => true,
154161
'switch_continue_to_break' => true,
155162
'ternary_operator_spaces' => true,
156-
'trailing_comma_in_multiline_array' => true,
163+
'trailing_comma_in_multiline' => [
164+
'elements' => [
165+
'arrays',
166+
],
167+
],
157168
'trim_array_spaces' => true,
158169
'unary_operator_spaces' => true,
170+
'types_spaces' => [
171+
'space' => 'none',
172+
],
159173
'line_ending' => true,
160174
'whitespace_after_comma_in_array' => true,
161175
'no_alias_functions' => true,
162176
'no_unreachable_default_argument_value' => true,
163-
'psr4' => true,
177+
'psr_autoloading' => true,
164178
'self_accessor' => true,
165179
];
166180

167181
$finder = PhpCsFixer\Finder::create()
168182
->in(__DIR__);
169183

170-
$config = new PhpCsFixer\Config();
171-
return $config
184+
return (new PhpCsFixer\Config())
172185
->setRiskyAllowed(true)
173186
->setRules($rules)
174187
->setFinder($finder);

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
55

6+
### Added
7+
- Compatibility with Laravel 9.x [#2344](https://github.com/jenssegers/laravel-mongodb/pull/2344) by [@divine](https://github.com/divine).
8+
69
## [3.8.4] - 2021-05-27
710

811
### Fixed

Diff for: Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PHP_VERSION=7.4
1+
ARG PHP_VERSION=8.0
22
ARG COMPOSER_VERSION=2.0
33

44
FROM composer:${COMPOSER_VERSION}

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Make sure you have the MongoDB PHP driver installed. You can find installation i
5858

5959
Laravel | Package | Maintained
6060
:---------|:---------------|:----------
61+
9.x | 3.9.x | :white_check_mark:
6162
8.x | 3.8.x | :white_check_mark:
6263
7.x | 3.7.x | :x:
6364
6.x | 3.6.x | :white_check_mark:

Diff for: composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
],
2020
"license": "MIT",
2121
"require": {
22-
"illuminate/support": "^8.0",
23-
"illuminate/container": "^8.0",
24-
"illuminate/database": "^8.0",
25-
"illuminate/events": "^8.0",
26-
"mongodb/mongodb": "^1.6"
22+
"illuminate/support": "^9.0",
23+
"illuminate/container": "^9.0",
24+
"illuminate/database": "^9.0",
25+
"illuminate/events": "^9.0",
26+
"mongodb/mongodb": "^1.11"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^9.0",
30-
"orchestra/testbench": "^6.0",
29+
"phpunit/phpunit": "^9.5.8",
30+
"orchestra/testbench": "^7.0",
3131
"mockery/mockery": "^1.3.1",
32-
"doctrine/dbal": "^2.6"
32+
"doctrine/dbal": "^2.13.3|^3.1.4"
3333
},
3434
"autoload": {
3535
"psr-4": {

Diff for: src/Auth/PasswordResetServiceProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class PasswordResetServiceProvider extends BasePasswordResetServiceProvider
88
{
99
/**
1010
* Register the token repository implementation.
11+
*
1112
* @return void
1213
*/
1314
protected function registerTokenRepository()

Diff for: src/Collection.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ class Collection
1010
{
1111
/**
1212
* The connection instance.
13+
*
1314
* @var Connection
1415
*/
1516
protected $connection;
1617

1718
/**
18-
* The MongoCollection instance..
19+
* The MongoCollection instance.
20+
*
1921
* @var MongoCollection
2022
*/
2123
protected $collection;
@@ -32,6 +34,7 @@ public function __construct(Connection $connection, MongoCollection $collection)
3234

3335
/**
3436
* Handle dynamic method calls.
37+
*
3538
* @param string $method
3639
* @param array $parameters
3740
* @return mixed

Diff for: src/Connection.php

+16
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ class Connection extends BaseConnection
1111
{
1212
/**
1313
* The MongoDB database handler.
14+
*
1415
* @var \MongoDB\Database
1516
*/
1617
protected $db;
1718

1819
/**
1920
* The MongoDB connection handler.
21+
*
2022
* @var \MongoDB\Client
2123
*/
2224
protected $connection;
2325

2426
/**
2527
* Create a new database connection instance.
28+
*
2629
* @param array $config
2730
*/
2831
public function __construct(array $config)
@@ -53,6 +56,7 @@ public function __construct(array $config)
5356

5457
/**
5558
* Begin a fluent query against a database collection.
59+
*
5660
* @param string $collection
5761
* @return Query\Builder
5862
*/
@@ -65,6 +69,7 @@ public function collection($collection)
6569

6670
/**
6771
* Begin a fluent query against a database collection.
72+
*
6873
* @param string $table
6974
* @param string|null $as
7075
* @return Query\Builder
@@ -76,6 +81,7 @@ public function table($table, $as = null)
7681

7782
/**
7883
* Get a MongoDB collection.
84+
*
7985
* @param string $name
8086
* @return Collection
8187
*/
@@ -94,6 +100,7 @@ public function getSchemaBuilder()
94100

95101
/**
96102
* Get the MongoDB database object.
103+
*
97104
* @return \MongoDB\Database
98105
*/
99106
public function getMongoDB()
@@ -103,6 +110,7 @@ public function getMongoDB()
103110

104111
/**
105112
* return MongoDB object.
113+
*
106114
* @return \MongoDB\Client
107115
*/
108116
public function getMongoClient()
@@ -120,6 +128,7 @@ public function getDatabaseName()
120128

121129
/**
122130
* Get the name of the default database based on db config or try to detect it from dsn.
131+
*
123132
* @param string $dsn
124133
* @param array $config
125134
* @return string
@@ -140,6 +149,7 @@ protected function getDefaultDatabaseName($dsn, $config)
140149

141150
/**
142151
* Create a new MongoDB connection.
152+
*
143153
* @param string $dsn
144154
* @param array $config
145155
* @param array $options
@@ -175,6 +185,7 @@ public function disconnect()
175185

176186
/**
177187
* Determine if the given configuration array has a dsn string.
188+
*
178189
* @param array $config
179190
* @return bool
180191
*/
@@ -185,6 +196,7 @@ protected function hasDsnString(array $config)
185196

186197
/**
187198
* Get the DSN string form configuration.
199+
*
188200
* @param array $config
189201
* @return string
190202
*/
@@ -195,6 +207,7 @@ protected function getDsnString(array $config)
195207

196208
/**
197209
* Get the DSN string for a host / port configuration.
210+
*
198211
* @param array $config
199212
* @return string
200213
*/
@@ -218,6 +231,7 @@ protected function getHostDsn(array $config)
218231

219232
/**
220233
* Create a DSN string from a configuration.
234+
*
221235
* @param array $config
222236
* @return string
223237
*/
@@ -270,6 +284,7 @@ protected function getDefaultSchemaGrammar()
270284

271285
/**
272286
* Set database.
287+
*
273288
* @param \MongoDB\Database $db
274289
*/
275290
public function setDatabase(\MongoDB\Database $db)
@@ -279,6 +294,7 @@ public function setDatabase(\MongoDB\Database $db)
279294

280295
/**
281296
* Dynamically pass methods to the connection.
297+
*
282298
* @param string $method
283299
* @param array $parameters
284300
* @return mixed

Diff for: src/Eloquent/Builder.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Builder extends EloquentBuilder
1313

1414
/**
1515
* The methods that should be returned from query builder.
16+
*
1617
* @var array
1718
*/
1819
protected $passthru = [

0 commit comments

Comments
 (0)