Skip to content

Commit dc49168

Browse files
authored
Merge pull request #20 from tattersoftware/tools
Development Tools
2 parents ab5e21f + f2aab5e commit dc49168

File tree

13 files changed

+152
-24
lines changed

13 files changed

+152
-24
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: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
- 'phpstan*'
13+
- '.github/workflows/analyze.yml'
14+
push:
15+
branches:
16+
- 'develop'
17+
paths:
18+
- 'src/**'
19+
- 'tests/**'
20+
- 'phpstan*'
21+
- '.github/workflows/analyze.yml'
22+
23+
jobs:
24+
build:
25+
name: Analyze code
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v2
30+
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: '7.4'
35+
extensions: intl
36+
37+
- name: Get composer cache directory
38+
id: composer-cache
39+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
40+
41+
- name: Cache composer dependencies
42+
uses: actions/cache@v2
43+
with:
44+
path: ${{ steps.composer-cache.outputs.dir }}
45+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
46+
restore-keys: ${{ runner.os }}-composer-
47+
48+
- name: Create PHPStan cache directory
49+
run: mkdir -p build/phpstan
50+
51+
- name: Cache PHPStan results
52+
uses: actions/cache@v2
53+
with:
54+
path: build/phpstan
55+
key: ${{ runner.os }}-phpstan-${{ github.sha }}
56+
restore-keys: ${{ runner.os }}-phpstan-
57+
58+
- name: Install dependencies
59+
run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader
60+
env:
61+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
62+
63+
- name: Run static analysis
64+
run: vendor/bin/phpstan analyze

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
3535

3636
- name: Cache composer dependencies
37-
uses: actions/cache@v1
37+
uses: actions/cache@v2
3838
with:
3939
path: ${{ steps.composer-cache.outputs.dir }}
4040
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
@@ -46,4 +46,4 @@ jobs:
4646
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
4747

4848
- name: Test with phpunit
49-
run: vendor/bin/phpunit --coverage-text
49+
run: vendor/bin/phpunit --verbose --coverage-text

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/vendor/
1+
vendor/
22
build/
33
phpunit*.xml
44
phpunit

composer.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@
3232
},
3333
"require-dev": {
3434
"codeigniter4/codeigniter4": "dev-develop",
35-
"mikey179/vfsstream": "1.6.*",
36-
"phpunit/phpunit" : "^8.5"
35+
"fzaninotto/faker": "^1.9@dev",
36+
"mikey179/vfsstream": "^1.6",
37+
"phpunit/phpunit": "^8.5",
38+
"phpstan/phpstan": "^0.12",
39+
"squizlabs/php_codesniffer": "^3.5",
40+
"codeigniter4/codeigniter4-standard": "^1.0"
3741
},
3842
"autoload": {
3943
"psr-4": {
@@ -46,6 +50,8 @@
4650
}
4751
},
4852
"scripts": {
53+
"analyze": "phpstan analyze",
54+
"style": "phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 src/ tests/",
4955
"test": "phpunit",
5056
"post-update-cmd": [
5157
"composer dump-autoload"

phpstan.neon.dist

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
- '#Call to an undefined static method Config\\Services::manifests\(\)#'
14+
- '#Unsafe usage of new static\(\)*#'
15+
scanDirectories:
16+
- vendor/codeigniter4/codeigniter4/system/Helpers
17+
dynamicConstantNames:
18+
- APP_NAMESPACE
19+
- CI_DEBUG
20+
- ENVIRONMENT

phpunit.xml.dist

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</exclude>
2525
</whitelist>
2626
</filter>
27-
27+
2828
<logging>
2929
<log type="coverage-html" target="build/logs/html"/>
3030
<log type="coverage-clover" target="build/logs/clover.xml"/>
@@ -47,10 +47,6 @@
4747
<!-- Directory containing the front controller (index.php) -->
4848
<const name="PUBLICPATH" value="./vendor/codeigniter4/codeigniter4/public/"/>
4949

50-
<!-- https://getcomposer.org/xdebug -->
51-
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
52-
53-
<!-- Database configuration -->
5450
<!-- <env name="database.tests.hostname" value="localhost"/> -->
5551
<!-- <env name="database.tests.database" value="tests"/> -->
5652
<!-- <env name="database.tests.username" value="tests_user"/> -->

src/Config/Services.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
use CodeIgniter\Config\BaseService;
44
use CodeIgniter\View\RendererInterface;
5+
use Tatter\Assets\Libraries\Assets;
6+
use Tatter\Assets\Libraries\Manifests;
7+
use Tatter\Assets\Config\Assets as AssetsConfig;
58

69
class Services extends BaseService
710
{
8-
public static function assets(BaseConfig $config = null, bool $getShared = true)
11+
public static function assets(AssetsConfig $config = null, bool $getShared = true)
912
{
1013
if ($getShared)
1114
{
@@ -18,10 +21,10 @@ public static function assets(BaseConfig $config = null, bool $getShared = true)
1821
{
1922
$config = config('Assets');
2023
}
21-
return new \Tatter\Assets\Libraries\Assets($config);
24+
return new Assets($config);
2225
}
2326

24-
public static function manifests(BaseConfig $config = null, bool $getShared = true)
27+
public static function manifests(AssetsConfig $config = null, bool $getShared = true)
2528
{
2629
if ($getShared)
2730
{
@@ -34,6 +37,6 @@ public static function manifests(BaseConfig $config = null, bool $getShared = tr
3437
{
3538
$config = config('Assets');
3639
}
37-
return new \Tatter\Assets\Libraries\Manifests($config);
40+
return new Manifests($config);
3841
}
3942
}

src/Handlers/ConfigHandler.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
<?php namespace Tatter\Assets\Handlers;
22

3-
use CodeIgniter\Config\BaseConfig;
43
use Config\Services;
4+
use Tatter\Assets\Config\Assets as AssetsConfig;
55
use Tatter\Assets\Exceptions\AssetsException;
66
use Tatter\Assets\Handlers\DirectoryHandler;
77
use Tatter\Assets\Interfaces\AssetHandlerInterface;
88

99
class ConfigHandler implements AssetHandlerInterface
10-
{
10+
{
11+
/**
12+
* Our configuration instance.
13+
*
14+
* @var AssetsConfig
15+
*/
16+
protected $config;
17+
1118
/**
1219
* Instance of the directory handler for config routes
1320
* that point to directories instead of files.
1421
*
15-
* @var \Tatter\Assets\Handlers\DirectoryHandler
22+
* @var DirectoryHandler|null
1623
*/
1724
protected $directoryHandler;
1825

1926
// Save the config
20-
public function __construct(BaseConfig $config = null)
27+
public function __construct(AssetsConfig $config = null)
2128
{
2229
// Save the configuration
2330
$this->config = $config ?? config('Assets');

0 commit comments

Comments
 (0)