Skip to content

Commit 4cf2c04

Browse files
Working on next version
1 parent 15f7862 commit 4cf2c04

16 files changed

+260
-67
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
/.github export-ignore
66
/.gitignore export-ignore
77
/.travis.yml export-ignore
8+
/phpstan.neon.dist export-ignore
89
/phpunit.xml.dist export-ignore
910
/README.md export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
composer.lock
2+
phpstan.neon
23
phpunit.xml
34
vendor

.travis.yml

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,94 @@
1-
dist: xenial
2-
31
matrix:
42
include:
5-
- env:
6-
- PHP_VERSION=5.6
7-
- env:
3+
- name: PHP 7.0; Symfony 3
4+
dist: xenial
5+
env:
86
- PHP_VERSION=7.0
9-
- env:
7+
- SYMFONY_VERSION=^3.4
8+
- RUN_PHPUNIT=true
9+
- name: PHP 7.1; Symfony 3
10+
dist: bionic
11+
env:
12+
- PHP_VERSION=7.1
13+
- SYMFONY_VERSION=^3.4
14+
- RUN_PHPUNIT=true
15+
- name: PHP 7.1; Symfony 4
16+
dist: bionic
17+
env:
1018
- PHP_VERSION=7.1
11-
- env:
19+
- SYMFONY_VERSION=^4.0
20+
- RUN_PHPUNIT=true
21+
- name: PHP 7.2; Symfony 3
22+
dist: bionic
23+
env:
24+
- PHP_VERSION=7.2
25+
- SYMFONY_VERSION=^3.4
26+
- RUN_PHPUNIT=true
27+
- name: PHP 7.2; Symfony 4
28+
dist: bionic
29+
env:
1230
- PHP_VERSION=7.2
13-
- env:
31+
- SYMFONY_VERSION=^4.0
32+
- RUN_PHPUNIT=true
33+
- name: PHP 7.2; Symfony 5
34+
dist: bionic
35+
env:
36+
- PHP_VERSION=7.2
37+
- SYMFONY_VERSION=^5.0
38+
- RUN_PHPUNIT=true
39+
- name: PHP 7.3; Symfony 3
40+
dist: bionic
41+
env:
42+
- PHP_VERSION=7.3
43+
- SYMFONY_VERSION=^3.4
44+
- RUN_PHPUNIT=true
45+
- name: PHP 7.3; Symfony 4
46+
dist: bionic
47+
env:
48+
- PHP_VERSION=7.3
49+
- SYMFONY_VERSION=^4.0
50+
- RUN_PHPUNIT=true
51+
- name: PHP 7.3; Symfony 5
52+
dist: bionic
53+
env:
1454
- PHP_VERSION=7.3
55+
- SYMFONY_VERSION=^5.0
56+
- RUN_PHPUNIT=true
57+
- name: PHP 7.4; Symfony 3
58+
dist: bionic
59+
env:
60+
- PHP_VERSION=7.4
61+
- SYMFONY_VERSION=^3.4
62+
- RUN_PHPUNIT=true
63+
- name: PHP 7.4; Symfony 4
64+
dist: bionic
65+
env:
66+
- PHP_VERSION=7.4
67+
- SYMFONY_VERSION=^4.0
68+
- RUN_PHPUNIT=true
69+
- name: PHP 7.4; Symfony 5
70+
dist: bionic
71+
env:
72+
- PHP_VERSION=7.4
73+
- SYMFONY_VERSION=^5.0
74+
- RUN_PHPUNIT=true
75+
- name: PHPStan
76+
dist: bionic
77+
env:
78+
- PHP_VERSION=7.4
79+
- RUN_PHPSTAN=true
1580

1681
before_install:
1782
- travis_retry docker pull registry.gitlab.com/grahamcampbell/php:$PHP_VERSION
83+
- if [[ ! -z $SYMFONY_VERSION ]]; then docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:$PHP_VERSION require "symfony/console:${SYMFONY_VERSION}" --no-update -n; fi
1884

1985
install:
2086
- travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:$PHP_VERSION install --no-suggest --prefer-dist -n -o
87+
- if [[ ! -z $RUN_PHPSTAN ]]; then travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint composer registry.gitlab.com/grahamcampbell/php:$PHP_VERSION bin phpstan install --no-suggest --prefer-dist -n -o; fi
2188

2289
script:
23-
- docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:$PHP_VERSION --coverage-clover build/logs/clover.xml
90+
- if [[ ! -z $RUN_PHPUNIT ]]; then docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit registry.gitlab.com/grahamcampbell/php:$PHP_VERSION --coverage-clover build/logs/clover.xml; fi
91+
- if [[ ! -z $RUN_PHPSTAN ]]; then docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan registry.gitlab.com/grahamcampbell/php:$PHP_VERSION analyse src; fi
2492

2593
after_script:
26-
- travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint ocular registry.gitlab.com/grahamcampbell/php:$PHP_VERSION code-coverage:upload --format=php-clover build/logs/clover.xml
94+
- if [[ ! -z $RUN_PHPUNIT ]]; then travis_retry docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint ocular registry.gitlab.com/grahamcampbell/php:$PHP_VERSION code-coverage:upload --format=php-clover build/logs/clover.xml; fi

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014-2019 Graham Campbell <[email protected]>
3+
Copyright (c) 2014-2020 Graham Campbell <[email protected]>
44
Copyright (c) 2013-2014 Michael Dowling <[email protected]>
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy

