Skip to content

Work around same-name import bug in PHP 5.6 #239

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

Merged
merged 3 commits into from
Dec 6, 2017
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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.

## Unreleased
## 1.8.1 - 2017-12-06

### Fixed

- `PluginClientFactory` name conflict with PHP 5.x.

## 1.8.0 - 2017-11-30

### Added

Expand Down
11 changes: 5 additions & 6 deletions Collector/PluginClientFactoryListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace Http\HttplugBundle\Collector;

use Http\Client\Common\PluginClientFactory;
use Http\HttplugBundle\Collector\PluginClientFactory as CollectorPluginClientFactory;
use Http\Client\Common\PluginClientFactory as DefaultPluginClientFactory;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

Expand All @@ -19,14 +18,14 @@
final class PluginClientFactoryListener implements EventSubscriberInterface
{
/**
* @var CollectorPluginClientFactory
* @var PluginClientFactory
*/
private $factory;

/**
* @param CollectorPluginClientFactory $factory
* @param PluginClientFactory $factory
*/
public function __construct(CollectorPluginClientFactory $factory)
public function __construct(PluginClientFactory $factory)
{
$this->factory = $factory;
}
Expand All @@ -38,7 +37,7 @@ public function __construct(CollectorPluginClientFactory $factory)
*/
public function onEvent(Event $e)
{
PluginClientFactory::setFactory([$this->factory, 'createClient']);
DefaultPluginClientFactory::setFactory([$this->factory, 'createClient']);
}

/**
Expand Down
31 changes: 31 additions & 0 deletions Tests/Unit/Collector/PluginClientFactoryListenerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Http\HttplugBundle\Tests\Unit\Collector;

use Http\Client\Common\PluginClientFactory as DefaultPluginClientFactory;
use Http\HttplugBundle\Collector\Collector;
use Http\HttplugBundle\Collector\Formatter;
use Http\HttplugBundle\Collector\PluginClientFactory;
use Http\HttplugBundle\Collector\PluginClientFactoryListener;
use Nyholm\NSA;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Stopwatch\Stopwatch;

final class PluginClientFactoryListenerTest extends TestCase
{
public function testRegisterPluginClientFactory()
{
$collector = $this->getMockBuilder(Collector::class)->getMock();
$formatter = $this->getMockBuilder(Formatter::class)->disableOriginalConstructor()->getMock();
$stopwatch = $this->getMockBuilder(Stopwatch::class)->getMock();

$factory = new PluginClientFactory($collector, $formatter, $stopwatch);

$listener = new PluginClientFactoryListener($factory);

$listener->onEvent(new Event());

$this->assertTrue(is_callable(NSA::getProperty(DefaultPluginClientFactory::class, 'factory')));
}
}