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
31 changes: 0 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,34 +170,3 @@ jobs:
name: "Make Docs"
run: "make docs"

phpbench:
name: "PHPBench Regression Test"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- '7.3'
steps:
-
name: "Checkout code"
uses: "actions/checkout@v2"

-
name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
php-version: "${{ matrix.php-version }}"
tools: composer:v2

-
name: "Composer install"
uses: "ramsey/composer-install@v1"
with:
composer-options: "--no-scripts"
-
name: "PHPBench Regression Test"
run: ".github/phpbench_regression_test.sh"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
__pycache__
/doc/_ext/__pycache__
.phpunit.result.cache
.php_cs.cache
8 changes: 8 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ $finder = PhpCsFixer\Finder::create()
->in('lib')
->in('tests')
->exclude([
'Workspace',
'Assets/Cache',
'Assets/Projects',
'Assets/Workspace',
])
;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'no_unused_imports' => true,
'array_syntax' => ['syntax' => 'short'],
'void_return' => true,
'ordered_class_elements' => true,
'single_quote' => true,
'heredoc_indentation' => true,
'global_namespace_import' => true,
])
->setFinder($finder)
;

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,15 @@ Community

- Follow [@phpactor](https://twitter.com/phpactor) for the latest news.
- Join the `#phpactor` channel on the Slack [Symfony Devs](https://symfony.com/slack-invite) channel.

Contributing
------------

This package is open source and welcomes contributions! Feel free to open a
pull request on this repository.

Support
-------

- Create an issue on the main [Phpactor](https://github.com/phpactor/phpactor) repository.
- Join the `#phpactor` channel on the Slack [Symfony Devs](https://symfony.com/slack-invite) channel.
27 changes: 14 additions & 13 deletions composer.lock

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

9 changes: 5 additions & 4 deletions lib/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PackageVersions\Versions;
use Phpactor\Extension\Logger\LoggingExtension;
use Phpactor\Extension\Console\ConsoleExtension;
use Exception;

class Application extends SymfonyApplication
{
Expand Down Expand Up @@ -51,7 +52,7 @@ public function doRun(InputInterface $input, OutputInterface $output)

try {
return parent::doRun($input, $output);
} catch (\Exception $e) {
} catch (Exception $e) {
if (
$input->hasArgument('command')
&& ($command = $input->getArgument('command'))
Expand All @@ -78,7 +79,7 @@ protected function getDefaultInputDefinition()
return $definition;
}

private function handleException(OutputInterface $output, string $dumper, \Exception $e)
private function handleException(OutputInterface $output, string $dumper, Exception $e)
{
$errors = [
'error' => $this->serializeException($e),
Expand All @@ -97,7 +98,7 @@ private function handleException(OutputInterface $output, string $dumper, \Excep
return 64;
}

private function serializeException(\Exception $e)
private function serializeException(Exception $e)
{
return [
'class' => get_class($e),
Expand All @@ -106,7 +107,7 @@ private function serializeException(\Exception $e)
];
}

private function initialize(InputInterface $input)
private function initialize(InputInterface $input): void
{
$this->container = Phpactor::boot($input, $this->vendorDir);

Expand Down
14 changes: 8 additions & 6 deletions lib/Extension/ClassMover/Application/ClassCopy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Phpactor\Filesystem\Domain\CopyReport;
use Phpactor\Extension\Core\Application\Helper\ClassFileNormalizer;
use Phpactor\Extension\ClassMover\Application\Logger\ClassCopyLogger;
use Exception;
use RuntimeException;

class ClassCopy
{
Expand Down Expand Up @@ -60,12 +62,12 @@ public function copyClass(ClassCopyLogger $logger, string $srcName, string $dest
);
}

public function copyFile(ClassCopyLogger $logger, string $srcPath, string $destPath)
public function copyFile(ClassCopyLogger $logger, string $srcPath, string $destPath): void
{
$srcPath = Phpactor::normalizePath($srcPath);

if (false === Glob::isDynamic($srcPath) && !file_exists($srcPath)) {
throw new \RuntimeException(sprintf(
throw new RuntimeException(sprintf(
'File "%s" does not exist',
$srcPath
));
Expand All @@ -81,13 +83,13 @@ public function copyFile(ClassCopyLogger $logger, string $srcPath, string $destP

try {
$this->doCopyFile($logger, $globPath, $globDest);
} catch (\Exception $e) {
throw new \RuntimeException(sprintf('Could not copy file "%s" to "%s"', $srcPath, $destPath), null, $e);
} catch (Exception $e) {
throw new RuntimeException(sprintf('Could not copy file "%s" to "%s"', $srcPath, $destPath), null, $e);
}
}
}

private function doCopyFile(ClassCopyLogger $logger, string $srcPath, string $destPath)
private function doCopyFile(ClassCopyLogger $logger, string $srcPath, string $destPath): void
{
$destPath = Phpactor::normalizePath($destPath);

Expand All @@ -99,7 +101,7 @@ private function doCopyFile(ClassCopyLogger $logger, string $srcPath, string $de
$logger->copying($srcPath, $destPath);
}

private function updateReferences(ClassCopyLogger $logger, CopyReport $copyReport)
private function updateReferences(ClassCopyLogger $logger, CopyReport $copyReport): void
{
foreach ($copyReport->srcFiles() as $srcPath) {
$destPath = $copyReport->destFiles()->current();
Expand Down
13 changes: 7 additions & 6 deletions lib/Extension/ClassMover/Application/ClassMover.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Phpactor\Filesystem\Domain\FilesystemRegistry;
use Phpactor\Extension\Core\Application\Helper\FilesystemHelper;
use Phpactor\Extension\ClassMover\Application\Logger\ClassMoverLogger;
use RuntimeException;

class ClassMover
{
Expand Down Expand Up @@ -88,21 +89,21 @@ public function moveClass(ClassMoverLogger $logger, string $filesystemName, stri
);
}

public function moveFile(ClassMoverLogger $logger, string $filesystemName, string $srcPath, string $destPath, bool $moveRelatedFiles)
public function moveFile(ClassMoverLogger $logger, string $filesystemName, string $srcPath, string $destPath, bool $moveRelatedFiles): void
{
$srcPath = Phpactor::normalizePath($srcPath);
foreach (FilesystemHelper::globSourceDestination($srcPath, $destPath) as $globSrc => $globDest) {
foreach ($this->expandRelatedPaths($globSrc, $globDest, $moveRelatedFiles) as $oldPath => $newPath) {
try {
$this->doMoveFile($logger, $filesystemName, $oldPath, $newPath);
} catch (\Exception $e) {
throw new \RuntimeException(sprintf('Could not move file "%s" to "%s"', $srcPath, $destPath), null, $e);
} catch (Exception $e) {
throw new RuntimeException(sprintf('Could not move file "%s" to "%s"', $srcPath, $destPath), null, $e);
}
}
}
}

private function doMoveFile(ClassMoverLogger $logger, string $filesystemName, string $srcPath, string $destPath)
private function doMoveFile(ClassMoverLogger $logger, string $filesystemName, string $srcPath, string $destPath): void
{
$filesystem = $this->filesystemRegistry->get($filesystemName);
$destPath = Phpactor::normalizePath($destPath);
Expand Down Expand Up @@ -136,7 +137,7 @@ private function directoryMap(Filesystem $filesystem, FilePath $srcPath, FilePat
return $files;
}

private function replaceThoseReferences(ClassMoverLogger $logger, Filesystem $filesystem, array $files)
private function replaceThoseReferences(ClassMoverLogger $logger, Filesystem $filesystem, array $files): void
{
foreach ($files as $paths) {
list($srcPath, $destPath) = $paths;
Expand All @@ -151,7 +152,7 @@ private function replaceThoseReferences(ClassMoverLogger $logger, Filesystem $fi
}
}

private function replaceReferences(ClassMoverLogger $logger, Filesystem $filesystem, string $srcName, string $destName)
private function replaceReferences(ClassMoverLogger $logger, Filesystem $filesystem, string $srcName, string $destName): void
{
foreach ($filesystem->fileList()->existing()->phpFiles() as $filePath) {
$references = $this->classMover->findReferences($filesystem->getContents($filePath), $srcName);
Expand Down
6 changes: 3 additions & 3 deletions lib/Extension/ClassMover/Application/Logger/NullLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

class NullLogger implements ClassCopyLogger, ClassMoverLogger
{
public function copying(FilePath $srcPath, FilePath $destPath)
public function copying(FilePath $srcPath, FilePath $destPath): void
{
}

public function replacing(FilePath $path, FoundReferences $references, FullyQualifiedName $replacementName)
public function replacing(FilePath $path, FoundReferences $references, FullyQualifiedName $replacementName): void
{
}

public function moving(FilePath $srcPath, FilePath $destPath)
public function moving(FilePath $srcPath, FilePath $destPath): void
{
}
}
8 changes: 4 additions & 4 deletions lib/Extension/ClassMover/ClassMoverExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function load(ContainerBuilder $container): void
$this->registerRpc($container);
}

private function registerRpc(ContainerBuilder $container)
private function registerRpc(ContainerBuilder $container): void
{
$container->register('class_mover.handler.class_references', function (Container $container) {
return new ReferencesHandler(
Expand All @@ -73,7 +73,7 @@ private function registerRpc(ContainerBuilder $container)
}, [ RpcExtension::TAG_RPC_HANDLER => [ 'name' => ClassMoveHandler::NAME ] ]);
}

private function registerClassMover(ContainerBuilder $container)
private function registerClassMover(ContainerBuilder $container): void
{
$container->register('class_mover.class_mover', function (Container $container) {
return new ClassMover(
Expand Down Expand Up @@ -101,7 +101,7 @@ private function registerClassMover(ContainerBuilder $container)
});
}

private function registerApplicationServices(ContainerBuilder $container)
private function registerApplicationServices(ContainerBuilder $container): void
{
$container->register('application.class_mover', function (Container $container) {
return new ClassMoverApp(
Expand Down Expand Up @@ -140,7 +140,7 @@ private function registerApplicationServices(ContainerBuilder $container)
});
}

private function registerConsoleCommands(ContainerBuilder $container)
private function registerConsoleCommands(ContainerBuilder $container): void
{
$container->register('command.class_move', function (Container $container) {
return new ClassMoveCommand(
Expand Down
5 changes: 3 additions & 2 deletions lib/Extension/ClassMover/Command/ClassCopyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Phpactor\Extension\ClassMover\Command\Logger\SymfonyConsoleCopyLogger;
use Symfony\Component\Console\Input\InputOption;
use Phpactor\Extension\Core\Console\Prompt\Prompt;
use InvalidArgumentException;

class ClassCopyCommand extends Command
{
Expand All @@ -36,7 +37,7 @@ public function __construct(
$this->prompt = $prompt;
}

public function configure()
public function configure(): void
{
$this->setDescription('Copy class (path or FQN)');
$this->addArgument('src', InputArgument::REQUIRED, 'Source path or FQN');
Expand Down Expand Up @@ -70,7 +71,7 @@ public function execute(InputInterface $input, OutputInterface $output)
return 0;
}

throw new \InvalidArgumentException(sprintf(
throw new InvalidArgumentException(sprintf(
'Invalid type "%s", must be one of: "%s"',
$type,
implode('", "', [ self::TYPE_AUTO, self::TYPE_FILE, self::TYPE_CLASS ])
Expand Down
Loading