Skip to content

Commit 85f7883

Browse files
committed
fix: method extend error. add github action scripts
1 parent e8e525d commit 85f7883

File tree

9 files changed

+128
-17
lines changed

9 files changed

+128
-17
lines changed

.github/workflows/php.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Unit-tests
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
name: Test on php ${{ matrix.php}} and ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
timeout-minutes: 10
10+
strategy:
11+
fail-fast: true
12+
matrix:
13+
php: [7.1, 7.2, 7.3, 7.4, 8.0] #
14+
os: [ubuntu-latest, macOS-latest] # windows-latest,
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
# usage refer https://github.com/shivammathur/setup-php
21+
- name: Setup PHP
22+
timeout-minutes: 5
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php}}
26+
tools: pecl, php-cs-fixer, phpunit
27+
extensions: mbstring, dom, fileinfo, mysql, openssl, igbinary, redis # , swoole-4.4.19 #optional, setup extensions
28+
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
29+
coverage: none #optional, setup coverage driver: xdebug, none
30+
31+
- name: Display Env
32+
run: env
33+
34+
- name: Install dependencies
35+
run: composer install --no-progress --no-suggest
36+
37+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
38+
# Docs: https://getcomposer.org/doc/articles/scripts.md
39+
40+
- name: Run test suite
41+
run: phpunit

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Tag-release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
release:
10+
name: Test on php ${{ matrix.php}}
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 10
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
php: [7.3]
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Set ENV for github-release
23+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
24+
run: |
25+
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
26+
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
27+
28+
# usage refer https://github.com/shivammathur/setup-php
29+
- name: Setup PHP
30+
timeout-minutes: 5
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php}}
34+
tools: pecl, php-cs-fixer, phpunit
35+
extensions: mbstring, dom, fileinfo, mysql, openssl # , swoole-4.4.19 #optional, setup extensions
36+
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
37+
coverage: none #optional, setup coverage driver: xdebug, none
38+
39+
- name: Install dependencies # eg: v1.0.3
40+
run: |
41+
tag1=${GITHUB_REF#refs/*/}
42+
echo "release tag: ${tag1}"
43+
composer install --no-progress --no-suggest
44+
45+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
46+
# Docs: https://getcomposer.org/doc/articles/scripts.md
47+
48+
# - name: Build phar and send to github assets
49+
# run: |
50+
# echo $RELEASE_TAG
51+
# echo $RELEASE_NAME
52+
# php -d phar.readonly=0 bin/kite phar:pack -o kite-${RELEASE_TAG}.phar --no-progress
53+
# php kite-${RELEASE_TAG}.phar -V
54+
55+
# https://github.com/actions/create-release
56+
- uses: meeDamian/[email protected]
57+
with:
58+
gzip: false
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
tag: ${{ env.RELEASE_TAG }}
61+
name: ${{ env.RELEASE_TAG }}
62+
# files: kite-${{ env.RELEASE_TAG }}.phar

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ composer.lock
77
*.log
88
*.pid
99
*.patch
10+
*.cache
1011
.DS_Store

phpunit.xml.dist renamed to phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<phpunit backupGlobals="false"
44
backupStaticAttributes="false"
5-
bootstrap="test/boot.php"
5+
bootstrap="test/bootstrap.php"
66
colors="false"
77
convertErrorsToExceptions="true"
88
convertNoticesToExceptions="true"

src/FileFinder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,12 @@ public function ignoreVCS($ignoreVCS): self
317317
*
318318
* @return FileFinder
319319
*/
320-
public function ignoreDotFiles($ignoreDotFiles): self
320+
public function ignoreDotFiles(bool $ignoreDotFiles = true): self
321321
{
322322
if ($ignoreDotFiles) {
323-
$this->ignore |= static::IGNORE_DOT_FILES;
323+
$this->ignore |= self::IGNORE_DOT_FILES;
324324
} else {
325-
$this->ignore &= ~static::IGNORE_DOT_FILES;
325+
$this->ignore &= ~self::IGNORE_DOT_FILES;
326326
}
327327
return $this;
328328
}

src/Parser/IniParser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class IniParser extends AbstractParser
3232
/**
3333
* parse INI
3434
*
35-
* @param string $string Waiting for the parse data
36-
* @param bool $enhancement 启用增强功能,支持通过关键字 继承、导入、参考
37-
* @param callable $pathHandler When the second param is true, this param is valid.
38-
* @param string $fileDir When the second param is true, this param is valid.
35+
* @param string $string Waiting for the parse data
36+
* @param bool $enhancement 启用增强功能,支持通过关键字 继承、导入、参考
37+
* @param callable|null $pathHandler When the second param is true, this param is valid.
38+
* @param string $fileDir When the second param is true, this param is valid.
3939
*
4040
* @return array
4141
* @throws InvalidArgumentException

src/Traits/FileSystemFuncTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ trait FileSystemFuncTrait
2727
* @param string $dest
2828
* @param resource $context
2929
*/
30-
public static function copy(string $source, string $dest, $context = null): void
30+
public static function copyFile(string $source, string $dest, $context = null): void
3131
{
3232
if (false === copy($source, $dest, $context)) {
3333
throw new FileSystemException("copy file content failure");

test/IniParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Time: 20:25
77
*/
88

9-
namespace Toolkit\FsUtil\ParserTest;
9+
namespace Toolkit\FsUtilTest;
1010

1111
use PHPUnit\Framework\TestCase;
1212
use Toolkit\FsUtil\Parser\IniParser;

test/boot.php renamed to test/bootstrap.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@
77
ini_set('display_errors', 'On');
88
date_default_timezone_set('Asia/Shanghai');
99

10-
spl_autoload_register(function ($class) {
10+
spl_autoload_register(static function ($class) {
1111
$file = null;
1212

13-
if (0 === strpos($class, 'Toolkit\FsUtil\Parser\Example\\')) {
14-
$path = str_replace('\\', '/', substr($class, strlen('Toolkit\FsUtil\Parser\Example\\')));
13+
if (0 === strpos($class, 'Toolkit\FsUtil\Example\\')) {
14+
$path = str_replace('\\', '/', substr($class, strlen('Toolkit\FsUtil\Example\\')));
1515
$file = dirname(__DIR__) . "/example/{$path}.php";
16-
} elseif (0 === strpos($class, 'Toolkit\FsUtil\Parser\Test\\')) {
17-
$path = str_replace('\\', '/', substr($class, strlen('Toolkit\FsUtil\Parser\Test\\')));
16+
} elseif (0 === strpos($class, 'Toolkit\FsUtilTest\\')) {
17+
$path = str_replace('\\', '/', substr($class, strlen('Toolkit\FsUtilTest\\')));
1818
$file = __DIR__ . "/{$path}.php";
19-
} elseif (0 === strpos($class, 'Toolkit\FsUtil\Parser\\')) {
20-
$path = str_replace('\\', '/', substr($class, strlen('Toolkit\FsUtil\Parser\\')));
19+
} elseif (0 === strpos($class, 'Toolkit\FsUtil\\')) {
20+
$path = str_replace('\\', '/', substr($class, strlen('Toolkit\FsUtil\\')));
2121
$file = dirname(__DIR__) . "/src/{$path}.php";
2222
}
2323

2424
if ($file && is_file($file)) {
2525
include $file;
2626
}
2727
});
28+
29+
if (is_file(dirname(__DIR__, 3) . '/autoload.php')) {
30+
require dirname(__DIR__, 3) . '/autoload.php';
31+
} elseif (is_file(dirname(__DIR__) . '/vendor/autoload.php')) {
32+
require dirname(__DIR__) . '/vendor/autoload.php';
33+
}
34+

0 commit comments

Comments
 (0)