Skip to content
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
},
"autoload": {
"psr-4": {
"Yii\\PHPStan\\": "src"
"Yii2\\Extensions\\PHPStan\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Yii\\PHPStan\\Tests\\": "tests"
"Yii2\\Extensions\\PHPStan\\Tests\\": "tests"
}
},
"extra": {
Expand Down
22 changes: 11 additions & 11 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ parametersSchema:

services:
-
class: Yii\PHPStan\Reflection\ApplicationPropertiesClassReflectionExtension
class: Yii2\Extensions\PHPStan\Reflection\ApplicationPropertiesClassReflectionExtension
tags: [phpstan.broker.propertiesClassReflectionExtension]
-
class: Yii\PHPStan\Reflection\RequestMethodsClassReflectionExtension
class: Yii2\Extensions\PHPStan\Reflection\RequestMethodsClassReflectionExtension
tags: [phpstan.broker.methodsClassReflectionExtension]
-
class: Yii\PHPStan\Reflection\RequestPropertiesClassReflectionExtension
class: Yii2\Extensions\PHPStan\Reflection\RequestPropertiesClassReflectionExtension
tags: [phpstan.broker.propertiesClassReflectionExtension]
-
class: Yii\PHPStan\Reflection\ResponsePropertiesClassReflectionExtension
class: Yii2\Extensions\PHPStan\Reflection\ResponsePropertiesClassReflectionExtension
tags: [phpstan.broker.propertiesClassReflectionExtension]
-
class: Yii\PHPStan\Reflection\UserPropertiesClassReflectionExtension
class: Yii2\Extensions\PHPStan\Reflection\UserPropertiesClassReflectionExtension
tags: [phpstan.broker.propertiesClassReflectionExtension]
-
class: Yii\PHPStan\Type\ActiveQueryDynamicMethodReturnTypeExtension
class: Yii2\Extensions\PHPStan\Type\ActiveQueryDynamicMethodReturnTypeExtension
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
-
class: Yii\PHPStan\Type\ActiveRecordDynamicMethodReturnTypeExtension
class: Yii2\Extensions\PHPStan\Type\ActiveRecordDynamicMethodReturnTypeExtension
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
-
class: Yii\PHPStan\Type\HeaderCollectionDynamicMethodReturnTypeExtension
class: Yii2\Extensions\PHPStan\Type\HeaderCollectionDynamicMethodReturnTypeExtension
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
-
class: Yii\PHPStan\Type\ActiveRecordDynamicStaticMethodReturnTypeExtension
class: Yii2\Extensions\PHPStan\Type\ActiveRecordDynamicStaticMethodReturnTypeExtension
tags: [phpstan.broker.dynamicStaticMethodReturnTypeExtension]
-
class: Yii\PHPStan\Type\ContainerDynamicMethodReturnTypeExtension
class: Yii2\Extensions\PHPStan\Type\ContainerDynamicMethodReturnTypeExtension
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]

- Yii\PHPStan\ServiceMap(%yii2.config_path%)
- Yii2\Extensions\PHPStan\ServiceMap(%yii2.config_path%)
16 changes: 0 additions & 16 deletions infection.json.dist

This file was deleted.

14 changes: 0 additions & 14 deletions psalm.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Reflection;
namespace Yii2\Extensions\PHPStan\Reflection;

use PHPStan\Reflection\Annotations\AnnotationsPropertiesClassReflectionExtension;
use PHPStan\Reflection\ClassReflection;
Expand All @@ -12,8 +12,8 @@
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\ObjectType;
use Yii2\Extensions\PHPStan\ServiceMap;
use yii\base\Application as BaseApplication;
use Yii\PHPStan\ServiceMap;
use yii\web\Application as WebApplication;

final class ApplicationPropertiesClassReflectionExtension implements PropertiesClassReflectionExtension
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/ComponentPropertyReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Reflection;
namespace Yii2\Extensions\PHPStan\Reflection;

use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\PropertyReflection;
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/RequestMethodsClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Reflection;
namespace Yii2\Extensions\PHPStan\Reflection;

use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodReflection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Reflection;
namespace Yii2\Extensions\PHPStan\Reflection;

use PHPStan\Analyser\OutOfClassScope;
use PHPStan\Reflection\ClassReflection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Reflection;
namespace Yii2\Extensions\PHPStan\Reflection;

use PHPStan\Analyser\OutOfClassScope;
use PHPStan\Reflection\ClassReflection;
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/UserPropertiesClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Reflection;
namespace Yii2\Extensions\PHPStan\Reflection;

use PHPStan\Reflection\Annotations\AnnotationsPropertiesClassReflectionExtension;
use PHPStan\Reflection\ClassReflection;
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan;
namespace Yii2\Extensions\PHPStan;

use Closure;
use InvalidArgumentException;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ActiveQueryDynamicMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Type;
namespace Yii2\Extensions\PHPStan\Type;

use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ActiveQueryObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Type;
namespace Yii2\Extensions\PHPStan\Type;

