Skip to content

Commit

Permalink
#23 adding return hints wherever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jul 22, 2017
1 parent 8e36d83 commit 874097c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class InstantiatorPerformanceEvent extends AthleticEvent
/**
* {@inheritDoc}
*/
protected function setUp()
protected function setUp() : void
{
parent::setUp();

$this->instantiator = new Instantiator();

$this->instantiator->instantiate(__CLASS__);
Expand All @@ -53,7 +55,7 @@ protected function setUp()
* @baseline
* @group instantiation
*/
public function testInstantiateSelf()
public function testInstantiateSelf() : void
{
$this->instantiator->instantiate(__CLASS__);
}
Expand All @@ -62,7 +64,7 @@ public function testInstantiateSelf()
* @iterations 20000
* @group instantiation
*/
public function testInstantiateInternalClass()
public function testInstantiateInternalClass() : void
{
$this->instantiator->instantiate('ArrayObject');
}
Expand All @@ -71,7 +73,7 @@ public function testInstantiateInternalClass()
* @iterations 20000
* @group instantiation
*/
public function testInstantiateSimpleSerializableAssetClass()
public function testInstantiateSimpleSerializableAssetClass() : void
{
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset');
}
Expand All @@ -80,7 +82,7 @@ public function testInstantiateSimpleSerializableAssetClass()
* @iterations 20000
* @group instantiation
*/
public function testInstantiateSerializableArrayObjectAsset()
public function testInstantiateSerializableArrayObjectAsset() : void
{
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset');
}
Expand All @@ -89,7 +91,7 @@ public function testInstantiateSerializableArrayObjectAsset()
* @iterations 20000
* @group instantiation
*/
public function testInstantiateUnCloneableAsset()
public function testInstantiateUnCloneableAsset() : void
{
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
class InvalidArgumentExceptionTest extends PHPUnit_Framework_TestCase
{
public function testFromNonExistingTypeWithNonExistingClass()
public function testFromNonExistingTypeWithNonExistingClass() : void
{
$className = __CLASS__ . str_replace('.', '', uniqid('', true));
$exception = InvalidArgumentException::fromNonExistingClass($className);
Expand All @@ -44,7 +44,7 @@ public function testFromNonExistingTypeWithNonExistingClass()
$this->assertSame('The provided class "' . $className . '" does not exist', $exception->getMessage());
}

public function testFromNonExistingTypeWithTrait()
public function testFromNonExistingTypeWithTrait() : void
{
$exception = InvalidArgumentException::fromNonExistingClass(SimpleTraitAsset::class);

Expand All @@ -54,7 +54,7 @@ public function testFromNonExistingTypeWithTrait()
);
}

public function testFromNonExistingTypeWithInterface()
public function testFromNonExistingTypeWithInterface() : void
{
$exception = InvalidArgumentException::fromNonExistingClass(InstantiatorInterface::class);

Expand All @@ -67,7 +67,7 @@ public function testFromNonExistingTypeWithInterface()
);
}

public function testFromAbstractClass()
public function testFromAbstractClass() : void
{
$reflection = new ReflectionClass(AbstractClassAsset::class);
$exception = InvalidArgumentException::fromAbstractClass($reflection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
class UnexpectedValueExceptionTest extends PHPUnit_Framework_TestCase
{
public function testFromSerializationTriggeredException()
public function testFromSerializationTriggeredException() : void
{
$reflectionClass = new ReflectionClass($this);
$previous = new Exception();
Expand All @@ -49,7 +49,7 @@ public function testFromSerializationTriggeredException()
);
}

public function testFromUncleanUnSerialization()
public function testFromUncleanUnSerialization() : void
{
$reflection = new ReflectionClass(AbstractClassAsset::class);
$exception = UnexpectedValueException::fromUncleanUnSerialization($reflection, 'foo', 123, 'bar', 456);
Expand Down
24 changes: 10 additions & 14 deletions tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,25 @@ class InstantiatorTest extends PHPUnit_Framework_TestCase
/**
* {@inheritDoc}
*/
protected function setUp()
protected function setUp() : void
{
parent::setUp();

$this->instantiator = new Instantiator();
}

/**
* @param string $className
*
* @dataProvider getInstantiableClasses
*/
public function testCanInstantiate($className)
public function testCanInstantiate(string $className) : void
{
$this->assertInstanceOf($className, $this->instantiator->instantiate($className));
}

/**
* @param string $className
*
* @dataProvider getInstantiableClasses
*/
public function testInstantiatesSeparateInstances($className)
public function testInstantiatesSeparateInstances(string $className) : void
{
$instance1 = $this->instantiator->instantiate($className);
$instance2 = $this->instantiator->instantiate($className);
Expand All @@ -88,7 +86,7 @@ public function testInstantiatesSeparateInstances($className)
$this->assertNotSame($instance1, $instance2);
}

public function testExceptionOnUnSerializationException()
public function testExceptionOnUnSerializationException() : void
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped(
Expand All @@ -103,18 +101,16 @@ public function testExceptionOnUnSerializationException()
}

/**
* @param string $invalidClassName
*
* @dataProvider getInvalidClassNames
*/
public function testInstantiationFromNonExistingClass($invalidClassName)
public function testInstantiationFromNonExistingClass(string $invalidClassName) : void
{
$this->setExpectedException(InvalidArgumentException::class);

$this->instantiator->instantiate($invalidClassName);
}

public function testInstancesAreNotCloned()
public function testInstancesAreNotCloned() : void
{
$className = 'TemporaryClass' . str_replace('.', '', uniqid('', true));

Expand All @@ -134,7 +130,7 @@ public function testInstancesAreNotCloned()
*
* @return string[][]
*/
public function getInstantiableClasses()
public function getInstantiableClasses() : array
{
return [
[stdClass::class],
Expand Down Expand Up @@ -162,7 +158,7 @@ public function getInstantiableClasses()
*
* @return string[][]
*/
public function getInvalidClassNames()
public function getInvalidClassNames() : array
{
return [
[__CLASS__ . str_replace('.', '', uniqid('', true))],
Expand Down

0 comments on commit 874097c

Please sign in to comment.