Skip to content

Commit

Permalink
Update repo
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed May 18, 2024
1 parent 0fff92d commit df2b5c3
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 72 deletions.
28 changes: 9 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,39 @@ name: CI

on:
push:
branches:
- master
branches: [ master ]
pull_request:
branches:
- master
branches: [ master ]

jobs:
lint:
checks:
runs-on: ubuntu-latest


name: Lint


name: 'Check'
steps:
- name: Checkout code
uses: actions/checkout@v3

uses: actions/checkout@v4

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT


- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-

key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: pcov

tools: infection, pint, phpstan

- name: Install dependencies
run: composer install


- name: Check platform requirements
run: composer check-platform-reqs

Expand Down
9 changes: 3 additions & 6 deletions src/ChannelFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
use PHPUnit\Framework\Assert as PHPUnit;
use Psr\Log\LoggerInterface;

/**
* @no-named-arguments
*/
class ChannelFake implements LoggerInterface
{
use LogHelpers;
Expand Down Expand Up @@ -160,7 +157,7 @@ public function assertCurrentContext(Closure|array $context, ?string $message =
{
if ($context instanceof Closure) {
PHPUnit::assertTrue(
(bool) $context($this->currentContext()), /** @phpstan-ignore-line */
(bool) $context($this->currentContext()),
$message ?? 'Unexpected context found in the [' . $this->name . '] channel. Found [' . json_encode((object) $this->currentContext(), JSON_THROW_ON_ERROR) . '].'
);
} else {
Expand Down Expand Up @@ -196,7 +193,7 @@ public function log($level, $message, array $context = []): void
*/
public function write(string $level, $message, array $context = []): void
{
$this->log($level, $message, $context); /** @phpstan-ignore-line */
$this->log($level, $message, $context);
}

/**
Expand Down Expand Up @@ -259,7 +256,7 @@ public function setEventDispatcher(Dispatcher $dispatcher): void
private function logged(Closure $callback): Collection
{
return $this->logs()
->filter(fn (LogEntry $log): bool => (bool) $callback($log)) /** @phpstan-ignore-line */
->filter(fn (LogEntry $log): bool => (bool) $callback($log))
->values();
}

Expand Down
1 change: 0 additions & 1 deletion src/LogEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Stringable;

/**
* @no-named-arguments
* @implements Arrayable<string, mixed>
*/
class LogEntry implements Arrayable
Expand Down
3 changes: 1 addition & 2 deletions src/LogFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\VarDumper\VarDumper;

/**
* @no-named-arguments
* @mixin ChannelFake
*/
class LogFake implements LoggerInterface
Expand Down Expand Up @@ -188,7 +187,7 @@ public function log($level, $message, array $context = []): void
*/
public function __call(string $method, array $parameters): mixed
{
return $this->driver()->{$method}(...$parameters); /** @phpstan-ignore-line */
return $this->driver()->{$method}(...$parameters);
}

/**
Expand Down
5 changes: 0 additions & 5 deletions src/LogHelpers.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
<?php

declare(strict_types=1);

namespace TiMacDonald\Log;

use Illuminate\Log\Logger;
use Illuminate\Log\LogManager;

/**
* @no-named-arguments
*/
trait LogHelpers
{
/**
Expand Down
3 changes: 0 additions & 3 deletions src/StackFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use Closure;
use RuntimeException;

/**
* @no-named-arguments
*/
class StackFake extends ChannelFake
{
/**
Expand Down
13 changes: 4 additions & 9 deletions tests/AssertionTest.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<?php

declare(strict_types=1);

namespace Tests;

use RuntimeException;
use TiMacDonald\CallableFake\CallableFake;
use TiMacDonald\Log\LogEntry;
use TiMacDonald\Log\LogFake;

/**
* @small
*/
class AssertionTest extends TestCase
{
public function testAssertLoggedFunc(): void
Expand Down Expand Up @@ -523,9 +518,9 @@ public function testAssertCurrentContextWithNonBoolReturnedFromClosure(): void
{
$log = new LogFake();

$log->assertCurrentContext(fn () => 1); /** @phpstan-ignore-line */
$log->assertCurrentContext(fn () => 1);
self::assertFailsWithMessage(
fn () => $log->assertCurrentContext(fn () => 0), /** @phpstan-ignore-line */
fn () => $log->assertCurrentContext(fn () => 0),
'Unexpected context found in the [stack] channel. Found [{}].'
);
}
Expand All @@ -535,9 +530,9 @@ public function testAssertLoggedFuncWithNonBoolReturnedFromClosure(): void
$log = new LogFake();
$log->info('xxxx');

$log->assertLogged(fn () => 1); /** @phpstan-ignore-line */
$log->assertLogged(fn () => 1);
self::assertFailsWithMessage(
fn () => $log->assertLogged(fn () => 0), /** @phpstan-ignore-line */
fn () => $log->assertLogged(fn () => 0),
'Expected log was not created in the [stack] channel.'
);
}
Expand Down
8 changes: 0 additions & 8 deletions tests/LogFakeApiTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

namespace Tests;

use Illuminate\Contracts\Events\Dispatcher;
Expand All @@ -16,9 +14,6 @@
use TiMacDonald\Log\LogEntry;
use TiMacDonald\Log\LogFake;

/**
* @small
*/
class LogFakeApiTest extends TestCase
{
public function testLoggingLevelMethods(): void
Expand Down Expand Up @@ -184,7 +179,6 @@ public function testDummyMethods(): void
//
});
$log->setEventDispatcher(new class () implements Dispatcher {
/** @phpstan-ignore-next-line */
public function listen($events, $listener = null)
{
//
Expand All @@ -205,13 +199,11 @@ public function until($event, $payload = [])
return null;
}

/** @phpstan-ignore-next-line */
public function dispatch($event, $payload = [], $halt = false)
{
return null;
}

/** @phpstan-ignore-next-line */
public function push($event, $payload = [])
{
//
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ protected function setUp(): void
$app = Container::setInstance(new Container());

$app->singleton('config', fn () => new Repository(['logging' => ['default' => 'stack']]));
$app->singleton('log', fn () => new LogManager($app)); /** @phpstan-ignore-line */
$app->singleton('log', fn () => new LogManager($app));

Facade::setFacadeApplication($app); /** @phpstan-ignore-line */
Facade::setFacadeApplication($app);
Facade::clearResolvedInstances();
}

Expand Down
17 changes: 0 additions & 17 deletions vendor-bin/dev/composer.json

This file was deleted.

0 comments on commit df2b5c3

Please sign in to comment.