diff --git a/.editorconfig b/.editorconfig index 2daea10..18b84df 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,7 +8,7 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true -[*.{md, rst}] +[*.{md,rst}] trim_trailing_whitespace = false [*.yml] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7fee510..89e54ae 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,7 +50,7 @@ jobs: vendor/bin/phpstan analyse -vvv - name: PHPUnit - run: vendor/bin/phpunit --verbose + run: vendor/bin/phpunit - name: Upload coverage results to Coveralls env: @@ -61,14 +61,14 @@ jobs: composer global require php-coveralls/php-coveralls php-coveralls --coverage_clover=build/logs/clover.xml -v - tests-last: + tests-latest: runs-on: ubuntu-22.04 timeout-minutes: 10 strategy: fail-fast: true - name: PHP 8.2 - Last + name: PHP Latest steps: - name: Checkout @@ -77,7 +77,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: latest tools: composer coverage: xdebug @@ -88,4 +88,4 @@ jobs: composer update - name: PHPUnit - run: vendor/bin/phpunit --verbose + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 592d95b..d6a2742 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ build/ raw-tests/ vendor/ .php-cs-fixer.cache +.phpunit.cache .phpunit.result.cache composer.lock composer.phar diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a489593..19eb991 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,8 +32,8 @@ test:php: - build/docs/ coverage: '/^\s*Lines:\s*\d+.\d+\%/' -test:php-last: - image: registry.gitlab.com/aplus-framework/images/base:3 +test:php-latest: + image: registry.gitlab.com/aplus-framework/images/base:latest stage: test timeout: 10 minutes cache: diff --git a/README.md b/README.md index b6fdaef..8d54430 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Aplus Framework Debug Library +Aplus Framework Debug Library # Aplus Framework Debug Library @@ -7,7 +7,6 @@ - [API Documentation](https://docs.aplus-framework.com/packages/debug.html) [![tests](https://github.com/aplus-framework/debug/actions/workflows/tests.yml/badge.svg)](https://github.com/aplus-framework/debug/actions/workflows/tests.yml) -[![pipeline](https://gitlab.com/aplus-framework/libraries/debug/badges/master/pipeline.svg)](https://gitlab.com/aplus-framework/libraries/debug/-/pipelines?scope=branches) -[![coverage](https://gitlab.com/aplus-framework/libraries/debug/badges/master/coverage.svg?job=test:php)](https://aplus-framework.gitlab.io/libraries/debug/coverage/) +[![coverage](https://coveralls.io/repos/github/aplus-framework/debug/badge.svg?branch=master)](https://coveralls.io/github/aplus-framework/debug?branch=master) [![packagist](https://img.shields.io/packagist/v/aplus/debug)](https://packagist.org/packages/aplus/debug) [![open-source](https://img.shields.io/badge/open--source-sponsor-magenta)](https://aplus-framework.com/sponsor) diff --git a/SECURITY.md b/SECURITY.md index 934c0d1..d316286 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,11 +1,5 @@ # Security Policy -Aplus Framework Debug Library runs **SAST** each new pipeline and all known vulnerabilities are monitored. - -## Supported Versions - The **latest** and **LTS** versions of this library receive security fixes. -## Reporting a Vulnerability - -Create a new issue and mark it as **confidential** in the [official repository of this library](https://gitlab.com/aplus-framework/libraries/debug/-/issues). +If you find any vulnerability send an email to `aplusframework@gmail.com`. diff --git a/composer.json b/composer.json index 6f8f2d0..9ab01ec 100644 --- a/composer.json +++ b/composer.json @@ -25,9 +25,9 @@ "homepage": "https://aplus-framework.com/packages/debug", "support": { "email": "support@aplus-framework.com", - "issues": "https://gitlab.com/aplus-framework/libraries/debug/issues", + "issues": "https://github.com/aplus-framework/debug/issues", "forum": "https://aplus-framework.com/forum", - "source": "https://gitlab.com/aplus-framework/libraries/debug", + "source": "https://github.com/aplus-framework/debug", "docs": "https://docs.aplus-framework.com/guides/libraries/debug/" }, "funding": [ @@ -45,12 +45,12 @@ }, "require-dev": { "ext-xdebug": "*", - "aplus/coding-standard": "^1.14", + "aplus/coding-standard": "^2.1", "ergebnis/composer-normalize": "^2.25", "jetbrains/phpstorm-attributes": "^1.0", "phpmd/phpmd": "^2.13", "phpstan/phpstan": "^1.5", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^10.5" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/docker-compose.yml b/docker-compose.yml index 8c028aa..d408131 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,9 @@ services: volumes: - .:/package tty: true - package-last: - image: registry.gitlab.com/aplus-framework/images/package:3 - container_name: package-debug-last + package-latest: + image: registry.gitlab.com/aplus-framework/images/package:latest + container_name: package-debug-latest working_dir: /package volumes: - .:/package diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 741d40f..905c202 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,10 @@ - - - src - + bootstrap="vendor/autoload.php" colors="true" stopOnError="false" stopOnFailure="false" + stopOnIncomplete="false" stopOnSkipped="false" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" + cacheDirectory=".phpunit.cache"> + @@ -18,4 +15,9 @@ tests + + + src + + diff --git a/src/Collection.php b/src/Collection.php index f97e1c8..9a4c136 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -71,7 +71,7 @@ public function getActions() : array public function hasCollectors() : bool { - return ! empty($this->collectors); + return !empty($this->collectors); } /** diff --git a/src/Collector.php b/src/Collector.php index f2ad1c9..1438a39 100644 --- a/src/Collector.php +++ b/src/Collector.php @@ -62,7 +62,7 @@ public function getData() : array public function hasData() : bool { - return ! empty($this->data); + return !empty($this->data); } /** diff --git a/src/Debugger.php b/src/Debugger.php index e3adce5..195e9cc 100644 --- a/src/Debugger.php +++ b/src/Debugger.php @@ -125,7 +125,7 @@ protected function addActivityValues(array &$activity, float $min, float $max) : public function setDebugbarView(string $file) : static { $realpath = \realpath($file); - if ( ! $realpath || ! \is_file($realpath)) { + if (!$realpath || !\is_file($realpath)) { throw new InvalidArgumentException( 'Invalid debugbar view file: ' . $file ); diff --git a/src/ExceptionHandler.php b/src/ExceptionHandler.php index 59bb561..ebc03ff 100644 --- a/src/ExceptionHandler.php +++ b/src/ExceptionHandler.php @@ -69,7 +69,7 @@ public function __construct( public function setEnvironment(string $environment) : static { - if ( ! \in_array($environment, [ + if (!\in_array($environment, [ static::DEVELOPMENT, static::PRODUCTION, ], true)) { @@ -104,7 +104,7 @@ public function setLanguage(Language $language = null) : static */ public function getLanguage() : Language { - if ( ! isset($this->language)) { + if (!isset($this->language)) { $this->setLanguage(); } return $this->language; @@ -113,7 +113,7 @@ public function getLanguage() : Language protected function validateView(string $file) : string { $realpath = \realpath($file); - if ( ! $realpath || ! \is_file($realpath)) { + if (!$realpath || !\is_file($realpath)) { throw new InvalidArgumentException( 'Invalid exceptions view file: ' . $file ); @@ -169,7 +169,7 @@ public function exceptionHandler(Throwable $exception) : void return; } \http_response_code(500); - if ( ! \headers_sent()) { + if (!\headers_sent()) { $this->sendHeaders(); } if ($this->isJson()) { @@ -268,7 +268,7 @@ public function errorHandler( string $errfile = null, int $errline = null ) : bool { - if ( ! (\error_reporting() & $errno)) { + if (!(\error_reporting() & $errno)) { return true; } $type = match ($errno) { diff --git a/src/Timer.php b/src/Timer.php index e36984d..35e404e 100644 --- a/src/Timer.php +++ b/src/Timer.php @@ -42,7 +42,7 @@ public function __construct() #[ArrayShape(['memory' => 'string', 'time' => 'string'])] public function test(int $times, callable $function, bool $flush = false) : array { - if ( ! $flush) { + if (!$flush) { \ob_start(); } $this->testsCount++; @@ -51,7 +51,7 @@ public function test(int $times, callable $function, bool $flush = false) : arra $function(); } $this->addMark('test[' . ($this->testsCount) . '][end]'); - if ( ! $flush) { + if (!$flush) { \ob_end_clean(); } return $this->diff( diff --git a/src/Views/exceptions/development.php b/src/Views/exceptions/development.php index 2197829..b5098ad 100644 --- a/src/Views/exceptions/development.php +++ b/src/Views/exceptions/development.php @@ -217,7 +217,7 @@ $pre = ''; $handle = fopen($trace['file'], 'rb'); $line = 1; - while ($handle && ! feof($handle)) { + while ($handle && !feof($handle)) { $code = fgets($handle); if (isset($trace['line']) && $line >= ($trace['line'] - 10) diff --git a/tests/ExceptionHandlerTest.php b/tests/ExceptionHandlerTest.php index df3ed3d..c1bbfda 100644 --- a/tests/ExceptionHandlerTest.php +++ b/tests/ExceptionHandlerTest.php @@ -180,17 +180,6 @@ public function testExceptionOnDevelopment() : void self::assertStringNotContainsString('Log:', $contents); } - /** - * @return array> - */ - public function environmentsProvider() : array - { - return [ - [ExceptionHandler::DEVELOPMENT], - [ExceptionHandler::PRODUCTION], - ]; - } - /** * @runInSeparateProcess * @@ -207,19 +196,6 @@ public function testExceptionWithLogger(string $environment) : void self::assertNotEmpty($logger->getLastLog()); } - /** - * @return array> - */ - public function errorProvider() : array - { - return [ - [\E_USER_WARNING, 'User Warning'], - [\E_USER_DEPRECATED, 'User Deprecated'], - [\E_USER_ERROR, 'User Error'], - [\E_USER_NOTICE, 'User Notice'], - ]; - } - /** * @dataProvider errorProvider * @@ -237,4 +213,28 @@ public function testErrorHandler(int $error, string $type) : void $this->expectExceptionMessage($type . ': Error message'); \trigger_error('Error message', $error); } + + /** + * @return array> + */ + public static function environmentsProvider() : array + { + return [ + [ExceptionHandler::DEVELOPMENT], + [ExceptionHandler::PRODUCTION], + ]; + } + + /** + * @return array> + */ + public static function errorProvider() : array + { + return [ + [\E_USER_WARNING, 'User Warning'], + [\E_USER_DEPRECATED, 'User Deprecated'], + [\E_USER_ERROR, 'User Error'], + [\E_USER_NOTICE, 'User Notice'], + ]; + } }