Skip to content
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

[9.x] WIP: Add PHPSTAN workflow #712

Draft
wants to merge 2 commits into
base: 9.x
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: "Continuous Integration"

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
- cron: '0 0 * * *'

jobs:
tests:
phpunit:

runs-on: ubuntu-latest
services:
Expand All @@ -19,8 +19,8 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.0, 8.1]
stability: [prefer-stable]
php: [ 8.0, 8.1 ]
stability: [ prefer-stable ]

name: PHP ${{ matrix.php }} - STABILITY ${{ matrix.stability }}

Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Static Analysis"

on:
push:
paths:
- .github/workflows/static-analysis.yml
- composer.*
- phpstan.neon.dist
- src/**
- tests/**

pull_request:
paths:
- .github/workflows/static-analysis.yml
- composer.*
- phpstan.neon.dist
- src/**
- tests/**

schedule:
- cron: '0 0 * * *'

jobs:
static-analysis-phpstan:

name: "Static Analysis with PHPStan"
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.1]
stability: [prefer-stable]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: none

- name: Install dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: COMPOSER_ROOT_VERSION=dev-master composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan --error-format=checkstyle"
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"require-dev": {
"doctrine/dbal": "^3.3",
"mockery/mockery": "^1.4.4",
"nunomaduro/larastan": "^2.1",
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.5.8"
},
Expand Down
17 changes: 17 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon

parameters:

paths:
- src

level: max

ignoreErrors:
- '#Unsafe usage of new static\(\).#'

excludePaths:
- src/helper.php

checkMissingIterableValueType: false
15 changes: 11 additions & 4 deletions src/Oci8/Auth/OracleUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Yajra\Oci8\Auth;

use Illuminate\Auth\EloquentUserProvider;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Str;

class OracleUserProvider extends EloquentUserProvider
Expand All @@ -13,10 +14,10 @@ class OracleUserProvider extends EloquentUserProvider
* @param array $credentials
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveByCredentials(array $credentials)
public function retrieveByCredentials(array $credentials): ?Authenticatable
{
if (empty($credentials)) {
return;
return null;
}

// First we will add each credential element to the query as a where clause.
Expand All @@ -26,10 +27,16 @@ public function retrieveByCredentials(array $credentials)

foreach ($credentials as $key => $value) {
if (! Str::contains($key, 'password')) {
$query->whereRaw("upper({$key}) = upper(?)", [$value]);
$query->whereRaw("upper($key) = upper(?)", [$value]);
}
}

return $query->first();
$model = $query->first();

if (! $model instanceof Authenticatable) {
return null;
}

return $model;
}
}
Loading