Skip to content

Commit

Permalink
remove ProjectType open source to make rector easier to use (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 13, 2021
1 parent 5fd67ab commit 47c4373
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 189 deletions.
2 changes: 0 additions & 2 deletions config/parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\ProjectType;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
Expand All @@ -23,7 +22,6 @@
$parameters->set(Option::IMPORT_DOC_BLOCKS, true);

$parameters->set(Option::PHP_VERSION_FEATURES, null);
$parameters->set(Option::PROJECT_TYPE, ProjectType::PROPRIETARY);
$parameters->set(Option::NESTED_CHAIN_METHOD_CALL_LIMIT, 30);
$parameters->set(Option::SKIP, []);

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@ namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\FixtureAu

use Doctrine\ORM\Mapping as ORM;

/**
* News
*
* @ORM\Table(name="news")
* @ORM\Entity(repositoryClass="DoctrineFixtureDemo\Repository\NewsRepository")
*/
class News
{
/**
* @var integer
*
* @ORM\Column(name="id", type="bigint", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
Expand All @@ -42,19 +35,13 @@ namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\FixtureAu

use Doctrine\ORM\Mapping as ORM;

/**
* News
*/
#[\Doctrine\ORM\Mapping\Table(name: 'news')]
#[\Doctrine\ORM\Mapping\Entity(repositoryClass: 'DoctrineFixtureDemo\Repository\NewsRepository')]
class News
{
/**
* @var integer
*/
#[\Doctrine\ORM\Mapping\Column(name: 'id', type: 'bigint', nullable: false)]
#[\Doctrine\ORM\Mapping\Id]
#[\Doctrine\ORM\Mapping\GeneratedValue(strategy: 'IDENTITY')]
private $id;
/**
* @var string
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@ namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\FixtureAu

use Doctrine\ORM\Mapping as ORM;

/**
* News
*
* @ORM\Table(name="news")
* @ORM\Entity(repositoryClass="DoctrineFixtureDemo\Repository\NewsRepository")
*/
class News
{
/**
* @var integer
*
* @ORM\Column(name="id", type="bigint", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
Expand All @@ -40,26 +33,17 @@ class News

namespace Rector\Tests\Php80\Rector\Class_\AnnotationToAttributeRector\FixtureAutoImported;

use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping as ORM;

/**
* News
*/
#[Table(name: 'news')]
#[Entity(repositoryClass: 'DoctrineFixtureDemo\Repository\NewsRepository')]
class News
{
/**
* @var integer
*/
#[Column(name: 'id', type: 'bigint', nullable: false)]
#[Id]
#[GeneratedValue(strategy: 'IDENTITY')]
private $id;
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
Expand All @@ -19,19 +20,15 @@
new AnnotationToAttribute('Symfony\Component\Routing\Annotation\Route'),

// symfony/validation
new AnnotationToAttribute('Symfony\Component\Validator\Constraints\Email',),
new AnnotationToAttribute('Symfony\Component\Validator\Constraints\Range',),
new AnnotationToAttribute('Symfony\Component\Validator\Constraints\NotBlank',),
new AnnotationToAttribute('Symfony\Component\Validator\Constraints\Choice',),
new AnnotationToAttribute('Symfony\Component\Validator\Constraints\Choice'),

new AnnotationToAttribute('Doctrine\ORM\Mapping\Table'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\Entity'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\Id'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\GeneratedValue'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\Column'),
new AnnotationToAttribute('Doctrine\ORM\Mapping\ChangeTrackingPolicy'),
new AnnotationToAttribute('Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter'),
new AnnotationToAttribute('ApiPlatform\Core\Annotation\ApiResource'),
]),
]]);

$services->set(AddLiteralSeparatorToNumberRector::class);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Rector\Tests\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector\Fixture;

abstract class SkipAbstract
{
public $property;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,14 @@ private function shouldSkip(Node $node, string $numericValueAsString): bool
{
/** @var int $startToken */
$startToken = $node->getAttribute(AttributeKey::START_TOKEN_POSITION);
/** @var File $file */

$file = $node->getAttribute(AttributeKey::FILE);

// new node
if (! $file instanceof File) {
return true;
}

$oldTokens = $file->getOldTokens();

foreach ($oldTokens[$startToken] as $token) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,7 @@ private function shouldSkipClass(ClassLike $classLike): bool
return true;
}

if ($classLike->isAbstract()) {
return true;
}

return $this->isOpenSourceProjectType();
return $classLike->isAbstract();
}

private function shouldSkipProperty(Property $property): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ final class DoctrineColumnPropertyTypeInferer implements PropertyTypeInfererInte
/**
* @var Type[]
*
* @see \Doctrine\DBAL\Platforms\MySqlPlatform::initializeDoctrineTypeMappings()
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/basic-mapping.html#doctrine-mapping-types
*/
private array $doctrineTypeToScalarType = [];
Expand Down
5 changes: 0 additions & 5 deletions src/Configuration/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ final class Option
*/
public const CACHE_DEBUG = 'cache-debug';

/**
* @var string
*/
public const PROJECT_TYPE = 'project_type';

/**
* @var string
*/
Expand Down
8 changes: 0 additions & 8 deletions src/Rector/AbstractRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
use Rector\Core\Configuration\CurrentNodeProvider;
use Rector\Core\Configuration\Option;
use Rector\Core\Contract\Rector\PhpRectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Exclusion\ExclusionManager;
Expand All @@ -38,7 +37,6 @@
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\Validation\InfiniteLoopValidator;
use Rector\Core\ValueObject\Application\File;
use Rector\Core\ValueObject\ProjectType;
use Rector\NodeCollector\NodeCollector\NodeRepository;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeRemoval\NodeRemover;
Expand Down Expand Up @@ -397,12 +395,6 @@ protected function unwrapStmts(array $stmts, Node $node): void
}
}

protected function isOpenSourceProjectType(): bool
{
$projectType = $this->parameterProvider->provideStringParameter(Option::PROJECT_TYPE);
return $projectType === ProjectType::OPEN_SOURCE;
}

/**
* @param Arg[] $currentArgs
* @param Arg[] $appendingArgs
Expand Down
18 changes: 0 additions & 18 deletions src/ValueObject/ProjectType.php

This file was deleted.

0 comments on commit 47c4373

Please sign in to comment.