Skip to content

Commit

Permalink
Merge pull request #424 from Ocramius/feature/clean-up-test-suite-dep…
Browse files Browse the repository at this point in the history
…endencies

Cleaned up dependencies, update mutation test setup and static analysis
  • Loading branch information
Ocramius committed Aug 25, 2018
2 parents 8ea3739 + e6227d1 commit 9af8a41
Show file tree
Hide file tree
Showing 23 changed files with 69 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Expand Up @@ -9,7 +9,7 @@
.travis.yml export-ignore
CONTRIBUTING.md export-ignore
couscous.yml export-ignore
humbug.json.dist export-ignore
infection.json.dist export-ignore
index.html export-ignore
phpbench.json export-ignore
phpdox.xml.dist export-ignore
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Expand Up @@ -6,5 +6,5 @@ phpmd.xml
phpdox.xml
clover.xml
.couscous
humbuglog.json
humbuglog.txt
infectionlog.json
infectionlog.txt
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -31,9 +31,9 @@ script:
- php examples/smart-reference.php
- php examples/virtual-proxy.php
- ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/
- ./vendor/bin/phpstan analyse -c phpstan.neon -l 7 src
- ./vendor/bin/phpstan analyse -c phpstan.tests.neon -l 4 tests
- ./vendor/bin/humbug
- ./vendor/bin/phpstan analyse
- ./vendor/bin/phpstan analyse -c phpstan.tests.neon
- ./vendor/bin/infection -vvv --test-framework-options='--testsuite=unit' --min-msi=99 --min-covered-msi=100

