Skip to content

Commit

Permalink
Merge pull request #10 from jakubkulhan/sf4
Browse files Browse the repository at this point in the history
Symfony 4.0 support, dropped autoscanning
  • Loading branch information
mzstic committed Feb 21, 2018
2 parents 90cc4f7 + 47ed08f commit febf963
Show file tree
Hide file tree
Showing 19 changed files with 393 additions and 628 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- nightly

cache:
directories:
Expand All @@ -16,14 +14,19 @@ env:
- PREFER_LOWEST="--prefer-lowest"
- PREFER_LOWEST=""

matrix:
allow_failures:
- php: nightly


install:
- composer update $PREFER_LOWEST

before_script:
- if [ $TRAVIS_PHP_VERSION = '5.6' ]; then PHPUNIT_FLAGS="--coverage-clover coverage.xml"; fi
- if [ $TRAVIS_PHP_VERSION = '7.2' ]; then PHPUNIT_FLAGS="--coverage-clover coverage.xml"; fi

script:
- phpunit $PHPUNIT_FLAGS

after_script:
- if [ $TRAVIS_PHP_VERSION = '5.6' ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.xml; fi
- if [ $TRAVIS_PHP_VERSION = '7.2' ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.xml; fi
7 changes: 0 additions & 7 deletions Annotation/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@
*/
class Component
{

/** @var string service ID */
public $name;

/** @var string service environments */
public $env;

}
32 changes: 26 additions & 6 deletions DependencyInjection/ClassMultiMap.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
namespace Skrz\Bundle\AutowiringBundle\DependencyInjection;

use ReflectionClass;
use Skrz\Bundle\AutowiringBundle\Exception\MultipleValuesException;
use Skrz\Bundle\AutowiringBundle\Exception\NoValueException;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Maps from class name, all its parents, and implemented interfaces to certain value
Expand All @@ -13,16 +13,28 @@
class ClassMultiMap
{

/** @var string[] */
/** @var ContainerBuilder */
private $containerBuilder;

/** @var string[][] */
private $classes = [];

public function __construct(ContainerBuilder $containerBuilder)
{
$this->containerBuilder = $containerBuilder;
}

/**
* @param string $className
* @param string $value
* @return void
*/
public function put($className, $value)
public function put(string $className, string $value)
{
$reflectionClass = new ReflectionClass($className);
$reflectionClass = $this->containerBuilder->getReflectionClass($className, false);
if ($reflectionClass === null) {
return;
}

foreach ($reflectionClass->getInterfaceNames() as $interfaceName) {
if (!isset($this->classes[$interfaceName])) {
Expand All @@ -43,7 +55,7 @@ public function put($className, $value)
* @param string $className
* @return string
*/
public function getSingle($className)
public function getSingle(string $className): string
{
if (!isset($this->classes[$className])) {
throw new NoValueException(sprintf("Key '%s'.", $className));
Expand All @@ -62,7 +74,7 @@ public function getSingle($className)
* @param string $className
* @return string[]
*/
public function getMulti($className)
public function getMulti(string $className): array
{
if (!isset($this->classes[$className])) {
return [];
Expand All @@ -71,4 +83,12 @@ public function getMulti($className)
return $this->classes[$className];
}

/**
* @return string[][]
*/
public function all(): array
{
return $this->classes;
}

}
169 changes: 0 additions & 169 deletions DependencyInjection/Compiler/AutoscanCompilerPass.php

This file was deleted.

0 comments on commit febf963

Please sign in to comment.