Skip to content

Commit

Permalink
Merge branch 'new' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Dec 10, 2023
2 parents 92ea195 + 8ca0820 commit f4b629e
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{md, rst}]
[*.{md,rst}]
trim_trailing_whitespace = false

[*.yml]
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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

Expand All @@ -88,4 +88,4 @@ jobs:
composer update

- name: PHPUnit
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build/
raw-tests/
vendor/
.php-cs-fixer.cache
.phpunit.cache
.phpunit.result.cache
composer.lock
composer.phar
Expand Down
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="https://gitlab.com/aplus-framework/libraries/debug"><img src="https://gitlab.com/aplus-framework/libraries/debug/-/raw/master/guide/image.png" alt="Aplus Framework Debug Library" align="right" width="100"></a>
<a href="https://github.com/aplus-framework/debug"><img src="https://raw.githubusercontent.com/aplus-framework/debug/master/guide/image.png" alt="Aplus Framework Debug Library" align="right" width="100"></a>

# Aplus Framework Debug Library

Expand All @@ -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)
8 changes: 1 addition & 7 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -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 `[email protected]`.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"homepage": "https://aplus-framework.com/packages/debug",
"support": {
"email": "[email protected]",
"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": [
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false"
bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnError="false"
stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
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">
<coverage>
<report>
<clover outputFile="build/coverage/clover.xml"/>
<html outputDirectory="build/coverage"/>
Expand All @@ -18,4 +15,9 @@
<directory suffix="Test.php">tests</directory>
</testsuite>
<logging/>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function getActions() : array

public function hasCollectors() : bool
{
return ! empty($this->collectors);
return !empty($this->collectors);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getData() : array

public function hasData() : bool
{
return ! empty($this->data);
return !empty($this->data);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
10 changes: 5 additions & 5 deletions src/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand All @@ -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
);
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/Views/exceptions/development.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
48 changes: 24 additions & 24 deletions tests/ExceptionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,6 @@ public function testExceptionOnDevelopment() : void
self::assertStringNotContainsString('Log:', $contents);
}

/**
* @return array<array<string>>
*/
public function environmentsProvider() : array
{
return [
[ExceptionHandler::DEVELOPMENT],
[ExceptionHandler::PRODUCTION],
];
}

/**
* @runInSeparateProcess
*
Expand All @@ -207,19 +196,6 @@ public function testExceptionWithLogger(string $environment) : void
self::assertNotEmpty($logger->getLastLog());
}

/**
* @return array<array<int|string>>
*/
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
*
Expand All @@ -237,4 +213,28 @@ public function testErrorHandler(int $error, string $type) : void
$this->expectExceptionMessage($type . ': Error message');
\trigger_error('Error message', $error);
}

/**
* @return array<array<string>>
*/
public static function environmentsProvider() : array
{
return [
[ExceptionHandler::DEVELOPMENT],
[ExceptionHandler::PRODUCTION],
];
}

/**
* @return array<array<int|string>>
*/
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'],
];
}
}

0 comments on commit f4b629e

Please sign in to comment.