Skip to content

Commit

Permalink
merge branch 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Jan 28, 2022
2 parents f98603b + 064cadf commit 69ff585
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 5 deletions.
26 changes: 24 additions & 2 deletions CHANGELOG-6.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@ using the [Keep a CHANGELOG](http://keepachangelog.com) principles.

## [Unreleased]

## [6.1.2] - 2022-01-28

### Changed

- fix `bartlett/php-compatinfo-db` constraint to fix conflict with future versions 3.19 or greater

## [6.1.1] - 2022-01-18

### Changed

- [GH-319](https://github.com/llaville/php-compatinfo/issues/319) Add Platform to composer.json (thanks to @remicollet)
- fix `php-compatinfo-db` constraint to avoid conflict with new version feature introduced in 3.17.0

### Removed

- [drop support of Composer v1](https://github.com/llaville/php-compatinfo/issues/320)

## [6.0.4] - 2022-01-18

### Fixed

- [GH-339](https://github.com/llaville/php-compatinfo/issues/339) Stop on empty/broken files during analysis (thanks to @yuri-ccp for reporting)

## [6.1.0] - 2022-01-06

### Added
Expand Down Expand Up @@ -73,8 +92,11 @@ using the [Keep a CHANGELOG](http://keepachangelog.com) principles.
- drop support for PHP 7.3 has ended 6th December 2021.
- file `config/container.php` replaced by `src/Infrastructure/Framework/Symfony/DependencyInjection/ContainerFactory.php`

[unreleased]: https://github.com/llaville/php-compat-info/compare/6.1.0...HEAD
[6.1.0]: https://github.com/llaville/php-compat-info/compare/6.0.3...6.1.0
[unreleased]: https://github.com/llaville/php-compat-info/compare/6.1.2...HEAD
[6.1.2]: https://github.com/llaville/php-compat-info/compare/6.1.1...6.1.2
[6.1.1]: https://github.com/llaville/php-compat-info/compare/6.1.0...6.1.1
[6.1.0]: https://github.com/llaville/php-compat-info/compare/6.0.4...6.1.0
[6.0.4]: https://github.com/llaville/php-compat-info/compare/6.0.3...6.0.4
[6.0.3]: https://github.com/llaville/php-compat-info/compare/6.0.2...6.0.3
[6.0.2]: https://github.com/llaville/php-compat-info/compare/6.0.1...6.0.2
[6.0.1]: https://github.com/llaville/php-compat-info/compare/6.0.0...6.0.1
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"ext-libxml": "*",
"ext-pcre": "*",
"ext-spl": "*",
"bartlett/php-compatinfo-db": "^3.17",
"bartlett/php-compatinfo-db": ">=3.17 <3.19",
"bartlett/sarif-php-sdk": "^1.0",
"composer-runtime-api": "^2.0",
"doctrine/collections": "^1.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function beforeTraverse(array $nodes)
/** @var Node\Stmt[] $newNodes */
$newNodes = $nodes;
// global namespace is not explicitly specified in source code ... we will add it
if ($nodes[0] instanceof Node\Stmt\Declare_) {
if (count($nodes) && $nodes[0] instanceof Node\Stmt\Declare_) {
$declare = array_shift($newNodes);
$newNodes = [$declare, new Node\Stmt\Namespace_(null, $newNodes)];
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Presentation/Console/Command/AnalyserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$compatibilityQuery = new GetCompatibilityQuery(
$input->getArgument('source'),
$input->getOption('exclude'),
$input->hasOption('stop-on-failure'),
$input->getOption('stop-on-failure'),
$app->getInstalledVersion()
);

Expand Down
137 changes: 137 additions & 0 deletions tests/ErrorHandlerIssueTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php
/**
* This file is part of the PHP_CompatInfo package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Bartlett\CompatInfo\Tests;

use Exception;
use function sprintf;

/**
* @author Laurent Laville
* @since Release 6.0.4
* @link https://github.com/llaville/php-compatinfo/issues/339
*/
final class ErrorHandlerIssueTest extends TestCase
{
/**
* {@inheritDoc}
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

self::$fixtures .= 'noContents' . DIRECTORY_SEPARATOR;
}

/**
* Regression test for issue #339
*
* @link https://github.com/llaville/php-compatinfo/issues/339
* Stop on empty/broken files during analysis
* @group regression
* @return void
* @throws Exception
*/
public function testEmptyDir()
{
$dataSource = 'emptyDir' . DIRECTORY_SEPARATOR;
$metrics = $this->executeAnalysis($dataSource);

$this->assertCount(
0,
$metrics['files'],
sprintf('Expected to analyse empty directory, but found %d file(s)', $metrics['files'])
);
}

/**
* Regression test for issue #339
*
* @link https://github.com/llaville/php-compatinfo/issues/339
* Stop on empty/broken files during analysis
* @group regression
* @return void
* @throws Exception
*/
public function testEmptyFile()
{
$dataSource = 'emptyFile.php';
$metrics = $this->executeAnalysis($dataSource);

$this->assertCount(
1,
$metrics['files'],
sprintf('Expected to analyse only one empty PHP file, but found %d file(s)', $metrics['files'])
);

$this->assertCount(
1,
$metrics['errors'],
sprintf('Expected to found only one error, but found %d error(s)', $metrics['errors'])
);

$this->assertStringStartsWith('File has no contents on line 1', $metrics['errors'][0]);
}

/**
* Regression test for issue #339
*
* @link https://github.com/llaville/php-compatinfo/issues/339
* Stop on empty/broken files during analysis
* @group regression
* @return void
* @throws Exception
*/
public function testWithoutOpenTag()
{
$dataSource = 'withoutOpenTag.php';
$metrics = $this->executeAnalysis($dataSource);

$this->assertCount(
1,
$metrics['files'],
sprintf('Expected to analyse only one empty PHP file, but found %d file(s)', $metrics['files'])
);

$this->assertCount(
1,
$metrics['errors'],
sprintf('Expected to found only one error, but found %d error(s)', $metrics['errors'])
);

$this->assertStringStartsWith('File has no contents on line 1', $metrics['errors'][0]);
}

/**
* Regression test for issue #339
*
* @link https://github.com/llaville/php-compatinfo/issues/339
* Stop on empty/broken files during analysis
* @group regression
* @return void
* @throws Exception
*/
public function testParseError()
{
$dataSource = 'parseError.php';
$metrics = $this->executeAnalysis($dataSource);

$this->assertCount(
1,
$metrics['files'],
sprintf('Expected to analyse only one file, but found %d file(s)', $metrics['files'])
);

$this->assertCount(
1,
$metrics['errors'],
sprintf('Expected to found only one error, but found %d error(s)', $metrics['errors'])
);

$this->assertStringStartsWith('Syntax error, unexpected EOF on line 3', $metrics['errors'][0]);
}
}
Empty file.
1 change: 1 addition & 0 deletions tests/fixtures/noContents/emptyFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
2 changes: 2 additions & 0 deletions tests/fixtures/noContents/parseError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
$foo = function () {}
Empty file.

0 comments on commit 69ff585

Please sign in to comment.