Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #61

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ composer.phar

# CS
.php_cs.cache

# PHPUnit
.phpunit.result.cache
64 changes: 43 additions & 21 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,53 @@ For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);

$finder = Symfony\CS\Finder\DefaultFinder::create()
$finder = \PhpCsFixer\Finder::create()
->in(array(__DIR__))
;

return Symfony\CS\Config\Config::create()
return \PhpCsFixer\Config::create()
// Set to Symfony Level (PSR1 PSR2)
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
->fixers(array(
'header_comment', // Add the provided header comment ($header)
'newline_after_open_tag', // Force new line after <?php
'ordered_use', // Order "use" alphabetically
'short_array_syntax', // Replace array() by []
'-empty_return', // Keep return null;
'phpdoc_order', // Clean up the /** php doc */
'concat_with_spaces', // Force space around concatenation operator
'-align_double_arrow', // Force no double arrow align
'unalign_double_arrow', // Keep double arrow simple
'-align_equals', // Force no aligned equals
'unalign_equals', // Keep equals simple
'strict', // Strict comparison
'strict_param', // Functions should use $strict param
'-heredoc_to_nowdoc', // Do not convert heredoc to nowdoc
))
->setRules([
'@Symfony' => true,

// Add the provided header comment ($header)
'header_comment' => [
'header' => $header
],

// Force new line after <?php
'blank_line_after_opening_tag' => true,

// Order "use" alphabetically
'ordered_imports' => true,

// Replace array() by []
'array_syntax' => [
'syntax' => 'short'
],

// Keep return null;
'simplified_null_return' => false,

// Clean up the /** php doc */
'phpdoc_order' => true,

// Force space around concatenation operator
'concat_space' => [
'spacing' => 'one'
],

// Strict comparison
'strict_comparison' => true,

// Functions should use $strict param
'strict_param' => true,

// Do not convert heredoc to nowdoc
'heredoc_to_nowdoc' => false
])
->setUsingCache(true)
->finder($finder)
->setFinder($finder)
->setRiskyAllowed(true);
;
13 changes: 4 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ cache:

matrix:
include:
- php: 5.4
env: check_cs=true
- php: 5.5
- php: 5.6
env: deps=low coverage=true
- php: 5.6
env: deps=high coverage=true
- php: 7.0
- php: 7.1
env: deps=low coverage=true
- php: 7.2
env: check_cs=true
- php: 7.3
env: deps=high coverage=true

env:
global:
Expand All @@ -39,7 +34,7 @@ script:
- if [ "$coverage" = "true" ]; then vendor/bin/phpunit --coverage-clover=coverage; fi;
- if [ "$coverage" = "true" ]; then xdebug-disable; fi;
- if [ "$coverage" != "true" ]; then vendor/bin/phpunit; fi;
- if [ "$check_cs" = "true" ]; then vendor/bin/php-cs-fixer fix --config-file=.php_cs --dry-run --diff; fi;
- if [ "$check_cs" = "true" ]; then vendor/bin/php-cs-fixer fix --config=.php_cs --dry-run --diff; fi;