matrix:
allow_failures:
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Expand Up @@ -20,19 +20,19 @@
],
"require": {
"php": "^7.2.0",
"zendframework/zend-code": "^3.3.0",
"ocramius/package-versions": "^1.1.3"
"zendframework/zend-code": "^3.3.1",
"ocramius/package-versions": "^1.3.0"
},
"require-dev": {
"ext-phar": "*",
"phpunit/phpunit": "^6.4.3",
"squizlabs/php_codesniffer": "^2.9.1",
"phpunit/phpunit": "^7.3.2",
"squizlabs/php_codesniffer": "^3.3.1",
"couscous/couscous": "^1.6.1",
"phpbench/phpbench": "^0.12.2",
"phpstan/phpstan": "dev-master#856eb10a81c1d27c701a83f167dc870fd8f4236a as 0.9.999",
"phpstan/phpstan-phpunit": "dev-master#5629c0a1f4a9c417cb1077cf6693ad9753895761",
"nikic/php-parser": "^3.1.1",
"humbug/humbug": "1.0.0-RC.0@RC"
"phpbench/phpbench": "^0.14.0",
"phpstan/phpstan": "^0.10.3",
"phpstan/phpstan-phpunit": "^0.10",
"infection/infection": "^0.10.1",
"symfony/console": "^3.4.14"
},
"suggest": {
"ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects",
Expand Down
4 changes: 2 additions & 2 deletions humbug.json.dist → infection.json.dist
Expand Up @@ -6,7 +6,7 @@
},
"timeout": 15,
"logs": {
"text": "humbuglog.txt",
"json": "humbuglog.json"
"text": "infectionlog.txt",
"json": "infectionlog.json"
}
}
3 changes: 3 additions & 0 deletions phpstan.neon
@@ -1,4 +1,7 @@
parameters:
level: 7
paths:
- src
ignoreErrors:
# We only mock this dependency, and never really require it:
- '#Zend\\Server\\Client#'
Expand Down
5 changes: 5 additions & 0 deletions phpstan.tests.neon
@@ -1,4 +1,9 @@
parameters:
level: 4
paths:
- tests/language-feature-scripts
- tests/ProxyManagerBench
- tests/ProxyManagerTest
ignoreErrors:
# We only mock this dependency, and never really require it:
- '#Zend\\Server\\Client#'
Expand Down
14 changes: 8 additions & 6 deletions phpunit.xml.dist
Expand Up @@ -16,12 +16,14 @@
beStrictAboutResourceUsageDuringSmallTests="true"
beStrictAboutChangesToGlobalState="true"
>
<testsuite name="ProxyManager tests">
<directory>./tests/ProxyManagerTest</directory>
</testsuite>
<testsuite name="ProxyManager language integration tests">
<directory suffix=".phpt">./tests/language-feature-scripts</directory>
</testsuite>
<testsuites>
<testsuite name="unit">
<directory>./tests/ProxyManagerTest</directory>
</testsuite>
<testsuite name="integration">
<directory suffix=".phpt">./tests/language-feature-scripts</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
Expand Down
6 changes: 6 additions & 0 deletions src/ProxyManager/Generator/MethodGenerator.php
Expand Up @@ -12,6 +12,12 @@
*
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*
* Note: following overrides are just fixing some "lies" in the documented types in zend-code
*
* @method \Zend\Code\Generator\DocBlockGenerator|null getDocBlock()
* @method string|null getBody()
* @method string|null getSourceContent()
*/
class MethodGenerator extends ZendMethodGenerator
{
Expand Down
Expand Up @@ -42,6 +42,8 @@ public function generate(ClassGenerator $classGenerator) : string
if (! $this->canEval) {
$fileName = tempnam(sys_get_temp_dir(), 'EvaluatingGeneratorStrategy.php.tmp.');

assert(is_string($fileName));

file_put_contents($fileName, "<?php\n" . $code);
/* @noinspection PhpIncludeInspection */
require $fileName;
Expand Down
Expand Up @@ -76,6 +76,8 @@ private function writeFile(string $source, string $location) : void
{
$tmpFileName = tempnam($location, 'temporaryProxyManagerFile');

assert(is_string($tmpFileName));

file_put_contents($tmpFileName, $source);

if (! rename($tmpFileName, $location)) {
Expand Down
Expand Up @@ -39,12 +39,7 @@ public function __construct(Properties $properties)
$this->setDefaultValue($this->getMap($properties));
}

/**
*
* @param Properties $properties
*
* @return int[][]|mixed[][]
*/
/** @return array<string, string> */
private function getMap(Properties $properties) : array
{
$map = [];
Expand Down
Expand Up @@ -45,9 +45,9 @@ private static function generateUnsetPrivatePropertiesCode(Properties $propertie

$unsetClosureCalls = [];

/* @var $privateProperties \ReflectionProperty[] */
/** @var \ReflectionProperty[] $privateProperties */
foreach ($groups as $privateProperties) {
/* @var $firstProperty \ReflectionProperty */
/** @var \ReflectionProperty $firstProperty */
$firstProperty = reset($privateProperties);

$unsetClosureCalls[] = self::generateUnsetClassPrivatePropertiesBlock(
Expand Down
2 changes: 1 addition & 1 deletion tests/ProxyManagerBench/BaselinePropertyAccessBench.php
Expand Up @@ -61,7 +61,7 @@ class BaselinePropertyAccessBench
*/
private $accessMixedPropertiesProtected;

protected function setUp()
public function setUp()
{
$this->privateProperties = new ClassWithPrivateProperties();
$this->protectedProperties = new ClassWithProtectedProperties();
Expand Down
Expand Up @@ -50,7 +50,7 @@ class LazyLoadingGhostInstantiationBench
*/
private $mixedPropertiesProxy;

protected function setUp()
public function setUp()
{
$this->emptyClassProxy = $this->generateProxy(EmptyClass::class);
$this->privatePropertiesProxy = $this->generateProxy(ClassWithPrivateProperties::class);
Expand Down
22 changes: 11 additions & 11 deletions tests/ProxyManagerBench/LazyLoadingGhostPropertyAccessBench.php
Expand Up @@ -29,22 +29,22 @@
class LazyLoadingGhostPropertyAccessBench
{
/**
* @var EmptyClass|GhostObjectInterface
* @var EmptyClass|LazyLoadingInterface
*/
private $emptyClassProxy;

/**
* @var EmptyClass|GhostObjectInterface
* @var EmptyClass|LazyLoadingInterface
*/
private $initializedEmptyClassProxy;

/**
* @var ClassWithPrivateProperties|GhostObjectInterface
* @var ClassWithPrivateProperties|LazyLoadingInterface
*/
private $privatePropertiesProxy;

/**
* @var ClassWithPrivateProperties|GhostObjectInterface
* @var ClassWithPrivateProperties|LazyLoadingInterface
*/
private $initializedPrivatePropertiesProxy;

Expand All @@ -54,12 +54,12 @@ class LazyLoadingGhostPropertyAccessBench
private $accessPrivateProperty;

/**
* @var ClassWithProtectedProperties|GhostObjectInterface
* @var ClassWithProtectedProperties|LazyLoadingInterface
*/
private $protectedPropertiesProxy;

/**
* @var ClassWithProtectedProperties|GhostObjectInterface
* @var ClassWithProtectedProperties|LazyLoadingInterface
*/
private $initializedProtectedPropertiesProxy;

Expand All @@ -69,26 +69,26 @@ class LazyLoadingGhostPropertyAccessBench
private $accessProtectedProperty;

/**
* @var ClassWithPublicProperties|GhostObjectInterface
* @var ClassWithPublicProperties|LazyLoadingInterface
*/
private $publicPropertiesProxy;

/**
* @var ClassWithPublicProperties|GhostObjectInterface
* @var ClassWithPublicProperties|LazyLoadingInterface
*/
private $initializedPublicPropertiesProxy;

/**
* @var ClassWithMixedProperties|GhostObjectInterface
* @var ClassWithMixedProperties|LazyLoadingInterface
*/
private $mixedPropertiesProxy;

/**
* @var ClassWithMixedProperties|GhostObjectInterface
* @var ClassWithMixedProperties|LazyLoadingInterface
*/
private $initializedMixedPropertiesProxy;

protected function setUp()
public function setUp()
{
$this->emptyClassProxy = $this->buildProxy(EmptyClass::class);
$this->privatePropertiesProxy = $this->buildProxy(ClassWithPrivateProperties::class);
Expand Down
Expand Up @@ -50,7 +50,7 @@ class LazyLoadingValueHolderInstantiationBench
*/
private $mixedPropertiesProxy;

protected function setUp()
public function setUp()
{
$this->emptyClassProxy = $this->generateProxy(EmptyClass::class);
$this->privatePropertiesProxy = $this->generateProxy(ClassWithPrivateProperties::class);
Expand Down
Expand Up @@ -54,7 +54,7 @@ class LazyLoadingValueHolderPropertyAccessBench
*/
private $initializedMixedPropertiesProxy;

protected function setUp()
public function setUp()
{
$this->emptyClassProxy = $this->buildProxy(EmptyClass::class);
$this->publicPropertiesProxy = $this->buildProxy(ClassWithPublicProperties::class);
Expand Down
Expand Up @@ -493,7 +493,7 @@ function () : string {

$object->foo('Ocramius', 'Malukenho', 'Danizord');
self::assertSame('Ocramius', $object->bar);
self::assertSame(['Malukenho', 'Danizord'], $object->baz);
self::assertSame(['Malukenho', 'Danizord'], self::getObjectAttribute($object, 'baz'));
}

/**
Expand Down
Expand Up @@ -370,7 +370,7 @@ function () : string {

$object->foo('Ocramius', 'Malukenho', 'Danizord');
self::assertSame('Ocramius', $object->bar);
self::assertSame(['Malukenho', 'Danizord'], $object->baz);
self::assertSame(['Malukenho', 'Danizord'], self::getObjectAttribute($object, 'baz'));
}

/**
Expand Down
Expand Up @@ -94,7 +94,7 @@ function (ReflectionMethod $method) : string {
/**
* Data provider
*
* @return array[][]
* @return ReflectionClass[][]|null[][]|string[][][]
*/
public function expectedMethods() : array
{
Expand Down Expand Up @@ -214,7 +214,7 @@ public function expectedMethods() : array
/**
* Data provider
*
* @return array[][]
* @return ReflectionClass[][]|null[][]|string[][][]
*/
public function expectedAbstractPublicMethods() : array
{
Expand Down
Expand Up @@ -13,9 +13,9 @@
class ClassWithMethodWithByRefVariadicFunction
{
/**
* @param mixed & ...$fooz
* @param array<int, mixed> $fooz
*
* @return mixed[]
* @return array<int, mixed>
*/
public function tuz(& ...$fooz)
{
Expand Down
Expand Up @@ -18,13 +18,13 @@ class ClassWithMethodWithVariadicFunction
public $bar;

/**
* @var mixed[]
* @var mixed
*/
public $baz;

/**
* @param mixed $bar
* @param mixed ...$baz
* @param mixed $baz
*/
public function foo($bar, ...$baz)
{
Expand Down

0 comments on commit 9af8a41

Please sign in to comment.