Skip to content

Commit

Permalink
Merge branch '5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tylernathanreed committed Sep 25, 2023
2 parents f8f0ee8 + 2525bf8 commit 0ed7b15
Show file tree
Hide file tree
Showing 37 changed files with 808 additions and 587 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Lint

on: [push]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: json, dom, curl, libxml, mbstring
coverage: none

- name: Install Pint
run: composer global require laravel/pint

- name: Run Pint
run: pint

- name: Commit linted files
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fixed code styling
6 changes: 3 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: coverage
name: Coverage

on:
push:
pull_request:

jobs:
linux_tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

strategy:
fail-fast: true
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, gd, xdebug
tools: composer:v2
coverage: xdebug
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Static Analysis

on:
push:
pull_request:

jobs:
static:
name: Static Analysis
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: ['8.1', '8.2']

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, dom, curl, libxml, mbstring
coverage: none

- name: Install Dependencies
run: composer update --prefer-stable --no-interaction --no-progress --ansi

- name: Run Static Analysis
run: composer test:static
36 changes: 0 additions & 36 deletions .github/workflows/style.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: tests
name: Tests

on:
push:
pull_request:

jobs:
linux_tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: ['7.3', '7.4', '8.0', '8.1']
php: ['8.0', '8.1', '8.2']
stability: [prefer-lowest, prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
Expand All @@ -33,7 +33,7 @@ jobs:
with:
timeout_minutes: 5
max_attempts: 2
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress ${{ matrix.flags }}
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit --verbose
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Laravel Relation Joins

[![Laravel Version](https://img.shields.io/badge/Laravel-8.x%2F9.x%2F10.x-blue)](https://laravel.com/)
[![Laravel Version](https://img.shields.io/badge/Laravel-9.x%2F10.x%2F11.x-blue)](https://laravel.com/)
[![Build Status](https://github.com/tylernathanreed/laravel-relation-joins/workflows/tests/badge.svg)](https://github.com/tylernathanreed/laravel-relation-joins/actions)
[![Style Status](https://github.com/tylernathanreed/laravel-relation-joins/workflows/style/badge.svg)](https://github.com/tylernathanreed/laravel-relation-joins/actions)
[![Coverage Status](https://coveralls.io/repos/github/tylernathanreed/laravel-relation-joins/badge.svg?branch=master)](https://coveralls.io/github/tylernathanreed/laravel-relation-joins?branch=master)
Expand Down Expand Up @@ -62,11 +62,15 @@ Reedware\LaravelRelationJoins\LaravelRelationJoinServiceProvider::class
<a name="versioning"></a>
### Versioning

This package was built with the latest version of Laravel in mind, but support goes back to Laravel 8.x.
This package is maintained with the latest version of Laravel in mind, but support follows Laravel's [Support Policy](https://laravel.com/docs/master/releases#support-policy).

For Laravel 7.x, use version 3.x of this package.
For Laravel 6.x, use version 2.x of this package.
For Laravel 5.5, use version 1.x of this package.
| Package | Laravel | PHP |
| :-----: | :--------: | :--------: |
| 5.x | 9.x - 11.x | 8.0 - 8.2+ |
| 4.x | 8.x - 10.x | 7.3 - 8.0+ |
| 3.x | 7.x - 9.x | 7.2 - 8.0+ |
| 2.x | 6.x - 8.x | 7.2 - 8.0+ |
| 1.x | 5.5 - 8.x | 7.1 - 8.0+ |

<a name="usage"></a>
## Usage
Expand Down
40 changes: 31 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"name": "reedware/laravel-relation-joins",
"description": "Adds the ability to join on a relationship by name.",
"keywords": ["laravel", "relation", "join", "eloquent", "query"],
"keywords": [
"laravel",
"relation",
"join",
"eloquent",
"query"
],
"license": "MIT",
"authors": [
{
Expand All @@ -10,17 +16,18 @@
}
],
"require": {
"php": ">=7.3",
"illuminate/contracts": "^8.83|^9.52|^10.0",
"illuminate/database": "^8.83|^9.52|^10.0",
"illuminate/support": "^8.83|^9.52|^10.0"
"php": ">=8.0",
"illuminate/contracts": "^9.52|^10.0",
"illuminate/database": "^9.52|^10.0",
"illuminate/support": "^9.52|^10.0"
},
"require-dev": {
"illuminate/container": "^8.83|^9.52|^10.0",
"mockery/mockery": "^1.5.1",
"illuminate/container": "^9.52|^10.0",
"laravel/pint": "^1.5",
"mockery/mockery": "^1.6.6",
"php-coveralls/php-coveralls": "^2.4",
"phpunit/phpunit": "^8.5.33|^9.5",
"squizlabs/php_codesniffer": "^3.6"
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand All @@ -38,5 +45,20 @@
"Reedware\\LaravelRelationJoins\\LaravelRelationJoinServiceProvider"
]
}
},
"minimum-stability": "stable",
"config": {
"sort-packages": true,
"preferred-install": "dist"
},
"scripts": {
"test:coverage": [
"@test:suite",
"php-coveralls -v --dry-run"
],
"test:static": "phpstan",
"test:style": "pint --test",
"test:style-fix": "pint",
"test:suite": "phpunit --verbose"
}
}
33 changes: 33 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
parameters:
level: 6
paths:
- src
excludePaths:
- tests/*
stubFiles:
- stubs/EloquentBuilder.stub
- stubs/QueryBuilder.stub
- stubs/Relation.stub
ignoreErrors:
-
message: '#Call to protected method \w+\(\) of class Illuminate\\Database\\Eloquent\\Builder.#'
path: src/Mixins/JoinsRelationships.php
-
message: '#Access to protected property Illuminate\\Database\\Eloquent\\Builder::\$\w+.#'
path: src/Mixins/JoinsRelationships.php
















48 changes: 10 additions & 38 deletions src/EloquentJoinClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,21 @@ class EloquentJoinClause extends JoinClause
{
/**
* The model associated to this join.
*
* @var \Illuminate\Database\Eloquent\Model
*/
public $model;
public Model $model;

/**
* The eloquent query representing this join.
*
* @var \Illuminate\Database\Eloquent\Builder
*/
public $eloquent;
public Eloquent $eloquent;

/**
* Whether or not a method call is being forwarded through eloquent.
*
* @var boolean
*/
protected $forwardingCall = false;
protected bool $forwardingCall = false;

/**
* Create a new join clause instance.
*
* @param \Illuminate\Database\Query\JoinClause $parentJoin
* @param \Illuminate\Database\Eloquent\Model $model
*
* @return $this
*/
public function __construct(JoinClause $parentJoin, Model $model)
{
Expand All @@ -55,12 +44,8 @@ public function __construct(JoinClause $parentJoin, Model $model)

/**
* Merges the properties of the parent join into this join.
*
* @param \Illuminate\Database\Query\Builder $query
*
* @return void
*/
protected function mergeQuery(Builder $query)
protected function mergeQuery(Builder $query): void
{
$properties = (new ReflectionClass(Builder::class))->getProperties();

Expand All @@ -77,10 +62,8 @@ protected function mergeQuery(Builder $query)

/**
* Apply the scopes to the eloquent builder instance and return it.
*
* @return static
*/
public function applyScopes()
public function applyScopes(): static
{
$query = $this->eloquent->applyScopes();

Expand All @@ -91,10 +74,8 @@ public function applyScopes()

/**
* Returns a new query builder for the model's table.
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function newEloquentQuery()
public function newEloquentQuery(): Eloquent
{
return $this->model->registerGlobalScopes(
$this->newModelQuery()
Expand All @@ -103,42 +84,33 @@ public function newEloquentQuery()

/**
* Returns a new eloquent builder that doesn't have any global scopes or eager loading.
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function newModelQuery()
public function newModelQuery(): Eloquent
{
return $this->newEloquentBuilder()->setModel($this->model);
}

/**
* Returns a new eloquent builder for this join clause.
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function newEloquentBuilder()
public function newEloquentBuilder(): Eloquent
{
return new Eloquent($this);
}

/**
* Get a new instance of the join clause builder.
*
* @return \Illuminate\Database\Query\JoinClause
*/
public function newQuery()
public function newQuery(): JoinClause
{
return new JoinClause($this->newParentQuery(), $this->type, $this->table);
}

/**
* Handle dynamic method calls into the method.
*
* @phpcs:disable Squiz.Commenting.FunctionComment
*
* @param string $method
* @param array $parameters
*
* @param array<mixed> $parameters
* @return mixed
*/
public function __call($method, $parameters)
Expand Down
Loading

0 comments on commit 0ed7b15

Please sign in to comment.