classpreloader.php renamed to bin/classpreloader

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
if (file_exists($autoloadPath = __DIR__.'/../../autoload.php')) {
15-
require_once $autoloadPath;
14+
if (file_exists(__DIR__.'/../vendor/autoload.php')) {
15+
require __DIR__.'/../vendor/autoload.php';
16+
} elseif (file_exists(__DIR__.'/../../../autoload.php')) {
17+
require __DIR__.'/../../../autoload.php';
18+
} elseif (file_exists(__DIR__.'/../autoload.php')) {
19+
require __DIR__.'/../autoload.php';
1620
} else {
17-
require_once __DIR__.'/vendor/autoload.php';
21+
throw new RuntimeException('Unable to locate autoload.php file.');
1822
}
1923

2024
$application = new ClassPreloader\Console\Application();

composer.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "classpreloader/console",
33
"description": "Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case",
4-
"keywords": ["autoload", "class", "preload"],
4+
"keywords": ["autoload", "class", "preload", "preloader"],
55
"license": "MIT",
66
"authors": [
77
{
@@ -13,13 +13,16 @@
1313
"email": "[email protected]"
1414
}
1515
],
16-
"require":{
17-
"php": "^5.6|^7.0",
16+
"require": {
17+
"php": "^7.0.8",
1818
"classpreloader/classpreloader": "^4.0",
19-
"symfony/console": "^2.3|^3.0|^4.0"
19+
"symfony/console": "^3.4|^4.0|^5.0",
20+
"symfony/polyfill-ctype": "^1.9"
2021
},
21-
"require-dev":{
22-
"phpunit/phpunit": "^5.7|^6.5|^7.5"
22+
"require-dev": {
23+
"bamarni/composer-bin-plugin": "^1.3",
24+
"phpunit/phpunit": "^6.5.10|^7.5.15",
25+
"graham-campbell/analyzer": "^2.4.1"
2326
},
2427
"autoload": {
2528
"psr-4": {
@@ -29,7 +32,7 @@
2932
"autoload-dev": {
3033
"classmap": ["tests/stubs/"]
3134
},
32-
"bin": ["classpreloader.php"],
35+
"bin": ["bin/classpreloader"],
3336
"config": {
3437
"preferred-install": "dist"
3538
},

phpstan-baseline.neon

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Only booleans are allowed in \\|\\|, int given on the left side\\.$#"
5+
count: 1
6+
path: src/ConfigResolver.php
7+
8+
-
9+
message: "#^Only booleans are allowed in &&, int given on the right side\\.$#"
10+
count: 1
11+
path: src/ConfigResolver.php
12+
13+
-
14+
message: "#^Cannot cast array\\<string\\>\\|bool\\|string\\|null to string\\.$#"
15+
count: 2
16+
path: src/PreCompileCommand.php
17+
18+
-
19+
message: "#^Anonymous function should have native return typehint \"Generator\"\\.$#"
20+
count: 1
21+
path: src/PreCompileCommand.php
22+
23+
-
24+
message: "#^Only numeric types are allowed in /, int\\|false given on the left side\\.$#"
25+
count: 1
26+
path: src/PreCompileCommand.php
27+
28+
-
29+
message: "#^Only booleans are allowed in a negated boolean, array\\<string\\>\\|bool\\|string\\|null given\\.$#"
30+
count: 2
31+
path: src/PreCompileCommand.php

phpstan.neon.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 8
3+
4+
includes:
5+
- phpstan-baseline.neon

phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
processIsolation="true"
1212
stopOnError="false"
1313
stopOnFailure="false"
14-
syntaxCheck="true"
1514
verbose="true"
1615
>
1716
<testsuites>

src/Application.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of Class Preloader.
57
*
@@ -19,7 +21,7 @@
1921
*
2022
* This is sets everything up for the CLI.
2123
*/
22-
class Application extends BaseApplication
24+
final class Application extends BaseApplication
2325
{
2426
/**
2527
* Create a new application instance.

src/ConfigResolver.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of Class Preloader.
57
*
@@ -12,34 +14,34 @@
1214

1315
namespace ClassPreloader\Console;
1416

15-
use ClassPreloader\Config;
17+
use ClassPreloader\ClassLoader\Config;
1618
use InvalidArgumentException;
1719

1820
/**
1921
* This is the config resolver class.
2022
*/
21-
class ConfigResolver
23+
final class ConfigResolver
2224
{
2325
/**
2426
* Get a list of files in order.
2527
*
26-
* @param mixed $config
28+
* @param string $config
2729
*
2830
* @throws \InvalidArgumentException
2931
*
30-
* @return array
32+
* @return string[]
3133
*/
32-
public function getFileList($config)
34+
public static function getFileList(string $config)
3335
{
34-
if (strpos($config, ',')) {
36+
if (strpos($config, ',') !== false) {
3537
return array_filter(explode(',', $config));
3638
}
3739

38-
if (!$this->isAbsolutePath($config)) {
40+
if (!self::isAbsolutePath($config)) {
3941
$config = getcwd().'/'.$config;
4042
}
4143

42-
if (!file_exists($config)) {
44+
if (!file_exists($config) || !is_readable($config)) {
4345
throw new InvalidArgumentException(sprintf('Configuration file "%s" does not exist.', $config));
4446
}
4547

@@ -63,7 +65,7 @@ public function getFileList($config)
6365
*
6466
* @return bool
6567
*/
66-
protected function isAbsolutePath($file)
68+
private static function isAbsolutePath($file)
6769
{
6870
return strspn($file, '/\\', 0, 1)
6971
|| (strlen($file) > 3 && ctype_alpha($file[0])

0 commit comments

Comments
 (0)