Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests on PHP 8.3 #22

Merged
merged 6 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
coverage: none

- name: Install composer dependencies
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.1, 8.2 ]
php: [ 8.2, 8.3 ]
laravel: [ ^10.0 ]
dependency-version: [ prefer-lowest, prefer-stable ]
include:
Expand All @@ -36,15 +36,6 @@ jobs:
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none

- name: Set Minimum PHP 8.1 Versions
run: |
composer require ramsey/collection:^1.2 brick/math:^0.9.3 --no-interaction --no-update

- name: Set Minimum PHP 8.2 Versions
run: |
composer require guzzlehttp/guzzle:^7.5 guzzlehttp/psr7:^2.4 predis/predis:^2.0.2 --no-interaction --no-update
if: matrix.php >= 8.2

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --no-scripts
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.2",
"illuminate/http": "^10.15",
"illuminate/support": "^10.15"
},
Expand All @@ -24,7 +24,7 @@
"intervention/image": "^2.5.0",
"nunomaduro/larastan": "^2.3",
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^10.4"
},
"suggest": {
"intervention/image": "Needed to use Image generation component"
Expand Down
20 changes: 7 additions & 13 deletions src/Debug/DebugManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ public function log(): void
private function entries(): Collection
{
return collect($this->collectors)
->flatMap(static function (DataCollector $collector) {
return $collector->collect();
})
->flatMap(static fn (DataCollector $collector) => $collector->collect())
->sortBy(static fn (Entry $entry) => $entry->getMicroTime())
->map(static fn (Entry $entry) => (string) $entry);
}
Expand All @@ -124,9 +122,7 @@ private function entries(): Collection
private function warnings(): Collection
{
$warnings = collect($this->collectors)
->flatMap(static function (DataCollector $collector) {
return $collector->warnings();
})
->flatMap(static fn (DataCollector $collector) => $collector->warnings())
->map(static fn (Warning $warning) => (string) $warning);

if ($warnings->isEmpty()) {
Expand All @@ -136,13 +132,11 @@ private function warnings(): Collection
$maxLength = (int) $warnings->max(static fn (string $warning) => Str::length($warning));

return $warnings
->map(static function (string $warning) use ($maxLength) {
return sprintf(
'!! %s%s !!',
$warning,
str_repeat(' ', $maxLength - Str::length($warning))
);
})
->map(static fn (string $warning) => sprintf(
'!! %s%s !!',
$warning,
str_repeat(' ', $maxLength - Str::length($warning))
))
->prepend(str_repeat('!', $maxLength + 6))
->push(str_repeat('!', $maxLength + 6));
}
Expand Down
8 changes: 3 additions & 5 deletions src/Debug/DebugMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

class DebugMiddleware
{
protected DebugManager $debugManager;

public function __construct(DebugManager $debugManager)
{
$this->debugManager = $debugManager;
public function __construct(
protected DebugManager $debugManager,
) {
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Debug/Entries/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Soyhuce\DevTools\Debug\Entries;

use Illuminate\Support\Carbon;
use Stringable;

class Entry
class Entry implements Stringable
{
protected float $microTime;

Expand Down
4 changes: 3 additions & 1 deletion src/Debug/Warnings/Warning.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Soyhuce\DevTools\Debug\Warnings;

class Warning
use Stringable;

class Warning implements Stringable
{
public function __construct(
private string $source,
Expand Down
6 changes: 3 additions & 3 deletions src/Faker/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public static function generate(
?string $text = null,
string $encoding = 'jpg',
): InterventionImage {
if (!class_exists('Intervention\Image\Image')) {
if (!class_exists(\Intervention\Image\Image::class)) {
throw new Exception('package intervention/image is required to use Image::generate');
}

$backgroundColor = static::generateRandomColor();
$fontColor = ColorUtils::getComplementaryColor($backgroundColor);
$img = ImageManagerStatic::canvas($width, $height, $backgroundColor);
$text = $text ?? $width . 'x' . $height;
$text ??= $width . 'x' . $height;
$fontSize = (int) ($width / mb_strlen($text));

$img->text(
Expand All @@ -48,6 +48,6 @@ static function (AbstractFont $font) use ($fontSize, $fontColor): void {
*/
private static function generateRandomColor(): array
{
return [mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)];
return [random_int(0, 255), random_int(0, 255), random_int(0, 255)];
}
}
20 changes: 7 additions & 13 deletions src/Tools/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,12 @@ public static function toBytes(string $value): int
}

$number = (int) mb_substr($value, 0, -2);
switch (mb_strtoupper(mb_substr($value, -2))) {
case 'KB':
case 'KO':
return $number * 1024;
case 'MB':
case 'MO':
return $number * 1024 ** 2;
case 'GB':
case 'GO':
return $number * 1024 ** 3;
default:
return $number;
}

return match (mb_strtoupper(mb_substr($value, -2))) {
'KB', 'KO' => $number * 1024,
'MB', 'MO' => $number * 1024 ** 2,
'GB', 'GO' => $number * 1024 ** 3,
default => $number,
};
}
}
Loading