Skip to content

feat: initial laravel 9 compatibility #2344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
php-cs-fixer:
runs-on: ubuntu-latest
env:
PHP_CS_FIXER_VERSION: v2.18.7
PHP_CS_FIXER_VERSION: v3.6.0
strategy:
matrix:
php:
- '7.4'
- '8.0'
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -35,19 +35,14 @@ jobs:
strategy:
matrix:
include:
- { os: ubuntu-latest, php: 7.2, mongodb: 3.6, experimental: true }
- { os: ubuntu-latest, php: 7.2, mongodb: '4.0', experimental: true }
- { os: ubuntu-latest, php: 7.2, mongodb: 4.2, experimental: true }
- { os: ubuntu-latest, php: 7.2, mongodb: 4.4, experimental: true }
- { os: ubuntu-latest, php: 7.3, mongodb: 3.6, experimental: false }
- { os: ubuntu-latest, php: 7.3, mongodb: '4.0', experimental: false }
- { os: ubuntu-latest, php: 7.3, mongodb: 4.2, experimental: false }
- { os: ubuntu-latest, php: 7.3, mongodb: 4.4, experimental: false }
- { os: ubuntu-latest, php: 7.4, mongodb: 3.6, experimental: false }
- { os: ubuntu-latest, php: 7.4, mongodb: '4.0', experimental: false }
- { os: ubuntu-latest, php: 7.4, mongodb: 4.2, experimental: false }
- { os: ubuntu-latest, php: 7.4, mongodb: 4.4, experimental: false }
- { os: ubuntu-latest, php: 8.0, mongodb: '4.0', experimental: false }
- { os: ubuntu-latest, php: 8.0, mongodb: 4.2, experimental: false }
- { os: ubuntu-latest, php: 8.0, mongodb: 4.4, experimental: false }
- { os: ubuntu-latest, php: 8.0, mongodb: '5.0', experimental: false }
- { os: ubuntu-latest, php: 8.1, mongodb: '4.0', experimental: false }
- { os: ubuntu-latest, php: 8.1, mongodb: 4.2, experimental: false }
- { os: ubuntu-latest, php: 8.1, mongodb: 4.4, experimental: false }
- { os: ubuntu-latest, php: 8.1, mongodb: '5.0', experimental: false }
services:
mongo:
image: mongo:${{ matrix.mongodb }}
Expand Down Expand Up @@ -78,22 +73,18 @@ jobs:
env:
DEBUG: ${{secrets.DEBUG}}
- name: Download Composer cache dependencies from cache
if: (!startsWith(matrix.php, '7.2'))
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer dependencies
if: (!startsWith(matrix.php, '7.2'))
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ matrix.os }}-composer-
- name: Install dependencies
if: (!startsWith(matrix.php, '7.2'))
run: |
composer install --no-interaction
- name: Run tests
if: (!startsWith(matrix.php, '7.2'))
run: |
./vendor/bin/phpunit --coverage-clover coverage.xml
env:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
.DS_Store
.idea/
.phpunit.result.cache
/.php_cs
/.php_cs.cache
/.php-cs-fixer.php
/.php-cs-fixer.cache
/vendor
composer.lock
composer.phar
Expand Down
35 changes: 24 additions & 11 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
],
'cast_spaces' => true,
'class_definition' => true,
'class_definition' => false,
'clean_namespace' => true,
'compact_nullable_typehint' => true,
'concat_space' => [
Expand All @@ -46,16 +46,22 @@
'heredoc_to_nowdoc' => true,
'include' => true,
'indentation_type' => true,
'integer_literal_case' => true,
'braces' => false,
'lowercase_cast' => true,
'lowercase_constants' => true,
'constant_case' => [
'case' => 'lower',
],
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'method_argument_space' => true,
'method_argument_space' => [
'on_multiline' => 'ignore',
],
'class_attributes_separation' => [
'elements' => [
'method',
'method' => 'one',
],
],
'visibility_required' => [
Expand All @@ -74,7 +80,6 @@
'tokens' => [
'throw',
'use',
'use_trait',
'extra',
],
],
Expand All @@ -87,6 +92,7 @@
'multiline_whitespace_before_semicolons' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_space_around_double_colon' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => [
'positions' => [
Expand Down Expand Up @@ -120,7 +126,9 @@
'phpdoc_summary' => true,
'phpdoc_trim' => true,
'phpdoc_no_alias_tag' => [
'type' => 'var',
'replacements' => [
'type' => 'var',
],
],
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
Expand All @@ -130,7 +138,6 @@
'no_mixed_echo_print' => [
'use' => 'echo',
],
'braces' => true,
'return_type_declaration' => [
'space_before' => 'none',
],
Expand All @@ -153,22 +160,28 @@
'switch_case_space' => true,
'switch_continue_to_break' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => [
'elements' => [
'arrays',
],
],
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'types_spaces' => [
'space' => 'none',
],
'line_ending' => true,
'whitespace_after_comma_in_array' => true,
'no_alias_functions' => true,
'no_unreachable_default_argument_value' => true,
'psr4' => true,
'psr_autoloading' => true,
'self_accessor' => true,
];

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

$config = new PhpCsFixer\Config();
return $config
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules($rules)
->setFinder($finder);
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added
- Compatibility with Laravel 9.x [#2344](https://github.com/jenssegers/laravel-mongodb/pull/2344) by [@divine](https://github.com/divine).

## [3.8.4] - 2021-05-27

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PHP_VERSION=7.4
ARG PHP_VERSION=8.0
ARG COMPOSER_VERSION=2.0

FROM composer:${COMPOSER_VERSION}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Make sure you have the MongoDB PHP driver installed. You can find installation i

Laravel | Package | Maintained
:---------|:---------------|:----------
9.x | 3.9.x | :white_check_mark:
8.x | 3.8.x | :white_check_mark:
7.x | 3.7.x | :x:
6.x | 3.6.x | :white_check_mark:
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
],
"license": "MIT",
"require": {
"illuminate/support": "^8.0",
"illuminate/container": "^8.0",
"illuminate/database": "^8.0",
"illuminate/events": "^8.0",
"mongodb/mongodb": "^1.6"
"illuminate/support": "^9.0",
"illuminate/container": "^9.0",
"illuminate/database": "^9.0",
"illuminate/events": "^9.0",
"mongodb/mongodb": "^1.11"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.5.8",
"orchestra/testbench": "^7.0",
"mockery/mockery": "^1.3.1",
"doctrine/dbal": "^2.6"
"doctrine/dbal": "^2.13.3|^3.1.4"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions src/Auth/PasswordResetServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class PasswordResetServiceProvider extends BasePasswordResetServiceProvider
{
/**
* Register the token repository implementation.
*
* @return void
*/
protected function registerTokenRepository()
Expand Down
5 changes: 4 additions & 1 deletion src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ class Collection
{
/**
* The connection instance.
*
* @var Connection
*/
protected $connection;

/**
* The MongoCollection instance..
* The MongoCollection instance.
*
* @var MongoCollection
*/
protected $collection;
Expand All @@ -32,6 +34,7 @@ public function __construct(Connection $connection, MongoCollection $collection)

/**
* Handle dynamic method calls.
*
* @param string $method
* @param array $parameters
* @return mixed
Expand Down
16 changes: 16 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ class Connection extends BaseConnection
{
/**
* The MongoDB database handler.
*
* @var \MongoDB\Database
*/
protected $db;

/**
* The MongoDB connection handler.
*
* @var \MongoDB\Client
*/
protected $connection;

/**
* Create a new database connection instance.
*
* @param array $config
*/
public function __construct(array $config)
Expand Down Expand Up @@ -53,6 +56,7 @@ public function __construct(array $config)

/**
* Begin a fluent query against a database collection.
*
* @param string $collection
* @return Query\Builder
*/
Expand All @@ -65,6 +69,7 @@ public function collection($collection)

/**
* Begin a fluent query against a database collection.
*
* @param string $table
* @param string|null $as
* @return Query\Builder
Expand All @@ -76,6 +81,7 @@ public function table($table, $as = null)

/**
* Get a MongoDB collection.
*
* @param string $name
* @return Collection
*/
Expand All @@ -94,6 +100,7 @@ public function getSchemaBuilder()

/**
* Get the MongoDB database object.
*
* @return \MongoDB\Database
*/
public function getMongoDB()
Expand All @@ -103,6 +110,7 @@ public function getMongoDB()

/**
* return MongoDB object.
*
* @return \MongoDB\Client
*/
public function getMongoClient()
Expand All @@ -120,6 +128,7 @@ public function getDatabaseName()

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

/**
* Create a new MongoDB connection.
*
* @param string $dsn
* @param array $config
* @param array $options
Expand Down Expand Up @@ -175,6 +185,7 @@ public function disconnect()

/**
* Determine if the given configuration array has a dsn string.
*
* @param array $config
* @return bool
*/
Expand All @@ -185,6 +196,7 @@ protected function hasDsnString(array $config)

/**
* Get the DSN string form configuration.
*
* @param array $config
* @return string
*/
Expand All @@ -195,6 +207,7 @@ protected function getDsnString(array $config)

/**
* Get the DSN string for a host / port configuration.
*
* @param array $config
* @return string
*/
Expand All @@ -218,6 +231,7 @@ protected function getHostDsn(array $config)

/**
* Create a DSN string from a configuration.
*
* @param array $config
* @return string
*/
Expand Down Expand Up @@ -270,6 +284,7 @@ protected function getDefaultSchemaGrammar()

/**
* Set database.
*
* @param \MongoDB\Database $db
*/
public function setDatabase(\MongoDB\Database $db)
Expand All @@ -279,6 +294,7 @@ public function setDatabase(\MongoDB\Database $db)

/**
* Dynamically pass methods to the connection.
*
* @param string $method
* @param array $parameters
* @return mixed
Expand Down
1 change: 1 addition & 0 deletions src/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Builder extends EloquentBuilder

/**
* The methods that should be returned from query builder.
*
* @var array
*/
protected $passthru = [
Expand Down
Loading