Skip to content

Commit ca0d97e

Browse files
Better namespace. (#9)
1 parent 88b84a5 commit ca0d97e

22 files changed

+80
-80
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
},
2323
"autoload": {
2424
"psr-4": {
25-
"Yii\\PHPStan\\": "src"
25+
"Yii2\\Extensions\\PHPStan\\": "src"
2626
}
2727
},
2828
"autoload-dev": {
2929
"psr-4": {
30-
"Yii\\PHPStan\\Tests\\": "tests"
30+
"Yii2\\Extensions\\PHPStan\\Tests\\": "tests"
3131
}
3232
},
3333
"extra": {

extension.neon

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@ parametersSchema:
1111

1212
services:
1313
-
14-
class: Yii\PHPStan\Reflection\ApplicationPropertiesClassReflectionExtension
14+
class: Yii2\Extensions\PHPStan\Reflection\ApplicationPropertiesClassReflectionExtension
1515
tags: [phpstan.broker.propertiesClassReflectionExtension]
1616
-
17-
class: Yii\PHPStan\Reflection\RequestMethodsClassReflectionExtension
17+
class: Yii2\Extensions\PHPStan\Reflection\RequestMethodsClassReflectionExtension
1818
tags: [phpstan.broker.methodsClassReflectionExtension]
1919
-
20-
class: Yii\PHPStan\Reflection\RequestPropertiesClassReflectionExtension
20+
class: Yii2\Extensions\PHPStan\Reflection\RequestPropertiesClassReflectionExtension
2121
tags: [phpstan.broker.propertiesClassReflectionExtension]
2222
-
23-
class: Yii\PHPStan\Reflection\ResponsePropertiesClassReflectionExtension
23+
class: Yii2\Extensions\PHPStan\Reflection\ResponsePropertiesClassReflectionExtension
2424
tags: [phpstan.broker.propertiesClassReflectionExtension]
2525
-
26-
class: Yii\PHPStan\Reflection\UserPropertiesClassReflectionExtension
26+
class: Yii2\Extensions\PHPStan\Reflection\UserPropertiesClassReflectionExtension
2727
tags: [phpstan.broker.propertiesClassReflectionExtension]
2828
-
29-
class: Yii\PHPStan\Type\ActiveQueryDynamicMethodReturnTypeExtension
29+
class: Yii2\Extensions\PHPStan\Type\ActiveQueryDynamicMethodReturnTypeExtension
3030
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
3131
-
32-
class: Yii\PHPStan\Type\ActiveRecordDynamicMethodReturnTypeExtension
32+
class: Yii2\Extensions\PHPStan\Type\ActiveRecordDynamicMethodReturnTypeExtension
3333
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
3434
-
35-
class: Yii\PHPStan\Type\HeaderCollectionDynamicMethodReturnTypeExtension
35+
class: Yii2\Extensions\PHPStan\Type\HeaderCollectionDynamicMethodReturnTypeExtension
3636
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
3737
-
38-
class: Yii\PHPStan\Type\ActiveRecordDynamicStaticMethodReturnTypeExtension
38+
class: Yii2\Extensions\PHPStan\Type\ActiveRecordDynamicStaticMethodReturnTypeExtension
3939
tags: [phpstan.broker.dynamicStaticMethodReturnTypeExtension]
4040
-
41-
class: Yii\PHPStan\Type\ContainerDynamicMethodReturnTypeExtension
41+
class: Yii2\Extensions\PHPStan\Type\ContainerDynamicMethodReturnTypeExtension
4242
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
4343

44-
- Yii\PHPStan\ServiceMap(%yii2.config_path%)
44+
- Yii2\Extensions\PHPStan\ServiceMap(%yii2.config_path%)

infection.json.dist

-16
This file was deleted.

psalm.xml

-14
This file was deleted.

src/Reflection/ApplicationPropertiesClassReflectionExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Reflection;
5+
namespace Yii2\Extensions\PHPStan\Reflection;
66

77
use PHPStan\Reflection\Annotations\AnnotationsPropertiesClassReflectionExtension;
88
use PHPStan\Reflection\ClassReflection;
@@ -12,8 +12,8 @@
1212
use PHPStan\Reflection\PropertyReflection;
1313
use PHPStan\Reflection\ReflectionProvider;
1414
use PHPStan\Type\ObjectType;
15+
use Yii2\Extensions\PHPStan\ServiceMap;
1516
use yii\base\Application as BaseApplication;
16-
use Yii\PHPStan\ServiceMap;
1717
use yii\web\Application as WebApplication;
1818

1919
final class ApplicationPropertiesClassReflectionExtension implements PropertiesClassReflectionExtension

src/Reflection/ComponentPropertyReflection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Reflection;
5+
namespace Yii2\Extensions\PHPStan\Reflection;
66

77
use PHPStan\Reflection\ClassReflection;
88
use PHPStan\Reflection\PropertyReflection;

src/Reflection/RequestMethodsClassReflectionExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Reflection;
5+
namespace Yii2\Extensions\PHPStan\Reflection;
66

77
use PHPStan\Reflection\ClassReflection;
88
use PHPStan\Reflection\MethodReflection;

src/Reflection/RequestPropertiesClassReflectionExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Reflection;
5+
namespace Yii2\Extensions\PHPStan\Reflection;
66

77
use PHPStan\Analyser\OutOfClassScope;
88
use PHPStan\Reflection\ClassReflection;

src/Reflection/ResponsePropertiesClassReflectionExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Reflection;
5+
namespace Yii2\Extensions\PHPStan\Reflection;
66

77
use PHPStan\Analyser\OutOfClassScope;
88
use PHPStan\Reflection\ClassReflection;

src/Reflection/UserPropertiesClassReflectionExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Reflection;
5+
namespace Yii2\Extensions\PHPStan\Reflection;
66

77
use PHPStan\Reflection\Annotations\AnnotationsPropertiesClassReflectionExtension;
88
use PHPStan\Reflection\ClassReflection;

src/ServiceMap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan;
5+
namespace Yii2\Extensions\PHPStan;
66

77
use Closure;
88
use InvalidArgumentException;

src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Type;
5+
namespace Yii2\Extensions\PHPStan\Type;
66

77
use PhpParser\Node\Arg;
88
use PhpParser\Node\Expr\MethodCall;

src/Type/ActiveQueryObjectType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Type;
5+
namespace Yii2\Extensions\PHPStan\Type;
66

77
use PHPStan\Type\ObjectType;
88
use PHPStan\Type\VerbosityLevel;

src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Type;
5+
namespace Yii2\Extensions\PHPStan\Type;
66

77
use PhpParser\Node\Arg;
88
use PhpParser\Node\Expr\MethodCall;

src/Type/ActiveRecordDynamicStaticMethodReturnTypeExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Type;
5+
namespace Yii2\Extensions\PHPStan\Type;
66

77
use PhpParser\Node\Expr\StaticCall;
88
use PhpParser\Node\Name;

src/Type/ActiveRecordObjectType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Type;
5+
namespace Yii2\Extensions\PHPStan\Type;
66

77
use ArrayAccess;
88
use PHPStan\ShouldNotHappenException;

src/Type/ContainerDynamicMethodReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Type;
5+
namespace Yii2\Extensions\PHPStan\Type;
66

77
use PhpParser\Node\Arg;
88
use PhpParser\Node\Expr\MethodCall;
@@ -13,8 +13,8 @@
1313
use PHPStan\Type\DynamicMethodReturnTypeExtension;
1414
use PHPStan\Type\ObjectType;
1515
use PHPStan\Type\Type;
16+
use Yii2\Extensions\PHPStan\ServiceMap;
1617
use yii\di\Container;
17-
use Yii\PHPStan\ServiceMap;
1818

1919
final class ContainerDynamicMethodReturnTypeExtension implements DynamicMethodReturnTypeExtension
2020
{

src/Type/HeaderCollectionDynamicMethodReturnTypeExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Type;
5+
namespace Yii2\Extensions\PHPStan\Type;
66

77
use PhpParser\Node\Arg;
88
use PhpParser\Node\Expr\ConstFetch;

tests/ServiceMapTest.php

+48-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Tests;
5+
namespace Yii2\Extensions\PHPStan\Tests;
66

77
use InvalidArgumentException;
88
use PhpParser\Node\Scalar\String_;
@@ -12,8 +12,8 @@
1212
use SplFileInfo;
1313
use SplObjectStorage;
1414
use SplStack;
15-
use Yii\PHPStan\ServiceMap;
16-
use Yii\PHPStan\Tests\Yii\MyActiveRecord;
15+
use Yii2\Extensions\PHPStan\ServiceMap;
16+
use Yii2\Extensions\PHPStan\Tests\Yii\MyActiveRecord;
1717

1818
final class ServiceMapTest extends TestCase
1919
{
@@ -44,7 +44,9 @@ public function testThrowExceptionWhenServiceHasUnsupportedType(): void
4444
$this->expectException(RuntimeException::class);
4545
$this->expectExceptionMessage('Unsupported service definition for unsupported-type');
4646

47-
new ServiceMap(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-type.php');
47+
new ServiceMap(
48+
__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-type.php'
49+
);
4850
}
4951

5052
/**
@@ -55,7 +57,9 @@ public function testThrowExceptionWhenServiceHasUnsupportedArray(): void
5557
$this->expectException(RuntimeException::class);
5658
$this->expectExceptionMessage('Cannot guess service definition for unsupported-array');
5759

58-
new ServiceMap(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-array.php');
60+
new ServiceMap(
61+
__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-array.php'
62+
);
5963
}
6064

6165
/**
@@ -66,7 +70,9 @@ public function testThrowExceptionWhenComponentHasInvalidValue(): void
6670
$this->expectException(RuntimeException::class);
6771
$this->expectExceptionMessage('Invalid value for component with id customComponent. Expected object or array.');
6872

69-
new ServiceMap(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-component.php');
73+
new ServiceMap(
74+
__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-component.php'
75+
);
7076
}
7177

7278
/**
@@ -76,18 +82,42 @@ public function testItLoadsServicesAndComponents(): void
7682
{
7783
$serviceMap = new ServiceMap(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-valid.php');
7884

79-
self::assertSame(MyActiveRecord::class, $serviceMap->getServiceClassFromNode(new String_('singleton-string')));
80-
self::assertSame(MyActiveRecord::class, $serviceMap->getServiceClassFromNode(new String_(MyActiveRecord::class)));
81-
self::assertSame(SplStack::class, $serviceMap->getServiceClassFromNode(new String_('singleton-closure')));
82-
self::assertSame(SplObjectStorage::class, $serviceMap->getServiceClassFromNode(new String_('singleton-service')));
83-
self::assertSame(SplFileInfo::class, $serviceMap->getServiceClassFromNode(new String_('singleton-nested-service-class')));
84-
85-
self::assertSame(SplStack::class, $serviceMap->getServiceClassFromNode(new String_('closure')));
86-
self::assertSame(SplObjectStorage::class, $serviceMap->getServiceClassFromNode(new String_('service')));
87-
self::assertSame(SplFileInfo::class, $serviceMap->getServiceClassFromNode(new String_('nested-service-class')));
88-
89-
self::assertSame(MyActiveRecord::class, $serviceMap->getComponentClassById('customComponent'));
90-
self::assertSame(MyActiveRecord::class, $serviceMap->getComponentClassById('customInitializedComponent'));
85+
$this->assertSame(
86+
MyActiveRecord::class,
87+
$serviceMap->getServiceClassFromNode(new String_('singleton-string')),
88+
);
89+
$this->assertSame(
90+
MyActiveRecord::class,
91+
$serviceMap->getServiceClassFromNode(new String_(MyActiveRecord::class)),
92+
);
93+
$this->assertSame(
94+
SplStack::class,
95+
$serviceMap->getServiceClassFromNode(new String_('singleton-closure')),
96+
);
97+
$this->assertSame(
98+
SplObjectStorage::class,
99+
$serviceMap->getServiceClassFromNode(new String_('singleton-service')),
100+
);
101+
$this->assertSame(
102+
SplFileInfo::class,
103+
$serviceMap->getServiceClassFromNode(new String_('singleton-nested-service-class')),
104+
);
105+
106+
$this->assertSame(
107+
SplStack::class,
108+
$serviceMap->getServiceClassFromNode(new String_('closure')),
109+
);
110+
$this->assertSame(
111+
SplObjectStorage::class,
112+
$serviceMap->getServiceClassFromNode(new String_('service')),
113+
);
114+
$this->assertSame(
115+
SplFileInfo::class,
116+
$serviceMap->getServiceClassFromNode(new String_('nested-service-class')),
117+
);
118+
119+
$this->assertSame(MyActiveRecord::class, $serviceMap->getComponentClassById('customComponent'));
120+
$this->assertSame(MyActiveRecord::class, $serviceMap->getComponentClassById('customInitializedComponent'));
91121
}
92122

93123
/**

tests/Yii/MyActiveRecord.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Tests\Yii;
5+
namespace Yii2\Extensions\PHPStan\Tests\Yii;
66

77
use yii\db\ActiveRecord;
88

tests/Yii/MyController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Yii\PHPStan\Tests\Yii;
5+
namespace Yii2\Extensions\PHPStan\Tests\Yii;
66

77
use SplObjectStorage;
88
use Yii;

tests/assets/yii-config-valid.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use Yii\PHPStan\Tests\Yii\MyActiveRecord;
5+
use Yii2\Extensions\PHPStan\Tests\Yii\MyActiveRecord;
66

77
return [
88
'components' => [

0 commit comments

Comments
 (0)