Skip to content

Commit

Permalink
Update to new major versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Shevchuk committed Jul 1, 2021
1 parent 58e13c6 commit fba68d9
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 32 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: php
php:
- 7.1
- 7.2
- 7.3
- 7.4
- master
matrix:
allow_failures:
Expand All @@ -13,7 +12,7 @@ install:
- composer install
script:
# Code style
- php vendor/bin/phpcs ./src --standard=PSR1,PSR2 --encoding=utf-8
- php vendor/bin/phpcs ./src --standard=PSR12 --encoding=utf-8
# PHPUnit tests
- php vendor/bin/phpunit --configuration ./phpunit.xml.dist
notifications:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Composer Installer for Bluz
## Achievements

[![PHP >= 7.1+](https://img.shields.io/packagist/php-v/bluzphp/composer-plugin.svg?style=flat)](https://php.net/)
[![PHP >= 7.3+](https://img.shields.io/packagist/php-v/bluzphp/composer-plugin.svg?style=flat)](https://php.net/)

[![Latest Stable Version](https://img.shields.io/packagist/v/bluzphp/composer-plugin.svg?label=version&style=flat)](https://packagist.org/packages/bluzphp/composer-plugin)

Expand All @@ -19,7 +19,7 @@

## Requirements

* PHP: 7.1 (or later)
* PHP: 7.3 (or later)

## Available modules

Expand Down Expand Up @@ -59,7 +59,7 @@ php ./vendor/bin/bluzman module:remove options

## License

The project is developed by [NIX Solutions][1] PHP team and distributed under [MIT LICENSE][2]
The project is developed by [NIX][1] PHP team and distributed under [MIT LICENSE][2]

[1]: http://nixsolutions.com
[2]: https://raw.github.com/bluzphp/composer-plugin/master/LICENSE.md
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"homepage": "https://github.com/bluzphp/composer-plugin",
"license": "MIT",
"require": {
"php": ">=7.1",
"composer-plugin-api": "~1.0",
"symfony/filesystem": "~3.0",
"symfony/finder": "~3.0"
"php": ">=7.3",
"composer-plugin-api": "^2.0",
"symfony/filesystem": "~5.3",
"symfony/finder": "~5.3"
},
"require-dev": {
"composer/composer": "~1.8",
"composer/installers": "~1.6",
"squizlabs/php_codesniffer": "~3.4",
"phpunit/phpunit": "~7.0"
"composer/composer": "^2.0",
"composer/installers": "~1.11",
"phpunit/phpunit": "~9.5",
"squizlabs/php_codesniffer": "~3.6"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion src/Installers/Installer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Bluz composer installer
*
Expand Down Expand Up @@ -40,7 +41,7 @@ public function getInstallPath(PackageInterface $package): string
*
* {@inheritDoc}
*/
public function supports($packageType)
public function supports($packageType): bool
{
return $packageType === 'bluz-module';
}
Expand Down
43 changes: 28 additions & 15 deletions src/Installers/Plugin.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Bluz composer plugin
*
Expand Down Expand Up @@ -155,7 +156,7 @@ public function copyProjectExtraFiles(Event $event): void
public function copyModuleFiles(PackageEvent $event): void
{
$package = $this->extractPackage($event);
$this->packagePath = $this->vendorPath .DS. $package->getName();
$this->packagePath = $this->vendorPath . DS . $package->getName();
if ($package->getType() === 'bluz-module' && file_exists($this->packagePath)) {
if ($package->getExtra() && isset($package->getExtra()['copy-files'])) {
$this->copyExtras($package->getExtra()['copy-files']);
Expand All @@ -173,7 +174,7 @@ public function copyModuleFiles(PackageEvent $event): void
public function removeModuleFiles(PackageEvent $event): void
{
$package = $this->extractPackage($event);
$this->packagePath = $this->vendorPath .DS. $package->getName();
$this->packagePath = $this->vendorPath . DS . $package->getName();
if ($package->getType() === 'bluz-module' && file_exists($this->packagePath)) {
if ($package->getExtra() && isset($package->getExtra()['copy-files'])) {
$this->removeExtras($package->getExtra()['copy-files']);
Expand Down Expand Up @@ -222,12 +223,12 @@ protected function copyModule(): void
/**
* copyExtras
*
* @param array $files
* @param array $files
*
* @return void
* @throws \InvalidArgumentException
*/
protected function copyExtras($files): void
protected function copyExtras(array $files): void
{
foreach ($files as $source => $target) {
$this->copy(
Expand All @@ -246,7 +247,7 @@ protected function copyExtras($files): void
* @return void
* @throws \InvalidArgumentException
*/
protected function copy($source, $target): void
protected function copy(string $source, string $target): void
{
// skip, if not exists
if (!file_exists($source)) {
Expand Down Expand Up @@ -288,7 +289,7 @@ protected function copy($source, $target): void
}

if (is_dir($source)) {
$finder = new Finder;
$finder = new Finder();
$finder->files()->in($source);

foreach ($finder as $file) {
Expand Down Expand Up @@ -341,11 +342,11 @@ protected function removeModule(): void
/**
* removeExtras
*
* @param array $files
* @param array $files
*
* @return void
*/
protected function removeExtras($files): void
protected function removeExtras(array $files): void
{
foreach ($files as $source => $target) {
$this->installer->getIo()->write(
Expand All @@ -367,13 +368,15 @@ protected function remove($directory): void
if (!is_dir($sourcePath)) {
return;
}
foreach ($iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$sourcePath,
\RecursiveDirectoryIterator::SKIP_DOTS
),
\RecursiveIteratorIterator::CHILD_FIRST
) as $item) {
foreach (
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$sourcePath,
\RecursiveDirectoryIterator::SKIP_DOTS
),
\RecursiveIteratorIterator::CHILD_FIRST
) as $item
) {
// path to copied file
$current = PATH_ROOT . DS . $directory . DS . $iterator->getSubPathName();

Expand Down Expand Up @@ -422,4 +425,14 @@ protected function remove($directory): void
}
}
}

public function deactivate(Composer $composer, IOInterface $io)
{
// TODO: Implement deactivate() method.
}

public function uninstall(Composer $composer, IOInterface $io)
{
// TODO: Implement uninstall() method.
}
}
3 changes: 2 additions & 1 deletion tests/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

// This is global bootstrap for autoloading
// Environment
define('DEBUG', true);
Expand All @@ -12,4 +13,4 @@

// init autoloader
$loader = require PATH_ROOT . '/vendor/autoload.php';
$loader->addPsr4('Bluz\\Tests\\', __DIR__ .'/src');
$loader->addPsr4('Bluz\\Tests\\', __DIR__ . '/src');
1 change: 1 addition & 0 deletions tests/src/Installers/InstallerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
Expand Down
1 change: 1 addition & 0 deletions tests/src/Installers/PluginTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
Expand Down
3 changes: 2 additions & 1 deletion tests/src/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/framework
Expand Down Expand Up @@ -41,7 +42,7 @@ class TestCase extends \PHPUnit\Framework\TestCase
*/
private $installer;

public function setUp()
public function setUp(): void
{
$this->io = $this->createMock('Composer\IO\NullIO');
$this->config = new Config();
Expand Down

0 comments on commit fba68d9

Please sign in to comment.