use PHPStan\Type\ObjectType;
use PHPStan\Type\VerbosityLevel;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ActiveRecordDynamicMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Type;
namespace Yii2\Extensions\PHPStan\Type;

use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Type;
namespace Yii2\Extensions\PHPStan\Type;

use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ActiveRecordObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Type;
namespace Yii2\Extensions\PHPStan\Type;

use ArrayAccess;
use PHPStan\ShouldNotHappenException;
Expand Down
4 changes: 2 additions & 2 deletions src/Type/ContainerDynamicMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Type;
namespace Yii2\Extensions\PHPStan\Type;

use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
Expand All @@ -13,8 +13,8 @@
use PHPStan\Type\DynamicMethodReturnTypeExtension;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Yii2\Extensions\PHPStan\ServiceMap;
use yii\di\Container;
use Yii\PHPStan\ServiceMap;

final class ContainerDynamicMethodReturnTypeExtension implements DynamicMethodReturnTypeExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Type;
namespace Yii2\Extensions\PHPStan\Type;

use PhpParser\Node\Arg;
use PhpParser\Node\Expr\ConstFetch;
Expand Down
66 changes: 48 additions & 18 deletions tests/ServiceMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Tests;
namespace Yii2\Extensions\PHPStan\Tests;

use InvalidArgumentException;
use PhpParser\Node\Scalar\String_;
Expand All @@ -12,8 +12,8 @@
use SplFileInfo;
use SplObjectStorage;
use SplStack;
use Yii\PHPStan\ServiceMap;
use Yii\PHPStan\Tests\Yii\MyActiveRecord;
use Yii2\Extensions\PHPStan\ServiceMap;
use Yii2\Extensions\PHPStan\Tests\Yii\MyActiveRecord;

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

new ServiceMap(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-type.php');
new ServiceMap(
__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-type.php'
);
}

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

new ServiceMap(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-array.php');
new ServiceMap(
__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-array.php'
);
}

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

new ServiceMap(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-component.php');
new ServiceMap(
__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'yii-config-invalid-component.php'
);
}

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

self::assertSame(MyActiveRecord::class, $serviceMap->getServiceClassFromNode(new String_('singleton-string')));
self::assertSame(MyActiveRecord::class, $serviceMap->getServiceClassFromNode(new String_(MyActiveRecord::class)));
self::assertSame(SplStack::class, $serviceMap->getServiceClassFromNode(new String_('singleton-closure')));
self::assertSame(SplObjectStorage::class, $serviceMap->getServiceClassFromNode(new String_('singleton-service')));
self::assertSame(SplFileInfo::class, $serviceMap->getServiceClassFromNode(new String_('singleton-nested-service-class')));

self::assertSame(SplStack::class, $serviceMap->getServiceClassFromNode(new String_('closure')));
self::assertSame(SplObjectStorage::class, $serviceMap->getServiceClassFromNode(new String_('service')));
self::assertSame(SplFileInfo::class, $serviceMap->getServiceClassFromNode(new String_('nested-service-class')));

self::assertSame(MyActiveRecord::class, $serviceMap->getComponentClassById('customComponent'));
self::assertSame(MyActiveRecord::class, $serviceMap->getComponentClassById('customInitializedComponent'));
$this->assertSame(
MyActiveRecord::class,
$serviceMap->getServiceClassFromNode(new String_('singleton-string')),
);
$this->assertSame(
MyActiveRecord::class,
$serviceMap->getServiceClassFromNode(new String_(MyActiveRecord::class)),
);
$this->assertSame(
SplStack::class,
$serviceMap->getServiceClassFromNode(new String_('singleton-closure')),
);
$this->assertSame(
SplObjectStorage::class,
$serviceMap->getServiceClassFromNode(new String_('singleton-service')),
);
$this->assertSame(
SplFileInfo::class,
$serviceMap->getServiceClassFromNode(new String_('singleton-nested-service-class')),
);

$this->assertSame(
SplStack::class,
$serviceMap->getServiceClassFromNode(new String_('closure')),
);
$this->assertSame(
SplObjectStorage::class,
$serviceMap->getServiceClassFromNode(new String_('service')),
);
$this->assertSame(
SplFileInfo::class,
$serviceMap->getServiceClassFromNode(new String_('nested-service-class')),
);

$this->assertSame(MyActiveRecord::class, $serviceMap->getComponentClassById('customComponent'));
$this->assertSame(MyActiveRecord::class, $serviceMap->getComponentClassById('customInitializedComponent'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Yii/MyActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Tests\Yii;
namespace Yii2\Extensions\PHPStan\Tests\Yii;

use yii\db\ActiveRecord;

Expand Down
2 changes: 1 addition & 1 deletion tests/Yii/MyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Yii\PHPStan\Tests\Yii;
namespace Yii2\Extensions\PHPStan\Tests\Yii;

use SplObjectStorage;
use Yii;
Expand Down
2 changes: 1 addition & 1 deletion tests/assets/yii-config-valid.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use Yii\PHPStan\Tests\Yii\MyActiveRecord;
use Yii2\Extensions\PHPStan\Tests\Yii\MyActiveRecord;

return [
'components' => [
Expand Down