Skip to content

Commit

Permalink
Merge pull request #2 from pureware/php74
Browse files Browse the repository at this point in the history
add rectorphp
  • Loading branch information
pureware authored Nov 19, 2022
2 parents 569f46d + e75c6fe commit ba63d7a
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 53 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"symfony/var-dumper": "^6.0|^5.0"
"symfony/var-dumper": "^6.0|^5.0",
"rector/rector": "^0.14.8"
},
"minimum-stability": "dev",
"prefer-stable" : true,
Expand Down
118 changes: 117 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php declare(strict_types=1);

use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\SetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
// here we can define, what sets of rules will be applied
// tip: use "SetList" class to autocomplete sets
$rectorConfig->sets([
SetList::DEAD_CODE,
SetList::PHP_74,
\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_74

]);
$rectorConfig->paths(
[
__DIR__ . '/src',
__DIR__ . '/tests'
]
);
$rectorConfig->skip(
[
__DIR__ . '/src/Resources'
]
);
};
6 changes: 1 addition & 5 deletions src/Generator/DirectoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,10 @@ public function generate(Directory $directory)
}

protected function getFiles(Directory $directory): FileCollection {
$files = new FileCollection();

if ($this->force) {
$files = $directory->getFiles();
} else {
$files = $directory->getFiles()->filter(function (File $file) {
return !$this->filesystem->exists($this->buildFilePath($file));
});
$files = $directory->getFiles()->filter(fn(File $file) => !$this->filesystem->exists($this->buildFilePath($file)));
}


Expand Down
2 changes: 0 additions & 2 deletions src/Parser/TwigParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public function parseFile(File $file): File
}

/**
* @param string $string
* @return string
* @throws LoaderError
* @throws SyntaxError
*/
Expand Down
17 changes: 0 additions & 17 deletions src/TreeBuilder/Directory/DirectoryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,26 @@ public function getFiles(): ?FileCollection

}

/**
* @param FileCollection $files
*/
public function setFiles(FileCollection $files): void
{
$this->files = $files;
}

/**
* @param FileInterface $file
* @return void
*/
public function addFile(FileInterface $file): void
{
$this->files->add($file);
}

/**
* @return DirectoryCollection|null
*/
public function getDirectories(): ?DirectoryCollection
{
return $this->items;
}

/**
* @param DirectoryCollection|null $directories
*/
public function setDirectories(?DirectoryCollection $directories): void
{
$this->items = $directories;
}

/**
* @param DirectoryInterface $directory
* @return void
*/
public function addDirectories(DirectoryInterface $directory): void
{
$this->directories->add($directory);
Expand Down
27 changes: 0 additions & 27 deletions src/TreeBuilder/File/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,73 +21,46 @@ public function __construct(string $name, $fileNamespace)
$this->fileNamespace = $fileNamespace;
}

/**
* @return string
*/
public function getContent(): string
{
return $this->content;
}

/**
* @param string $content
*/
public function setContent(string $content): void
{
$this->content = $content;
}

/**
* @return string
*/
public function getParsedFileContent(): string
{
return $this->parsedFileContent;
}

/**
* @param string $parsedFileContent
*/
public function setParsedFileContent(string $parsedFileContent): void
{
$this->parsedFileContent = $parsedFileContent;
}

/**
* @return string
*/
public function getParsedFileName(): string
{
return $this->parsedFile ?? $this->getName();
}

/**
* @param string $parsedFileName
*/
public function setParsedFileName(string $parsedFileName): void
{
$this->parsedFile = $parsedFileName;
}

/**
* @return string
*/
public function getName(): string
{
return $this->name;
}

/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $name;
}

/**
* @return string
*/
public function getFileNamespace(): string
{
return $this->fileNamespace;
Expand Down

0 comments on commit ba63d7a

Please sign in to comment.