Skip to content
Snippets Groups Projects
Commit 8de4e502 authored by David Prévot's avatar David Prévot
Browse files

New upstream version 6.0.2

parents fb2f8a43 b4ccd857
No related branches found
No related tags found
No related merge requests found
Showing with 150 additions and 91 deletions
......@@ -31,8 +31,8 @@ jobs:
- name: Run PHP-CS-Fixer
run: ./tools/php-cs-fixer fix --dry-run --show-progress=dots --using-cache=no --verbose
type-checker:
name: Type Checker
static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
......@@ -49,8 +49,8 @@ jobs:
- name: Install dependencies with Composer
run: ./tools/composer update --no-interaction --no-ansi --no-progress
- name: Run Psalm
run: ./tools/psalm --config=.psalm/config.xml --no-progress --shepherd --show-info=false --stats
- name: Run PHPStan
run: ./tools/phpstan analyse --no-progress --error-format=github
tests:
name: Tests
......
# https://docs.github.com/en/actions
on:
push:
tags:
- "**"
name: Release
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
extensions: none
tools: none
- name: Determine tag
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Parse ChangeLog
run: build/scripts/extract-release-notes.php ${{ env.RELEASE_TAG }} > release-notes.md
- name: Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.RELEASE_TAG }}
name: sebastian/diff ${{ env.RELEASE_TAG }}
bodyFile: release-notes.md
......@@ -2,6 +2,5 @@
/.php-cs-fixer.php
/.php-cs-fixer.cache
/.phpunit.cache
/.psalm/cache
/composer.lock
/vendor
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.0" installed="3.41.1" location="./tools/php-cs-fixer" copy="true"/>
<phar name="psalm" version="^5.0" installed="5.18.0" location="./tools/psalm" copy="true"/>
<phar name="composer" version="^2.0.3" installed="2.6.6" location="./tools/composer" copy="true"/>
<phar name="php-cs-fixer" version="^3.59" installed="3.59.3" location="./tools/php-cs-fixer" copy="true"/>
<phar name="composer" version="^2.7" installed="2.7.7" location="./tools/composer" copy="true"/>
<phar name="phpstan" version="^1.11" installed="1.11.5" location="./tools/phpstan" copy="true"/>
</phive>
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.18.0@b113f3ed0259fd6e212d87c3df80eec95a6abf19">
<file src="src/Chunk.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->lines]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<Line>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Differ.php">
<MissingParamType>
<code>$line</code>
</MissingParamType>
</file>
<file src="src/Exception/ConfigurationException.php">
<MissingParamType>
<code>$value</code>
</MissingParamType>
</file>
<file src="src/Output/StrictUnifiedDiffOutputBuilder.php">
<InvalidPropertyAssignmentValue>
<code><![CDATA[$options['contextLines']]]></code>
</InvalidPropertyAssignmentValue>
<MissingParamType>
<code>$output</code>
<code>$output</code>
</MissingParamType>
<PropertyNotSetInConstructor>
<code>$changed</code>
</PropertyNotSetInConstructor>
</file>
<file src="src/Output/UnifiedDiffOutputBuilder.php">
<MissingParamType>
<code>$output</code>
<code>$output</code>
</MissingParamType>
</file>
</files>
<?xml version="1.0"?>
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
resolveFromConfigFile="false"
cacheDirectory=".psalm/cache"
errorBaseline=".psalm/baseline.xml"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
......@@ -2,6 +2,12 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [6.0.2] - 2024-07-03
### Changed
* This project now uses PHPStan instead of Psalm for static analysis
## [6.0.1] - 2024-03-02
### Changed
......@@ -17,6 +23,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* `SebastianBergmann\Diff\Line::getContent()` and `SebastianBergmann\Diff\Diff::getType()`
* Removed support for PHP 8.1
## [5.1.1] - 2024-03-02
### Changed
* Do not use implicitly nullable parameters
## [5.1.0] - 2023-12-22
### Added
......@@ -139,8 +151,10 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* This component is no longer supported on PHP 5.6
[6.0.2]: https://github.com/sebastianbergmann/diff/compare/6.0.1...6.0.2
[6.0.1]: https://github.com/sebastianbergmann/diff/compare/6.0.0...6.0.1
[6.0.0]: https://github.com/sebastianbergmann/diff/compare/5.1...6.0.0
[5.1.1]: https://github.com/sebastianbergmann/diff/compare/5.1.0...5.1.1
[5.1.0]: https://github.com/sebastianbergmann/diff/compare/5.0.3...5.1.0
[5.0.3]: https://github.com/sebastianbergmann/diff/compare/5.0.2...5.0.3
[5.0.2]: https://github.com/sebastianbergmann/diff/compare/5.0.1...5.0.2
......
[![Latest Stable Version](https://poser.pugx.org/sebastian/diff/v/stable.png)](https://packagist.org/packages/sebastian/diff)
[![CI Status](https://github.com/sebastianbergmann/diff/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/diff/actions)
[![Type Coverage](https://shepherd.dev/github/sebastianbergmann/diff/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/diff)
[![codecov](https://codecov.io/gh/sebastianbergmann/diff/branch/main/graph/badge.svg)](https://codecov.io/gh/sebastianbergmann/diff)
# sebastian/diff
......
#!/usr/bin/env php
<?php declare(strict_types=1);
if ($argc !== 2) {
print $argv[0] . ' <tag>' . PHP_EOL;
exit(1);
}
$version = $argv[1];
$file = __DIR__ . '/../../ChangeLog.md';
if (!is_file($file) || !is_readable($file)) {
print $file . ' cannot be read' . PHP_EOL;
exit(1);
}
$buffer = '';
$append = false;
foreach (file($file) as $line) {
if (str_starts_with($line, '## [' . $version . ']')) {
$append = true;
continue;
}
if ($append && (str_starts_with($line, '## ') || str_starts_with($line, '['))) {
break;
}
if ($append) {
$buffer .= $line;
}
}
$buffer = trim($buffer);
if ($buffer === '') {
print 'Unable to extract release notes' . PHP_EOL;
exit(1);
}
print $buffer . PHP_EOL;
parameters:
level: 2
paths:
- src
- tests
......@@ -16,7 +16,7 @@
</testsuite>
</testsuites>
<source>
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
......
......@@ -22,8 +22,15 @@ final class Chunk implements IteratorAggregate
private int $startRange;
private int $end;
private int $endRange;
/**
* @var list<Line>
*/
private array $lines;
/**
* @param list<Line> $lines
*/
public function __construct(int $start = 0, int $startRange = 1, int $end = 0, int $endRange = 1, array $lines = [])
{
$this->start = $start;
......@@ -54,7 +61,7 @@ final class Chunk implements IteratorAggregate
}
/**
* @psalm-return list<Line>
* @return list<Line>
*/
public function lines(): array
{
......@@ -62,7 +69,7 @@ final class Chunk implements IteratorAggregate
}
/**
* @psalm-param list<Line> $lines
* @param list<Line> $lines
*/
public function setLines(array $lines): void
{
......
......@@ -19,24 +19,24 @@ use Traversable;
final class Diff implements IteratorAggregate
{
/**
* @psalm-var non-empty-string
* @var non-empty-string
*/
private string $from;
/**
* @psalm-var non-empty-string
* @var non-empty-string
*/
private string $to;
/**
* @psalm-var list<Chunk>
* @var list<Chunk>
*/
private array $chunks;
/**
* @psalm-param non-empty-string $from
* @psalm-param non-empty-string $to
* @psalm-param list<Chunk> $chunks
* @param non-empty-string $from
* @param non-empty-string $to
* @param list<Chunk> $chunks
*/
public function __construct(string $from, string $to, array $chunks = [])
{
......@@ -46,7 +46,7 @@ final class Diff implements IteratorAggregate
}
/**
* @psalm-return non-empty-string
* @return non-empty-string
*/
public function from(): string
{
......@@ -54,7 +54,7 @@ final class Diff implements IteratorAggregate
}
/**
* @psalm-return non-empty-string
* @return non-empty-string
*/
public function to(): string
{
......@@ -62,7 +62,7 @@ final class Diff implements IteratorAggregate
}
/**
* @psalm-return list<Chunk>
* @return list<Chunk>
*/
public function chunks(): array
{
......@@ -70,7 +70,7 @@ final class Diff implements IteratorAggregate
}
/**
* @psalm-param list<Chunk> $chunks
* @param list<Chunk> $chunks
*/
public function setChunks(array $chunks): void
{
......
......@@ -42,6 +42,10 @@ final class Differ
$this->outputBuilder = $outputBuilder;
}
/**
* @param list<string>|string $from
* @param list<string>|string $to
*/
public function diff(array|string $from, array|string $to, ?LongestCommonSubsequenceCalculator $lcs = null): string
{
$diff = $this->diffToArray($from, $to, $lcs);
......@@ -49,6 +53,10 @@ final class Differ
return $this->outputBuilder->getDiff($diff);
}
/**
* @param list<string>|string $from
* @param list<string>|string $to
*/
public function diffToArray(array|string $from, array|string $to, ?LongestCommonSubsequenceCalculator $lcs = null): array
{
if (is_string($from)) {
......
......@@ -16,13 +16,8 @@ use Exception;
final class ConfigurationException extends InvalidArgumentException
{
public function __construct(
string $option,
string $expected,
$value,
int $code = 0,
?Exception $previous = null
) {
public function __construct(string $option, string $expected, mixed $value, int $code = 0, ?Exception $previous = null)
{
parent::__construct(
sprintf(
'Option "%s" must be %s, got "%s".',
......
......@@ -46,13 +46,13 @@ final class StrictUnifiedDiffOutputBuilder implements DiffOutputBuilderInterface
private bool $collapseRanges;
/**
* @psalm-var positive-int
* @var positive-int
*/
private int $commonLineThreshold;
private string $header;
/**
* @psalm-var positive-int
* @var positive-int
*/
private int $contextLines;
......
......@@ -30,7 +30,7 @@ final class UnifiedDiffOutputBuilder extends AbstractChunkOutputBuilder
private int $commonLineThreshold = 6;
/**
* @psalm-var positive-int
* @var positive-int
*/
private int $contextLines = 3;
private string $header;
......
......@@ -19,7 +19,7 @@ abstract class LongestCommonSubsequenceTestCase extends TestCase
private LongestCommonSubsequenceCalculator $implementation;
/**
* @psalm-var list<int>
* @var list<int>
*/
private array $stressSizes = [1, 2, 3, 100, 500, 1000, 2000];
......
......@@ -227,7 +227,7 @@ END;
}
/**
* @psalm-param list<Diff> $expected
* @param list<Diff> $expected
*/
#[DataProvider('diffProvider')]
public function testParser(string $diff, array $expected): void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment