Skip to content

Commit afb733d

Browse files
authored
Merge pull request #5 from tattersoftware/tools
PHP 8 + Tools
2 parents 55c0431 + 70d412c commit afb733d

File tree

12 files changed

+235
-65
lines changed

12 files changed

+235
-65
lines changed

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/.github export-ignore
2+
/docs export-ignore
3+
/examples export-ignore
4+
/tests export-ignore
5+
/.editorconfig export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/phpstan.neon.dist export-ignore
10+
11+
# Configure diff output for .php and .phar files.
12+
*.php diff=php
13+
*.phar -diff

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: composer
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: daily

.github/workflows/analyze.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# When a PR is opened or a push is made, perform
2+
# a static analysis check on the code using PHPStan.
3+
name: PHPStan
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- 'develop'
9+
paths:
10+
- 'src/**'
11+
- 'tests/**'
12+
- 'composer.**'
13+
- 'phpstan*'
14+
- '.github/workflows/analyze.yml'
15+
push:
16+
branches:
17+
- 'develop'
18+
paths:
19+
- 'src/**'
20+
- 'tests/**'
21+
- 'composer.**'
22+
- 'phpstan*'
23+
- '.github/workflows/analyze.yml'
24+
25+
jobs:
26+
build:
27+
name: PHP ${{ matrix.php-versions }} Static Analysis
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
php-versions: ['7.3', '7.4', '8.0']
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v2
36+
37+
- name: Setup PHP
38+
uses: shivammathur/setup-php@v2
39+
with:
40+
php-version: ${{ matrix.php-versions }}
41+
tools: composer, pecl, phpunit
42+
extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3
43+
44+
- name: Get composer cache directory
45+
id: composer-cache
46+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
47+
48+
- name: Create composer cache directory
49+
run: mkdir -p ${{ steps.composer-cache.outputs.dir }}
50+
51+
- name: Cache composer dependencies
52+
uses: actions/cache@v2
53+
with:
54+
path: ${{ steps.composer-cache.outputs.dir }}
55+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
56+
restore-keys: ${{ runner.os }}-composer-
57+
58+
- name: Create PHPStan cache directory
59+
run: mkdir -p build/phpstan
60+
61+
- name: Cache PHPStan results
62+
uses: actions/cache@v2
63+
with:
64+
path: build/phpstan
65+
key: ${{ runner.os }}-phpstan-${{ github.sha }}
66+
restore-keys: ${{ runner.os }}-phpstan-
67+
68+
- name: Install dependencies
69+
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
70+
env:
71+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
72+
73+
- name: Run static analysis
74+
run: vendor/bin/phpstan analyze

.github/workflows/test.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ name: PHPUnit
22

33
on:
44
pull_request:
5-
branches:
5+
branches:
6+
- develop
7+
push:
8+
branches:
69
- develop
710

811
jobs:
912
main:
10-
name: Build and test
13+
name: PHP ${{ matrix.php-versions }} Unit Tests
1114

1215
strategy:
1316
matrix:
14-
php-versions: ['7.2', '7.3', '7.4']
17+
php-versions: ['7.3', '7.4', '8.0']
1518

1619
runs-on: ubuntu-latest
1720

@@ -34,16 +37,36 @@ jobs:
3437
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
3538

3639
- name: Cache composer dependencies
37-
uses: actions/cache@v1
40+
uses: actions/cache@v2
3841
with:
3942
path: ${{ steps.composer-cache.outputs.dir }}
4043
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
4144
restore-keys: ${{ runner.os }}-composer-
4245

4346
- name: Install dependencies
44-
run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader
47+
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
4548
env:
4649
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
4750

48-
- name: Test with phpunit
49-
run: vendor/bin/phpunit --coverage-text
51+
- name: Test with PHPUnit
52+
run: vendor/bin/phpunit --verbose --coverage-text
53+
54+
- if: matrix.php-versions == '7.4'
55+
name: Run Coveralls
56+
run: |
57+
composer global require php-coveralls/php-coveralls:^2.4
58+
php-coveralls --coverage_clover=build/logs/clover.xml -v
59+
env:
60+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
COVERALLS_PARALLEL: true
62+
COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} - ${{ matrix.db-platforms }}
63+
64+
coveralls:
65+
needs: [main]
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Coveralls Finished
69+
uses: coverallsapp/github-action@master
70+
with:
71+
github-token: ${{ secrets.GITHUB_TOKEN }}
72+
parallel-finished: true

