Skip to content

Commit

Permalink
Merge pull request #11 from Crell/gha
Browse files Browse the repository at this point in the history
GitHub Actions cleanup
  • Loading branch information
elazar authored Aug 14, 2024
2 parents 47ebce8 + c574983 commit 587cc30
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 36 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: CI

on: [push]
on:
push: ~
pull_request: ~

jobs:
build-test:
name: PHPUnit tests on ${{ matrix.php }}
runs-on: ubuntu-latest

strategy:
matrix:
php: [ '8.1', '8.2', '8.3' ]
steps:
- uses: actions/checkout@v2
- uses: php-actions/composer@v6
Expand All @@ -14,3 +19,11 @@ jobs:
sudo chmod -R 777 vendor/pestphp/pest/.temp
vendor/bin/pest
build-code-style:
name: PHP-CS-Fixer checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: php-actions/composer@v6
- name: Run CS-Fixer
run: vendor/bin/php-cs-fixer check
30 changes: 15 additions & 15 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ class Container implements ContainerInterface, IteratorAggregate
public function __construct()
{
$this->entries = [
FilesystemRegistry::class => fn() => new FilesystemRegistry,
PassThruPathNormalizer::class => fn() => new PassThruPathNormalizer,
StripProtocolPathNormalizer::class => fn() => new StripProtocolPathNormalizer(
FilesystemRegistry::class => fn () => new FilesystemRegistry(),
PassThruPathNormalizer::class => fn () => new PassThruPathNormalizer(),
StripProtocolPathNormalizer::class => fn () => new StripProtocolPathNormalizer(
null,
$this->get(WhitespacePathNormalizer::class),
),
PathNormalizer::class => fn() => $this->get(StripProtocolPathNormalizer::class),
WhitespacePathNormalizer::class => fn() => new WhitespacePathNormalizer,
PortableVisibilityConverter::class => fn() => new PortableVisibilityConverter,
VisibilityConverter::class => fn() => $this->get(PortableVisibilityConverter::class),
LockRegistryInterface::class => fn() => $this->get(LocalLockRegistry::class),
LocalLockRegistry::class => fn() => new LocalLockRegistry,
NullLogger::class => fn() => new NullLogger,
LoggerInterface::class => fn() => $this->get(NullLogger::class),
BufferInterface::class => fn() => $this->get(MemoryBuffer::class),
MemoryBuffer::class => fn() => new MemoryBuffer,
OverflowBuffer::class => fn() => new OverflowBuffer,
FileBuffer::class => fn() => new FileBuffer,
PathNormalizer::class => fn () => $this->get(StripProtocolPathNormalizer::class),
WhitespacePathNormalizer::class => fn () => new WhitespacePathNormalizer(),
PortableVisibilityConverter::class => fn () => new PortableVisibilityConverter(),
VisibilityConverter::class => fn () => $this->get(PortableVisibilityConverter::class),
LockRegistryInterface::class => fn () => $this->get(LocalLockRegistry::class),
LocalLockRegistry::class => fn () => new LocalLockRegistry(),
NullLogger::class => fn () => new NullLogger(),
LoggerInterface::class => fn () => $this->get(NullLogger::class),
BufferInterface::class => fn () => $this->get(MemoryBuffer::class),
MemoryBuffer::class => fn () => new MemoryBuffer(),
OverflowBuffer::class => fn () => new OverflowBuffer(),
FileBuffer::class => fn () => new FileBuffer(),
];

$this->instances = [];
Expand Down
8 changes: 1 addition & 7 deletions src/FlystreamException.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ public static function protocolNotRegistered(string $protocol): self

public static function containerEntryNotFound(string $id): self
{
return new class(
sprintf(
'Specified container entry not found: %s',
$id
),
self::CODE_CONTAINER_ENTRY_NOT_FOUND
) extends FlystreamException implements NotFoundExceptionInterface { };
return new class (sprintf('Specified container entry not found: %s', $id), self::CODE_CONTAINER_ENTRY_NOT_FOUND) extends FlystreamException implements NotFoundExceptionInterface { };
}
}
4 changes: 2 additions & 2 deletions src/ServiceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class ServiceLocator

public function __construct()
{
$this->container = new Container;
$this->container = new Container();
}

public static function getInstance(): self
{
if (self::$instance === null) {
self::$instance = new self;
self::$instance = new self();
}
return self::$instance;
}
Expand Down
10 changes: 5 additions & 5 deletions tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Elazar\Flystream\MemoryBuffer;

it('can iterate, detect, and get default entries', function () {
$container = new Container;
$container = new Container();
$expectedDependencyCount = 15;
$actualDependencyCount = 0;
foreach ($container as $class => $instance) {
Expand All @@ -19,11 +19,11 @@
});

it('throws an exception for an unknown key', function () {
(new Container)->get('unknown-key');
(new Container())->get('unknown-key');
})->throws(FlystreamException::class);

it('can override a dependency using a class name', function () {
$container = new Container;
$container = new Container();

$default = $container->get(BufferInterface::class);
expect($default)->toBeInstanceOf(MemoryBuffer::class);
Expand All @@ -35,9 +35,9 @@
});

it('can override a dependency using an instance', function () {
$container = new Container;
$container = new Container();

$buffer = new FileBuffer;
$buffer = new FileBuffer();
$container->set(BufferInterface::class, $buffer);

$override = $container->get(BufferInterface::class);
Expand Down
8 changes: 5 additions & 3 deletions tests/LocalLockRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@
it('releases locks when going out of scope', function () {
$testLock = new Lock('foo', Lock::TYPE_EXCLUSIVE);
$released = false;
$registry = new class($testLock, $released) extends LocalLockRegistry {
$registry = new class ($testLock, $released) extends LocalLockRegistry {
private Lock $testLock;
private bool $released;
public function __construct(Lock $testLock, bool &$released) {
public function __construct(Lock $testLock, bool &$released)
{
$this->testLock = $testLock;
$this->released = &$released;
}
public function release(Lock $lock): bool {
public function release(Lock $lock): bool
{
$this->released = true;
expect($lock)->toBe($this->testLock);
return parent::release($lock);
Expand Down
4 changes: 2 additions & 2 deletions tests/StreamWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
ServiceLocator::setInstance($serviceLocator);

$this->logger = new Logger(__FILE__);
$this->logger->pushHandler(new TestHandler);
$this->logger->pushHandler(new TestHandler());
ServiceLocator::set(LoggerInterface::class, $this->logger);

$this->registry = ServiceLocator::get(FilesystemRegistry::class);

$this->filesystem = new Filesystem(new InMemoryFilesystemAdapter);
$this->filesystem = new Filesystem(new InMemoryFilesystemAdapter());
$this->registry->register('fly', $this->filesystem);
});

Expand Down

0 comments on commit 587cc30

Please sign in to comment.