Skip to content

Commit

Permalink
fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jan 11, 2022
1 parent 81b197e commit 76afdb0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 27 deletions.
38 changes: 19 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@
"symfony/string": "^6.0",
"symfony/yaml": "^5.4|^6.0",
"symplify/astral": "^10.0.9",
"symplify/autowire-array-parameter": "^10.0.2",
"symplify/composer-json-manipulator": "^10.0.2",
"symplify/console-color-diff": "^10.0.2",
"symplify/easy-parallel": "^10.0.2",
"symplify/package-builder": "^10.0.8",
"symplify/rule-doc-generator-contracts": "^10.0.2",
"symplify/simple-php-doc-parser": "^10.0.2",
"symplify/skipper": "^10.0.2",
"symplify/smart-file-system": "^10.0.2",
"symplify/symfony-php-config": "^10.0.5",
"symplify/vendor-patches": "^10.0.2",
"symplify/autowire-array-parameter": "^10.0.9",
"symplify/composer-json-manipulator": "^10.0.9",
"symplify/console-color-diff": "^10.0.9",
"symplify/easy-parallel": "^10.0.9",
"symplify/package-builder": "^10.0.9",
"symplify/rule-doc-generator-contracts": "^10.0.9",
"symplify/simple-php-doc-parser": "^10.0.9",
"symplify/skipper": "^10.0.9",
"symplify/smart-file-system": "^10.0.9",
"symplify/symfony-php-config": "^10.0.9",
"symplify/vendor-patches": "^10.0.9",
"tracy/tracy": "^2.8",
"webmozart/assert": "^1.10",
"helmich/typo3-typoscript-parser": "dev-master#0ccb3a6"
Expand All @@ -73,14 +73,14 @@
"phpunit/phpunit": "^9.5",
"rector/phpstan-rules": "^0.4.15",
"spatie/enum": "^3.10",
"symplify/coding-standard": "^10.0.2",
"symplify/easy-ci": "^10.0.2",
"symplify/easy-coding-standard": "^10.0.2",
"symplify/easy-testing": "^10.0.2",
"symplify/monorepo-builder": "^10.0.2",
"symplify/phpstan-extensions": "^10.0.2",
"symplify/phpstan-rules": "^10.0.2",
"symplify/rule-doc-generator": "^10.0.2",
"symplify/coding-standard": "^10.0.9",
"symplify/easy-ci": "^10.0.9",
"symplify/easy-coding-standard": "^10.0.9",
"symplify/easy-testing": "^10.0.9",
"symplify/monorepo-builder": "^10.0.9",
"symplify/phpstan-extensions": "^10.0.9",
"symplify/phpstan-rules": "^10.0.9",
"symplify/rule-doc-generator": "^10.0.9",
"timeweb/phpstan-enum": "dev-22-upgrade-phpstan-to-1.0"
},
"replace": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,24 @@ public function processNodes(array $stmts, SmartFileInfo $smartFileInfo): array

$traitScope = clone $scope;

$scopeContext = $this->privatesAccessor->getPrivatePropertyOfClass($traitScope, self::CONTEXT, ScopeContext::class);
$scopeContext = $this->privatesAccessor->getPrivatePropertyOfClass(
$traitScope,
self::CONTEXT,
ScopeContext::class
);
$traitContext = clone $scopeContext;
$this->privatesAccessor->setPrivatePropertyOfClass($traitContext, 'classReflection', $traitReflectionClass, ScopeContext::class);
$this->privatesAccessor->setPrivatePropertyOfClass($traitScope, self::CONTEXT, $traitContext, ScopeContext::class);
$this->privatesAccessor->setPrivatePropertyOfClass(
$traitContext,
'classReflection',
$traitReflectionClass,
ScopeContext::class
);
$this->privatesAccessor->setPrivatePropertyOfClass(
$traitScope,
self::CONTEXT,
$traitContext,
ScopeContext::class
);

$this->nodeScopeResolver->processNodes($node->stmts, $traitScope, $nodeCallback);
return;
Expand Down Expand Up @@ -201,19 +215,32 @@ private function decoratePHPStanNodeScopeResolverWithRenamedClassSourceLocator(
): void {
// 1. get PHPStan locator
/** @var MemoizingReflector $classReflector */
$classReflector = $this->privatesAccessor->getPrivatePropertyOfClass($nodeScopeResolver, 'reflector', MemoizingReflector::class);
$classReflector = $this->privatesAccessor->getPrivatePropertyOfClass(
$nodeScopeResolver,
'reflector',
MemoizingReflector::class
);

$reflector = $this->privatesAccessor->getPrivatePropertyOfClass($classReflector, 'reflector', Reflector::class);

/** @var SourceLocator $sourceLocator */
$sourceLocator = $this->privatesAccessor->getPrivatePropertyOfClass($reflector, 'sourceLocator', SourceLocator::class);
$sourceLocator = $this->privatesAccessor->getPrivatePropertyOfClass(
$reflector,
'sourceLocator',
SourceLocator::class
);

// 2. get Rector locator
$aggregateSourceLocator = new AggregateSourceLocator([
$sourceLocator,
$this->renamedClassesSourceLocator,
$this->parentAttributeSourceLocator,
]);
$this->privatesAccessor->setPrivatePropertyOfClass($reflector, 'sourceLocator', $aggregateSourceLocator, AggregateSourceLocator::class);
$this->privatesAccessor->setPrivatePropertyOfClass(
$reflector,
'sourceLocator',
$aggregateSourceLocator,
AggregateSourceLocator::class
);
}
}
14 changes: 12 additions & 2 deletions rules/TypeDeclaration/TypeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,18 @@ public function normalizeArrayTypeAndArrayNever(Type $type): Type
assert($traversedType instanceof ConstantArrayType);

// not sure why, but with direct new node everything gets nulled to MixedType
$this->privatesAccessor->setPrivatePropertyOfClass($traversedType, 'keyType', new MixedType(), Type::class);
$this->privatesAccessor->setPrivatePropertyOfClass($traversedType, 'itemType', new MixedType(), Type::class);
$this->privatesAccessor->setPrivatePropertyOfClass(
$traversedType,
'keyType',
new MixedType(),
Type::class
);
$this->privatesAccessor->setPrivatePropertyOfClass(
$traversedType,
'itemType',
new MixedType(),
Type::class
);

return $traversedType;
}
Expand Down

0 comments on commit 76afdb0

Please sign in to comment.