Skip to content

Commit

Permalink
Fix: Move and rename classes
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Mar 1, 2020
1 parent e968aeb commit 9ff5540
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 42 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ For a full diff see [`0.6.2...master`][0.6.2...master].
### Changed

* Moved `src/extension.neon` to `extension.neon` ([#140]), by [@localheinz]
* Marked classes as `@final` ([#144]), by [@localheinz]
* Marked classes as `@internal` ([#144]), by [@localheinz]
* Moved and renamed internal classes ([#153]), by [@localheinz]

## [`0.6.2`][0.6.2]

Expand Down Expand Up @@ -125,6 +126,7 @@ For a full diff see [`afd6fd9...0.1`][afd6fd9...0.1].
[#124]: https://github.com/Jan0707/phpstan-prophecy/pull/124
[#140]: https://github.com/Jan0707/phpstan-prophecy/pull/140
[#144]: https://github.com/Jan0707/phpstan-prophecy/pull/144
[#153]: https://github.com/Jan0707/phpstan-prophecy/pull/153

[@localheinz]: https://github.com/localheinz
[@PedroTroller]: https://github.com/PedroTroller
27 changes: 14 additions & 13 deletions extension.neon
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
services:
-
class: JanGregor\Prophecy\Extension\ProphetProphesizeDynamicReturnTypeExtension
class: JanGregor\Prophecy\PhpDoc\ObjectProphecy\TypeNodeResolverExtension
tags:
- phpstan.phpDoc.typeNodeResolverExtension

-
class: JanGregor\Prophecy\Reflection\ObjectProphecy\MethodsClassReflectionExtension
tags:
- phpstan.broker.methodsClassReflectionExtension

-
class: JanGregor\Prophecy\Type\Prophet\ProphesizeDynamicReturnTypeExtension
arguments:
className: Prophecy\Prophet
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
autowired: false

-
class: JanGregor\Prophecy\Extension\ProphetProphesizeDynamicReturnTypeExtension
class: JanGregor\Prophecy\Type\Prophet\ProphesizeDynamicReturnTypeExtension
arguments:
className: PHPUnit\Framework\TestCase
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
autowired: false

-
class: JanGregor\Prophecy\Extension\ObjectProphecyRevealDynamicReturnTypeExtension
class: JanGregor\Prophecy\Type\ObjectProphecy\RevealDynamicReturnTypeExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

-
class: JanGregor\Prophecy\Extension\ObjectProphecyWillExtendOrImplementDynamicReturnTypeExtension
class: JanGregor\Prophecy\Type\ObjectProphecy\WillExtendOrImplementDynamicReturnTypeExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

-
class: JanGregor\Prophecy\PhpDoc\TypeNodeResolverExtension
tags:
- phpstan.phpDoc.typeNodeResolverExtension

-
class: JanGregor\Prophecy\Reflection\ProphecyMethodsClassReflectionExtension
tags:
- phpstan.broker.methodsClassReflectionExtension
4 changes: 2 additions & 2 deletions phpstan-without-extension-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ parameters:
path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php

-
message: "#^Parameter \\#1 \\$declaringClass of class JanGregor\\\\Prophecy\\\\Reflection\\\\ObjectProphecyMethodReflection constructor expects PHPStan\\\\Reflection\\\\ClassReflection, object given\\.$#"
message: "#^Parameter \\#1 \\$declaringClass of class JanGregor\\\\Prophecy\\\\Reflection\\\\ObjectProphecy\\\\MethodReflection constructor expects PHPStan\\\\Reflection\\\\ClassReflection, object given\\.$#"
count: 2
path: test/Unit/Reflection/ObjectProphecyMethodReflectionTest.php
path: test/Unit/Reflection/ObjectProphecy/MethodReflectionTest.php

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* @see https://github.com/Jan0707/phpstan-prophecy
*/

namespace JanGregor\Prophecy\PhpDoc;
namespace JanGregor\Prophecy\PhpDoc\ObjectProphecy;

use JanGregor\Prophecy\Type\ObjectProphecyType;
use JanGregor\Prophecy\Type\ObjectProphecy;
use PHPStan\Analyser;
use PHPStan\PhpDoc;
use PHPStan\PhpDocParser;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function resolve(PhpDocParser\Ast\Type\TypeNode $typeNode, Analyser\NameS
}

if (null !== $objectProphecyType && null !== $prophesizedType) {
return new ObjectProphecyType($prophesizedType->getClassName());
return new ObjectProphecy\ObjectProphecyType($prophesizedType->getClassName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @see https://github.com/Jan0707/phpstan-prophecy
*/

namespace JanGregor\Prophecy\Reflection;
namespace JanGregor\Prophecy\Reflection\ObjectProphecy;

use PHPStan\Reflection;
use PHPStan\TrinaryLogic;
Expand All @@ -21,7 +21,7 @@
/**
* @internal
*/
final class ObjectProphecyMethodReflection implements Reflection\MethodReflection
final class MethodReflection implements Reflection\MethodReflection
{
private $declaringClass;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
* @see https://github.com/Jan0707/phpstan-prophecy
*/

namespace JanGregor\Prophecy\Reflection;
namespace JanGregor\Prophecy\Reflection\ObjectProphecy;

use PHPStan\Reflection;

/**
* @internal
*/
final class ProphecyMethodsClassReflectionExtension implements Reflection\MethodsClassReflectionExtension
final class MethodsClassReflectionExtension implements Reflection\MethodsClassReflectionExtension
{
public function hasMethod(Reflection\ClassReflection $classReflection, string $methodName): bool
{
Expand All @@ -29,6 +29,6 @@ public function hasMethod(Reflection\ClassReflection $classReflection, string $m

public function getMethod(Reflection\ClassReflection $classReflection, string $methodName): Reflection\MethodReflection
{
return new ObjectProphecyMethodReflection($classReflection, $methodName);
return new MethodReflection($classReflection, $methodName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @see https://github.com/Jan0707/phpstan-prophecy
*/

namespace JanGregor\Prophecy\Type;
namespace JanGregor\Prophecy\Type\ObjectProphecy;

use PHPStan\Type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
* @see https://github.com/Jan0707/phpstan-prophecy
*/

namespace JanGregor\Prophecy\Extension;
namespace JanGregor\Prophecy\Type\ObjectProphecy;

use JanGregor\Prophecy\Type\ObjectProphecyType;
use PhpParser\Node;
use PHPStan\Analyser;
use PHPStan\Reflection;
Expand All @@ -22,7 +21,7 @@
/**
* @internal
*/
final class ObjectProphecyRevealDynamicReturnTypeExtension implements Type\DynamicMethodReturnTypeExtension
final class RevealDynamicReturnTypeExtension implements Type\DynamicMethodReturnTypeExtension
{
public function getClass(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
* @see https://github.com/Jan0707/phpstan-prophecy
*/

namespace JanGregor\Prophecy\Extension;
namespace JanGregor\Prophecy\Type\ObjectProphecy;

use JanGregor\Prophecy\Type\ObjectProphecyType;
use PhpParser\Node;
use PHPStan\Analyser;
use PHPStan\Reflection;
Expand All @@ -23,7 +22,7 @@
/**
* @internal
*/
final class ObjectProphecyWillExtendOrImplementDynamicReturnTypeExtension implements Type\DynamicMethodReturnTypeExtension
final class WillExtendOrImplementDynamicReturnTypeExtension implements Type\DynamicMethodReturnTypeExtension
{
public function getClass(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* @see https://github.com/Jan0707/phpstan-prophecy
*/

namespace JanGregor\Prophecy\Extension;
namespace JanGregor\Prophecy\Type\Prophet;

use JanGregor\Prophecy\Type\ObjectProphecyType;
use JanGregor\Prophecy\Type\ObjectProphecy;
use PhpParser\Node;
use PHPStan\Analyser;
use PHPStan\Reflection;
Expand All @@ -23,7 +23,7 @@
/**
* @internal
*/
final class ProphetProphesizeDynamicReturnTypeExtension implements Type\DynamicMethodReturnTypeExtension
final class ProphesizeDynamicReturnTypeExtension implements Type\DynamicMethodReturnTypeExtension
{
private $className;

Expand Down Expand Up @@ -52,7 +52,7 @@ public function getTypeFromMethodCall(
$returnType = $parametersAcceptor->getReturnType();

if (0 === \count($methodCall->args)) {
return new ObjectProphecyType();
return new ObjectProphecy\ObjectProphecyType();
}

$argumentType = $scope->getType($methodCall->args[0]->value);
Expand All @@ -75,6 +75,6 @@ public function getTypeFromMethodCall(
$className = $scope->getClassReflection()->getName();
}

return new ObjectProphecyType($className);
return new ObjectProphecy\ObjectProphecyType($className);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
* @see https://github.com/Jan0707/phpstan-prophecy
*/

namespace JanGregor\Prophecy\Test\Unit\Reflection;
namespace JanGregor\Prophecy\Test\Unit\Reflection\ObjectProphecy;

use JanGregor\Prophecy\Reflection\ObjectProphecyMethodReflection;
use JanGregor\Prophecy\Reflection\ObjectProphecy\MethodReflection;
use PHPStan\Reflection;
use PHPStan\TrinaryLogic;
use PHPStan\Type;
use PHPUnit\Framework;
use Prophecy\Prophecy;

/**
* @covers \JanGregor\Prophecy\Reflection\ObjectProphecyMethodReflection
* @covers \JanGregor\Prophecy\Reflection\ObjectProphecy\MethodReflection
*
* @internal
*/
final class ObjectProphecyMethodReflectionTest extends Framework\TestCase
final class MethodReflectionTest extends Framework\TestCase
{
public function testConstructorSetsValues(): void
{
$classReflection = $this->prophesize(Reflection\ClassReflection::class);
$name = 'hmm';

$reflection = new ObjectProphecyMethodReflection(
$reflection = new MethodReflection(
$classReflection->reveal(),
$name
);
Expand All @@ -43,7 +43,7 @@ public function testConstructorSetsValues(): void

public function testDefaults(): void
{
$reflection = new ObjectProphecyMethodReflection(
$reflection = new MethodReflection(
$this->prophesize(Reflection\ClassReflection::class)->reveal(),
'hmm'
);
Expand Down

0 comments on commit 9ff5540

Please sign in to comment.