composer.json

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "tatter/audits",
3+
"type": "library",
34
"description": "Lightweight object logging for CodeIgniter 4",
45
"keywords": [
56
"codeigniter",
@@ -18,31 +19,37 @@
1819
"role": "Developer"
1920
}
2021
],
21-
"repositories": [
22-
{
23-
"type": "vcs",
24-
"url": "https://github.com/codeigniter4/CodeIgniter4"
25-
}
26-
],
27-
"minimum-stability": "dev",
28-
"prefer-stable": true,
2922
"require": {
30-
"php" : ">=7.2"
23+
"php": "^7.3 || ^8.0"
3124
},
3225
"require-dev": {
33-
"phpunit/phpunit": "^8.5",
34-
"fzaninotto/faker": "^1.9@dev",
35-
"codeigniter4/codeigniter4": "dev-develop"
26+
"codeigniter4/codeigniter4": "dev-develop",
27+
"tatter/tools": "^1.4"
3628
},
3729
"autoload": {
3830
"psr-4": {
3931
"Tatter\\Audits\\": "src"
32+
},
33+
"exclude-from-classmap": [
34+
"**/Database/Migrations/**"
35+
]
36+
},
37+
"autoload-dev": {
38+
"psr-4": {
39+
"Tests\\Support\\": "tests/_support"
4040
}
4141
},
42+
"repositories": [
43+
{
44+
"type": "vcs",
45+
"url": "https://github.com/codeigniter4/CodeIgniter4"
46+
}
47+
],
48+
"minimum-stability": "dev",
49+
"prefer-stable": true,
4250
"scripts": {
43-
"test": "phpunit",
44-
"post-update-cmd": [
45-
"composer dump-autoload"
46-
]
51+
"analyze": "phpstan analyze",
52+
"style": "phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 tests/ src/",
53+
"test": "phpunit"
4754
}
4855
}

phpstan.neon.dist

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
parameters:
2+
tmpDir: build/phpstan
3+
level: 5
4+
paths:
5+
- src
6+
- tests
7+
bootstrapFiles:
8+
- vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php
9+
excludes_analyse:
10+
- src/Config/Routes.php
11+
- src/Views/*
12+
ignoreErrors:
13+
universalObjectCratesClasses:
14+
- CodeIgniter\Entity
15+
- Faker\Generator
16+
scanDirectories:
17+
- vendor/codeigniter4/codeigniter4/system/Helpers
18+
dynamicConstantNames:
19+
- APP_NAMESPACE
20+
- CI_DEBUG
21+
- ENVIRONMENT

src/Audits.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php namespace Tatter\Audits;
22

3-
use CodeIgniter\Config\BaseConfig;
43
use Tatter\Audits\Models\AuditModel;
4+
use Tatter\Audits\Config\Audits as AuditsConfig;
55

66
/*** CLASS ***/
77
class Audits
88
{
99
/**
1010
* Our configuration instance.
1111
*
12-
* @var \Tatter\Audits\Config\Audits
12+
* @var AuditsConfig
1313
*/
1414
protected $config;
1515

@@ -23,9 +23,9 @@ class Audits
2323
/**
2424
* Store the configuration
2525
*
26-
* @param BaseConfig $config The Audits configuration to use
26+
* @param AuditsConfig $config The Audits configuration to use
2727
*/
28-
public function __construct(BaseConfig $config)
28+
public function __construct(AuditsConfig $config)
2929
{
3030
$this->config = $config;
3131
}
@@ -58,7 +58,7 @@ public function getQueue(): array
5858
/**
5959
* Add an audit row to the queue
6060
*
61-
* @param array|null The row to cache for insert
61+
* @param array|null $audit The row to cache for insert
6262
*/
6363
public function add(array $audit = null)
6464
{

src/Config/Services.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
<?php namespace Tatter\Audits\Config;
22

3+
use Config\Services as BaseServices;
34
use Tatter\Audits\Audits;
5+
use Tatter\Audits\Config\Audits as AuditsConfig;
46

5-
class Services extends \Config\Services
7+
class Services extends BaseServices
68
{
7-
public static function audits(BaseConfig $config = null, bool $getShared = true)
9+
/**
10+
* @param AuditsConfig|null $config
11+
* @param bool $getShared
12+
*
13+
* @return Audits
14+
*/
15+
public static function audits(AuditsConfig $config = null, bool $getShared = true): Audits
816
{
917
if ($getShared)
1018
{

0 commit comments

Comments
 (0)