Skip to content

Commit

Permalink
Merge pull request #6 from alex-patterson-webdev/feature/0.1.0
Browse files Browse the repository at this point in the history
Feature/0.1.0
  • Loading branch information
alex-patterson-webdev committed May 29, 2023
2 parents 7da9e74 + 154b41b commit d399c16
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 38 deletions.
4 changes: 4 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ build:
override:
- php-scrutinizer-run
- command: phpcs-run
- command: composer test
coverage:
file: test/coverage/clover.xml
format: clover
checks:
php: true
coding_style:
Expand Down
21 changes: 13 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
language: php

php:
- 7.4
env:
global:
- COMPOSER_ARGS="-vvv --no-interaction --no-suggest"

matrix:
fast_finish: true
include:
- php: 7.4

- php: 8.0
env:
- COMPOSER_ARGS="-vvv --no-interaction --no-suggest --ignore-platform-reqs"

install:
- travis_retry composer install --no-interaction --no-suggest
- travis_retry composer install $COMPOSER_ARGS

script:
- composer test

after_success:
- bash <(curl -s https://codecov.io/bash)

branches:
only:
- master
- dev
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A simple PSR-11 compatible Dependency Injection Container

Installation via [Composer](https://getcomposer.org).

require alex-patterson-webdev/container ^1
require alex-patterson-webdev/container ^0.1

## Usage

Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"psr/container-implementation" : "1.0.0"
},
"require": {
"php" : ">=7.4",
"php" : ">=7.4 || >=8.0",
"psr/container" : "^1"
},
"require-dev": {
"phpunit/phpunit" : "^9.2"
"phpunit/phpunit" : "^9.5"
},
"autoload": {
"psr-4": {
Expand All @@ -30,10 +30,9 @@
}
},
"scripts": {
"test": "php vendor/bin/phpunit --coverage-clover=coverage.xml"
"test": "php vendor/bin/phpunit"
},
"config": {
"preferred-install": "dist",
"optimize-autoloader": true,
"sort-packages": true
}
Expand Down
31 changes: 17 additions & 14 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
<phpunit
bootstrap="./vendor/autoload.php"
verbose="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
colors="true"
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./vendor/autoload.php"
verbose="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<testsuites>
<testsuite name="ContainerArray">
<testsuite name="Container">
<directory>./test/phpunit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="false">

<coverage processUncoveredFiles="false">
<include>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</include>
</coverage>

<logging>
<log type="coverage-clover" target="clover.xml"/>
<testdoxXml outputFile="./test/coverage/clover.xml"/>
</logging>
</phpunit>
</phpunit>
3 changes: 2 additions & 1 deletion src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,13 @@ private function resolveFactory(string $name): ?callable
*
* @return array
*
* @throws CircularDependencyException
* @throws ContainerException
*/
private function resolveFactoryClass(string $name, string $factoryClassName, ?string $methodName): array
{
if ($factoryClassName === $name) {
throw new ContainerException(
throw new CircularDependencyException(
sprintf('A circular configuration dependency was detected for service \'%s\'', $name)
);
}
Expand Down
20 changes: 10 additions & 10 deletions src/Provider/ConfigServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ public function __construct(array $config)
*/
public function registerServices(ContainerInterface $container): void
{
if (isset($this->config[static::SERVICES]) && is_array($this->config[static::SERVICES])) {
foreach ($this->config[static::SERVICES] as $name => $service) {
if (isset($this->config[self::SERVICES]) && is_array($this->config[self::SERVICES])) {
foreach ($this->config[self::SERVICES] as $name => $service) {
$container->set($name, $service);
}
}

if (isset($this->config[static::FACTORIES]) && is_array($this->config[static::FACTORIES])) {
$this->registerFactories($container, $this->config[static::FACTORIES]);
if (isset($this->config[self::FACTORIES]) && is_array($this->config[self::FACTORIES])) {
$this->registerFactories($container, $this->config[self::FACTORIES]);
}

if (isset($this->config[static::ALIASES]) && is_array($this->config[static::ALIASES])) {
$this->registerAliases($container, $this->config[static::ALIASES]);
if (isset($this->config[self::ALIASES]) && is_array($this->config[self::ALIASES])) {
$this->registerAliases($container, $this->config[self::ALIASES]);
}
}

Expand Down Expand Up @@ -111,10 +111,10 @@ private function registerArrayFactory(
}

/**
* @param ContainerInterface $container
* @param string $serviceName
* @param object|callable $factory
* @param string|null $methodName
* @param ContainerInterface $container
* @param string $serviceName
* @param object|callable|string $factory
* @param string|null $methodName
*
* @throws ServiceProviderException
*/
Expand Down

0 comments on commit d399c16

Please sign in to comment.