after_script:
- if [ "$coverage" = "true" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi;
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Use [PHP CS fixer](http://cs.sensiolabs.org/) to make your code compliant with
composer-changelogs's coding standards:

```shell
vendor/bin/php-cs-fixer fix --config-file=.php_cs --diff
vendor/bin/php-cs-fixer fix --config=.php_cs --diff
```
or the alias:
```shell
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
}
],
"require": {
"php": ">=5.4.0",
"php": ">=7.1",
"composer-plugin-api": "^1.0 || ^1.1"
},
"require-dev": {
"composer/composer": "~1.0.0-alpha10@dev",
"composer/semver": "1.2.0",
"friendsofphp/php-cs-fixer": "~1.5",
"phpunit/phpunit": "^4.8"
"composer/composer": "^1.9",
"composer/semver": "^1.5",
"friendsofphp/php-cs-fixer": "^2.15",
"phpunit/phpunit": "^7.5"
},
"config": {
"sort-packages": true
Expand All @@ -45,8 +45,8 @@
}
},
"scripts": {
"cs": "vendor/bin/php-cs-fixer fix --config-file=.php_cs --diff --dry-run --verbose",
"fix-cs": "vendor/bin/php-cs-fixer fix --config-file=.php_cs --diff --verbose",
"cs": "vendor/bin/php-cs-fixer fix --config=.php_cs --diff --dry-run --verbose",
"fix-cs": "vendor/bin/php-cs-fixer fix --config=.php_cs --diff --verbose",
"test": "vendor/bin/phpunit"
}
}
2 changes: 1 addition & 1 deletion src/ChangelogsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private function autoloadNeededClasses()
{
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__, \FilesystemIterator::SKIP_DOTS)) as $file) {
if ('.php' === substr($file, 0, -4)) {
class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__), -4)));
class_exists(__NAMESPACE__ . str_replace('/', '\\', substr($file, \strlen(__DIR__), -4)));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Config/ConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function build(array $extra, $baseDir)
}

if (array_key_exists('commit-bin-file', $extra)) {
if ($commitAuto === 'never') {
if ('never' === $commitAuto) {
$this->warnings[] = '"commit-bin-file" is specified but "commit-auto" option is set to "never". Ignoring.';
} else {
$file = realpath(
Expand All @@ -70,7 +70,7 @@ public function build(array $extra, $baseDir)
}
}
} else {
if ($commitAuto !== 'never') {
if ('never' !== $commitAuto) {
$this->warnings[] = sprintf(
'"commit-auto" is set to "%s" but "commit-bin-file" was not specified.',
$commitAuto
Expand All @@ -79,7 +79,7 @@ public function build(array $extra, $baseDir)
}

if (array_key_exists('commit-message', $extra)) {
if (strlen(trim($extra['commit-message'])) === 0) {
if (0 === strlen(trim($extra['commit-message']))) {
$this->warnings[] = '"commit-message" is specified but empty. Ignoring and using default commit message.';
} else {
$commitMessage = $extra['commit-message'];
Expand Down
8 changes: 8 additions & 0 deletions src/Outputter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public function addOperation(OperationInterface $operation)
$this->operations[] = $operation;
}

/**
* @return OperationInterface[]
*/
public function getOperations()
{
return $this->operations;
}

/**
* @return bool
*/
Expand Down
6 changes: 3 additions & 3 deletions src/UrlGenerator/GitBasedUrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract protected function getDomain();
*/
public function supports($sourceUrl)
{
return strpos($sourceUrl, $this->getDomain()) !== false;
return false !== strpos($sourceUrl, $this->getDomain());
}

/**
Expand All @@ -56,7 +56,7 @@ protected function generateBaseUrl($sourceUrl)
'%s://%s%s',
$sourceUrl['scheme'],
$sourceUrl['host'],
$pos === false ? $sourceUrl['path'] : substr($sourceUrl['path'], 0, strrpos($sourceUrl['path'], '.git'))
false === $pos ? $sourceUrl['path'] : substr($sourceUrl['path'], 0, strrpos($sourceUrl['path'], '.git'))
);
}

Expand Down Expand Up @@ -115,7 +115,7 @@ protected function extractRepositoryInformation($sourceUrl)
*/
private function isSshUrl($url)
{
return strpos($url, 'git@') !== false;
return false !== strpos($url, 'git@');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/UrlGenerator/WordPressUrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class WordPressUrlGenerator implements UrlGenerator
*/
public function supports($sourceUrl)
{
return strpos($sourceUrl, self::DOMAIN) !== false;
return false !== strpos($sourceUrl, self::DOMAIN);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Util/FileSystemHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function isAbsolute($file)
{
return strspn($file, '/\\', 0, 1)
|| (strlen($file) > 3 && ctype_alpha($file[0])
&& substr($file, 1, 1) === ':'
&& ':' === substr($file, 1, 1)
&& strspn($file, '/\\', 2, 1)
)
|| null !== parse_url($file, PHP_URL_SCHEME)
Expand Down
4 changes: 2 additions & 2 deletions src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public function getFullPretty()
*/
public function isDev()
{
return substr($this->name, 0, 4) === 'dev-' || substr($this->name, -4) === '-dev';
return 'dev-' === substr($this->name, 0, 4) || '-dev' === substr($this->name, -4);
}

/**
* Return the version string for CLI Output
* In cas of dev version is adds the vcs hash
* In case of dev version is adds the vcs hash.
*
* @return string
*/
Expand Down
9 changes: 4 additions & 5 deletions tests/ChangelogsPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
use Composer\Plugin\PluginManager;
use Composer\Repository\CompositeRepository;
use Composer\Script\ScriptEvents;
use PHPUnit\Framework\TestCase;
use Pyrech\ComposerChangelogs\ChangelogsPlugin;

class ChangelogsPluginTest extends \PHPUnit_Framework_TestCase
class ChangelogsPluginTest extends TestCase
{
/** @var BufferIO */
private $io;
Expand All @@ -46,7 +47,7 @@ class ChangelogsPluginTest extends \PHPUnit_Framework_TestCase
/**
* {@inheritdoc}
*/
protected function setUp()
protected function setUp(): void
{
$this->tempDir = __DIR__ . '/temp';
$this->config = new Config(false, realpath(__DIR__ . '/fixtures/local'));
Expand All @@ -71,7 +72,7 @@ protected function setUp()
/**
* {@inheritdoc}
*/
protected function tearDown()
protected function tearDown(): void
{
self::cleanTempDir();
}
Expand All @@ -98,8 +99,6 @@ public function test_it_is_registered_and_activated()
$this->addComposerPlugin($plugin);

$this->assertSame([$plugin], $this->composer->getPluginManager()->getPlugins());
$this->assertAttributeInstanceOf('Composer\IO\IOInterface', 'io', $plugin);
$this->assertAttributeInstanceOf('Pyrech\ComposerChangelogs\Outputter', 'outputter', $plugin);
Copy link
Owner

@pyrech pyrech Oct 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did these 2 asserts disappeared?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah we may be able to add them back in again but essentially in PHPUnit 8.x assertAttributeInstanceOf is deprecated. Apparently the author felt that allowing tests that check the attribute value is bad practice and so removed them sebastianbergmann/phpunit#3339

I figured here theres little to be gained by adding getters for io & outputter but can do that if you like?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I added those asserts to ensure the plugin is always activated correctly (as some of its dependencies depends from Composer) : https://github.com/pyrech/composer-changelogs/blob/master/src/ChangelogsPlugin.php#L59

But anyway, we can probably drop them 馃槈

}

public function test_it_receives_event()
Expand Down