diff --git a/.cs.php b/.cs.php
index e4ab7fc..2bba5e9 100644
--- a/.cs.php
+++ b/.cs.php
@@ -1,6 +1,8 @@
setUsingCache(false)
->setRiskyAllowed(true)
->setRules(
@@ -19,6 +21,12 @@
'concat_space' => ['spacing' => 'one'],
'compact_nullable_typehint' => true,
'declare_equal_normalize' => ['space' => 'single'],
+ 'general_phpdoc_annotation_remove' => [
+ 'annotations' => [
+ 'author',
+ 'package',
+ ],
+ ],
'increment_style' => ['style' => 'post'],
'list_syntax' => ['syntax' => 'short'],
'echo_tag_syntax' => ['format' => 'long'],
@@ -32,9 +40,22 @@
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
- 'imports_order' => ['class', 'const', 'function']
+ 'imports_order' => ['class', 'const', 'function'],
],
'single_line_throw' => false,
+ 'declare_strict_types' => false,
+ 'blank_line_between_import_groups' => true,
+ 'fully_qualified_strict_types' => true,
+ 'no_null_property_initialization' => false,
+ 'operator_linebreak' => [
+ 'only_booleans' => true,
+ 'position' => 'beginning',
+ ],
+ 'global_namespace_import' => [
+ 'import_classes' => true,
+ 'import_constants' => null,
+ 'import_functions' => null
+ ]
]
)
->setFinder(
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..0a6abee
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,22 @@
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+end_of_line = lf
+
+[composer.json]
+indent_size = 4
+
+[*.js]
+indent_size = 4
+
+[*.neon]
+indent_size = 4
+indent_style = tab
+
+[*.xml]
+indent_size = 4
+
+[*.yml]
+indent_size = 4
diff --git a/.gitattributes b/.gitattributes
index 0e58fb3..5a3d341 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -19,10 +19,8 @@
/phpunit.xml export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
-/.travis.* export-ignore
/.scrutinizer.* export-ignore
/.editorconfig export-ignore
-/.coveralls.* export-ignore
# Define binary file attributes.
# - Do not treat them as text.
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7878383..a4bf3d5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -3,46 +3,39 @@ name: build
on: [ push, pull_request ]
jobs:
- run:
- runs-on: ${{ matrix.operating-system }}
- strategy:
- matrix:
- operating-system: [ubuntu-latest]
- php-versions: ['7.3', '7.4', '8.0']
- name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
-
- steps:
- - name: Checkout
- uses: actions/checkout@v1
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-versions }}
- extensions: mbstring, intl, zip
- coverage: none
-
- - name: Check PHP Version
- run: php -v
-
- - name: Check Composer Version
- run: composer -V
-
- - name: Check PHP Extensions
- run: php -m
-
- - name: Validate composer.json and composer.lock
- run: composer validate
-
- - name: Install dependencies for PHP 7
- if: matrix.php-versions < '8.0'
- run: composer update --prefer-dist --no-progress
-
- - name: Install dependencies for PHP 8
- if: matrix.php-versions >= '8.0'
- run: composer update --prefer-dist --no-progress --ignore-platform-req=php
-
- - name: Run test suite
- run: composer check
- env:
- PHP_CS_FIXER_IGNORE_ENV: 1
+ run:
+ runs-on: ${{ matrix.operating-system }}
+ strategy:
+ matrix:
+ operating-system: [ ubuntu-latest ]
+ php-versions: [ '8.1', '8.2' ]
+ name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v1
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php-versions }}
+ extensions: mbstring, intl, zip
+ coverage: none
+
+ - name: Check PHP Version
+ run: php -v
+
+ - name: Check Composer Version
+ run: composer -V
+
+ - name: Check PHP Extensions
+ run: php -m
+
+ - name: Validate composer.json and composer.lock
+ run: composer validate
+
+ - name: Install dependencies
+ run: composer install --prefer-dist --no-progress --no-suggest
+
+ - name: Run test suite
+ run: composer test:all
diff --git a/.gitignore b/.gitignore
index 22f5e7f..a4689b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@ composer.lock
nbproject/
vendor/
build/
+.phpunit.cache/
.phpunit.result.cache
\ No newline at end of file
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index b68bf00..3514e2e 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -1,6 +1,6 @@
filter:
- paths: ["src/*"]
- excluded_paths: ["vendor/*", "tests/*"]
+ paths: [ "src/*" ]
+ excluded_paths: [ "vendor/*", "tests/*" ]
checks:
php:
@@ -13,9 +13,9 @@ tools:
build:
environment:
php:
- version: 7.4
- pecl_extensions:
- - zip
+ version: 8.1.2
+ ini:
+ xdebug.mode: coverage
mysql: false
node: false
postgresql: false
@@ -33,11 +33,9 @@ build:
dependencies:
before:
- composer self-update
- - composer update --no-interaction --prefer-dist --no-progress
tests:
before:
- -
- command: composer test:coverage
+ - command: composer test:coverage
coverage:
file: 'build/logs/clover.xml'
format: 'clover'
diff --git a/LICENSE b/LICENSE
index fa19b85..bf7a9a3 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2021 odan
+Copyright (c) 2023 odan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/composer.json b/composer.json
index 2a40979..04a701c 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,8 @@
{
"name": "selective/zip-responder",
- "type": "library",
"description": "A ZIP file and a stream responder (PSR-7)",
+ "license": "MIT",
+ "type": "library",
"keywords": [
"zip",
"psr7",
@@ -12,7 +13,6 @@
"slim"
],
"homepage": "https://github.com/selective-php/zip-responder",
- "license": "MIT",
"require": {
"php": "^7.3 || ^8.0",
"nyholm/psr7": "^1.4",
@@ -22,13 +22,9 @@
"friendsofphp/php-cs-fixer": "^3",
"maennchen/zipstream-php": "^2.1",
"nelexa/zip": "^3.3 || ^4",
- "overtrue/phplint": "^2.3",
"phpstan/phpstan": "^1",
- "phpunit/phpunit": "^9",
- "squizlabs/php_codesniffer": "^3.5"
- },
- "config": {
- "sort-packages": true
+ "phpunit/phpunit": "^10",
+ "squizlabs/php_codesniffer": "^3"
},
"autoload": {
"psr-4": {
@@ -40,21 +36,28 @@
"Selective\\Http\\Zip\\Test\\": "tests/"
}
},
+ "config": {
+ "sort-packages": true
+ },
"scripts": {
- "check": [
- "@lint",
- "@cs:check",
- "@sniffer:check",
- "@phpstan",
- "@test:coverage"
+ "cs:check": [
+ "@putenv PHP_CS_FIXER_IGNORE_ENV=1",
+ "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi"
+ ],
+ "cs:fix": [
+ "@putenv PHP_CS_FIXER_IGNORE_ENV=1",
+ "php-cs-fixer fix --config=.cs.php --ansi --verbose"
],
- "cs:check": "php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php",
- "cs:fix": "php-cs-fixer fix --config=.cs.php",
- "lint": "phplint ./ --exclude=vendor --no-interaction --no-cache",
- "phpstan": "phpstan analyse -c phpstan.neon --no-progress --ansi",
"sniffer:check": "phpcs --standard=phpcs.xml",
"sniffer:fix": "phpcbf --standard=phpcs.xml",
+ "stan": "phpstan analyse -c phpstan.neon --no-progress --ansi",
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always",
- "test:coverage": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
+ "test:all": [
+ "@cs:check",
+ "@sniffer:check",
+ "@stan",
+ "@test"
+ ],
+ "test:coverage": "php -d xdebug.mode=coverage -r \"require 'vendor/bin/phpunit';\" -- --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage"
}
}
diff --git a/phpcs.xml b/phpcs.xml
index c825571..f2f42d9 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -9,27 +9,8 @@
./src
./tests
-
-
+
-
-
- warning
- */tests/
-
-
- warning
-
-
- warning
- */config/
-
-
- warning
-
-
- warning
-
warning
diff --git a/phpstan.neon b/phpstan.neon
index 309bd4f..0b6508e 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,4 +1,4 @@
parameters:
- level: max
+ level: 8
paths:
- - src
+ - src
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index f2e36c3..2927473 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -3,9 +3,16 @@
bootstrap="vendor/autoload.php"
colors="true"
backupGlobals="false"
- backupStaticAttributes="false"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
-
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
+ cacheDirectory=".phpunit.cache"
+ backupStaticProperties="false">
+
+
+
+ tests
+
+
+
-
-
- tests
-
-
+
diff --git a/src/Stream/CallbackStream.php b/src/Stream/CallbackStream.php
index 7063ccf..775e55a 100644
--- a/src/Stream/CallbackStream.php
+++ b/src/Stream/CallbackStream.php
@@ -3,6 +3,7 @@
namespace Selective\Http\Zip\Stream;
use Psr\Http\Message\StreamInterface;
+use RuntimeException;
/**
* Callback-based stream implementation.
@@ -78,7 +79,7 @@ public function getSize()
/**
* Returns the current position of the file read/write pointer.
*
- * @throws \RuntimeException on error
+ * @throws RuntimeException on error
*
* @return int Position of the file pointer
*/
@@ -119,7 +120,7 @@ public function isSeekable()
* offset bytes SEEK_CUR: Set position to current location plus offset
* SEEK_END: Set position to end-of-stream plus offset.
*
- * @throws \RuntimeException on failure
+ * @throws RuntimeException on failure
*
* @return void
*/
@@ -133,7 +134,7 @@ public function seek($offset, $whence = SEEK_SET)
* If the stream is not seekable, this method will raise an exception;
* otherwise, it will perform a seek(0).
*
- * @throws \RuntimeException on failure
+ * @throws RuntimeException on failure
*
* @return bool
*
@@ -160,7 +161,7 @@ public function isWritable()
*
* @param string $string The string that is to be written
*
- * @throws \RuntimeException on failure
+ * @throws RuntimeException on failure
*
* @return int Returns the number of bytes written to the stream
*/
@@ -185,7 +186,7 @@ public function isReadable()
* @param int $length Read up to $length bytes from the object and return them.
* Fewer than $length bytes may be returned if underlying stream call returns fewer bytes.
*
- * @throws \RuntimeException if an error occurs
+ * @throws RuntimeException if an error occurs
*
* @return string returns the data read from the stream, or an empty string if no bytes are available
*/
@@ -206,7 +207,7 @@ public function read($length)
/**
* Returns the remaining contents in a string.
*
- * @throws \RuntimeException if unable to read or an error occurs while reading
+ * @throws RuntimeException if unable to read or an error occurs while reading
*
* @return string
*/