Skip to content

Commit

Permalink
[TASK] Load stubs via phpstan (#2200)
Browse files Browse the repository at this point in the history
* [TASK] Use static reflection

* [TASK] Add stubs for Migrations
  • Loading branch information
sabbelasichon authored Apr 22, 2021
1 parent 9c18bab commit c924f8c
Show file tree
Hide file tree
Showing 1,214 changed files with 16,799 additions and 34 deletions.
5 changes: 0 additions & 5 deletions captainhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
"pre-commit": {
"enabled": true,
"actions": [
{
"action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting",
"options": [],
"conditions": []
},
{
"action": "composer run check-style",
"options": [],
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
"Ssch\\TYPO3Rector\\Tests\\": "tests",
"Ssch\\TYPO3Rector\\PHPStan\\Tests\\": "utils/phpstan/tests",
"Ssch\\TYPO3Rector\\Rules\\Tests\\": "utils/rules/tests",
"Ssch\\TYPO3Rector\\Rules\\": "utils/rules/src"
"Ssch\\TYPO3Rector\\Rules\\": "utils/rules/src",
"Ssch\\TYPO3Rector\\Stubs\\": "utils/stubs/src"
},
"classmap": [
"stubs"
],
"exclude-from-classmap": [
"**.php.inc"
]
Expand Down
3 changes: 1 addition & 2 deletions config/solr/solr_php_client_to_solarium.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use ApacheSolrForTypo3\Solr\System\Solr\Document\Document;
use ApacheSolrForTypo3\Solr\System\Solr\ResponseAdapter;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Ssch\TYPO3Rector\Rector\Extensions\solr\ApacheSolrDocumentToSolariumDocumentRector;
Expand All @@ -17,7 +16,7 @@
->class(RenameClassRector::class)
->call('configure', [[
RenameClassRector::OLD_TO_NEW_CLASSES => [
Apache_Solr_Document::class => Document::class,
'Apache_Solr_Document' => 'ApacheSolrForTypo3\Solr\System\Solr\Document\Document',
Apache_Solr_Response::class => ResponseAdapter::class,
],
]]);
Expand Down
2 changes: 2 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
__DIR__ . '/utils',
]);

$parameters->set(Option::SKIP, [__DIR__ . '/utils/stubs/templates']);

$services = $containerConfigurator->services();

$services->set(LineLengthFixer::class);
Expand Down
2 changes: 0 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, __DIR__ . '/phpstan.neon');

$parameters->set(Option::AUTOLOAD_PATHS, [__DIR__ . '/stubs']);

$services = $containerConfigurator->services();

$services->set(AddCodeCoverageIgnoreToMethodRectorDefinitionRector::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\Variable;
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Ssch\TYPO3Rector\Helper\StringUtility;
Expand Down Expand Up @@ -153,8 +154,10 @@ private function createNewControllerActionsArray(
continue;
}

// If already transformed
if (class_exists($controllerClassName)) {
$controllerClassNameType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($controllerActions->key);

if ($controllerClassNameType instanceof ConstantStringType) {
// Already transformed
continue;
}

Expand Down
8 changes: 0 additions & 8 deletions src/Rector/v9/v0/MetaTagManagementRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use ReflectionClass;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
Expand Down Expand Up @@ -158,13 +157,6 @@ private function createXUCompatibleMetaTag(MethodCall $methodCall): MethodCall
$value = 'IE=8';
if (count($methodCall->args) > 0) {
$value = $methodCall->args[0]->value;
} else {
$classReflection = new ReflectionClass(DocumentTemplate::class);
$defaultProperties = array_values($classReflection->getDefaultProperties());

if (count($defaultProperties) > 0) {
$value = $defaultProperties[0];
}
}

return $this->nodeFactory->createMethodCall(
Expand Down
14 changes: 14 additions & 0 deletions stubs/Migrations/AbstractAuthenticationService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Sv;

if (class_exists(AbstractAuthenticationService::class)) {
return;
}

final class AbstractAuthenticationService
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/AbstractComposedSalt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Saltedpasswords\Salt;

if (class_exists(AbstractComposedSalt::class)) {
return;
}

final class AbstractComposedSalt
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/AbstractConditionViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Fluid\Core\ViewHelper;

if (class_exists(AbstractConditionViewHelper::class)) {
return;
}

final class AbstractConditionViewHelper
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/AbstractNode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree;

if (class_exists(AbstractNode::class)) {
return;
}

final class AbstractNode
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/AbstractSalt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Saltedpasswords\Salt;

if (class_exists(AbstractSalt::class)) {
return;
}

final class AbstractSalt
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/AbstractTagBasedViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Fluid\Core\ViewHelper;

if (class_exists(AbstractTagBasedViewHelper::class)) {
return;
}

final class AbstractTagBasedViewHelper extends AbstractViewHelper
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
return;
}

class AbstractViewHelper
final class AbstractViewHelper
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/AdminPanelView.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Frontend\View;

if (class_exists(AdminPanelView::class)) {
return;
}

final class AdminPanelView
{

}
11 changes: 11 additions & 0 deletions stubs/Migrations/AdminPanelViewHookInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace TYPO3\CMS\Frontend\View;;

if (interface_exists(AdminPanelViewHookInterface::class)) {
return;
}

interface AdminPanelViewHookInterface
{
}
14 changes: 14 additions & 0 deletions stubs/Migrations/AjaxLogin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);



if (class_exists(AjaxLogin::class)) {
return;
}

final class AjaxLogin
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/AjaxLoginHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Backend;

if (class_exists(AjaxLoginHandler::class)) {
return;
}

final class AjaxLoginHandler
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/Argon2iSalt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Saltedpasswords\Salt;

if (class_exists(Argon2iSalt::class)) {
return;
}

final class Argon2iSalt
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/ArgumentDefinition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Fluid\Core\ViewHelper;

if (class_exists(ArgumentDefinition::class)) {
return;
}

final class ArgumentDefinition
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/ArrayBrowser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Lowlevel\Utility;

if (class_exists(ArrayBrowser::class)) {
return;
}

final class ArrayBrowser
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/AuthenticationService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Sv;

if (class_exists(AuthenticationService::class)) {
return;
}

final class AuthenticationService
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/AutoPublishTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Version\Task;

if (class_exists(AutoPublishTask::class)) {
return;
}

final class AutoPublishTask
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/BaseTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Extbase\Tests\Unit;

if (class_exists(BaseTestCase::class)) {
return;
}

final class BaseTestCase
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/BcryptSalt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Saltedpasswords\Salt;

if (class_exists(BcryptSalt::class)) {
return;
}

final class BcryptSalt
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/BlowfishSalt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Saltedpasswords\Salt;

if (class_exists(BlowfishSalt::class)) {
return;
}

final class BlowfishSalt
{

}
14 changes: 14 additions & 0 deletions stubs/Migrations/CannotInitializeCacheException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\Extbase\Object\Container\Exception;

if (class_exists(CannotInitializeCacheException::class)) {
return;
}

final class CannotInitializeCacheException
{

}
Loading

0 comments on commit c924f8c

Please sign in to comment.