Skip to content

Commit

Permalink
Merge pull request #125 from peter279k/3.x-patch
Browse files Browse the repository at this point in the history
Add the 3.x Patch
  • Loading branch information
c9s committed Dec 14, 2022
2 parents 2650a53 + 01cee2d commit ec530d4
Show file tree
Hide file tree
Showing 42 changed files with 143 additions and 97 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: build

on: [push, pull_request]

jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, zip, xml
coverage: none

- name: Install dependencies
run: composer install -n

- name: Run test suite
run: vendor/bin/phpunit --exclude-group github_action

- name: Run demo script
run: example/demo meta --zsh commit arg 0 suggestions && example/demo meta --zsh commit arg 1 valid-values && example/demo zsh --bind demo > zsh
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"getopt"
],
"require": {
"php": ">=5.3.0",
"php": ">=7.2",
"corneltek/getoptionkit": "^2",
"corneltek/class-template": "^2",
"corneltek/universal": ">= 1.4",
Expand All @@ -23,7 +23,8 @@
"require-dev": {
"corneltek/phpunit-testmore": "dev-master",
"satooshi/php-coveralls": "^1",
"phpunit/phpunit": "^4.8 || ^5.7"
"phpunit/phpunit": "^8.5 || ^9.5",
"ext-intl": "*"
},
"license": "MIT",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ArchiveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function options($opts)
->defaultValue(true)
;

$opts->add('c|compress?', 'compress type: gz, bz2')
$opts->add('compress?', 'compress type: gz, bz2')
->defaultValue('gz')
->validValues(array('gz', 'bz2'))
;
Expand Down
5 changes: 5 additions & 0 deletions src/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -895,26 +895,31 @@ public function choose($prompt, $choices)
return $chooser->choose( $prompt, $choices );
}

#[\ReturnTypeWillChange]
public function offsetExists($key)
{
return isset($this->commands[$key]);
}

#[\ReturnTypeWillChange]
public function offsetSet($key,$value)
{
$this->commands[$key] = $value;
}

#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->commands[$key];
}

#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
unset($this->commands[$key]);
}

#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->commands);
Expand Down
2 changes: 1 addition & 1 deletion src/Completion/ZshGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function option_flag_item(Option $opt, $cmdSignature) {
// output description
$str .= "[" . addcslashes($opt->desc,'[]:') . "]";

$placeholder = ($opt->valueName) ? $opt->valueName : $opt->isa ? $opt->isa : null;
$placeholder = (($opt->valueName) ? $opt->valueName : $opt->isa) ? $opt->isa : null;

// has anything to complete
if ($opt->validValues || $opt->suggestions || $opt->isa) {
Expand Down
3 changes: 3 additions & 0 deletions src/Component/Table/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ private function getNumberOfColumns()

$columns = array(count($this->headers));
foreach ($this->rows as $row) {
if (!is_array($row)) {
$row = [];
}
$columns[] = count($row);
}
return $this->numberOfColumns = max($columns);
Expand Down
2 changes: 1 addition & 1 deletion src/OptionPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace CLIFramework;
use GetOptionKit\OptionCollection;
use GetOptionKit\Option;
use GetOptionKit\OptionPrinter\OptionPrinterInterface;
use GetOptionKit\OptionPrinter\OptionPrinter as OptionPrinterInterface;
use CLIFramework\Formatter;

class OptionPrinter implements OptionPrinterInterface
Expand Down
8 changes: 4 additions & 4 deletions src/Testing/CommandTestCase.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace CLIFramework\Testing;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

abstract class CommandTestCase extends PHPUnit_Framework_TestCase
abstract class CommandTestCase extends TestCase
{
public $app;

Expand All @@ -15,15 +15,15 @@ public function getApplication()
return $this->app;
}

public function setUp()
protected function setUp(): void
{
if ($this->outputBufferingActive) {
ob_start();
}
$this->app = $this->setupApplication();
}

public function tearDown()
protected function tearDown(): void
{
$this->app = NULL;
if ($this->outputBufferingActive) {
Expand Down
6 changes: 4 additions & 2 deletions src/Testing/ConsoleTestCase.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace CLIFramework\Testing;

class ConsoleTestCase extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class ConsoleTestCase extends TestCase
{
protected function runScript($path, $input, $callback)
{
Expand All @@ -21,7 +23,7 @@ protected function runScript($path, $input, $callback)
@fclose($pipes[0]);
@fclose($pipes[1]);
@fclose($pipes[2]);
@pclose($process);
@proc_close($process);
$callback($content);
}
}
3 changes: 2 additions & 1 deletion tests/CLIFramework/Ansi/ColorsTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
use CLIFramework\Ansi\Colors;
use PHPUnit\Framework\TestCase;

class ColorsTest extends PHPUnit_Framework_TestCase
class ColorsTest extends TestCase
{
public function stringProvider()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
*/
namespace tests\CLIFramework;
use TestApp\Application;
use PHPUnit\Framework\TestCase;

class ApplicationTest extends \PHPUnit_Framework_TestCase
class ApplicationTest extends TestCase
{
function test()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/ArgumentEditor/ArgumentEditorTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
use CLIFramework\ArgumentEditor\ArgumentEditor;
use PHPUnit\Framework\TestCase;

class ArgumentEditorTest extends PHPUnit_Framework_TestCase
class ArgumentEditorTest extends TestCase
{
public function testAppendAndRemove()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/ArgumentInfoListTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
use CLIFramework\ArgInfo;
use CLIFramework\ArgInfoList;
use PHPUnit\Framework\TestCase;

class ArgInfoListTest extends PHPUnit_Framework_TestCase
class ArgInfoListTest extends TestCase
{
public function test()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/ArgumentInfoTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
use CLIFramework\ArgInfo;
use PHPUnit\Framework\TestCase;

class ArgInfoTest extends PHPUnit_Framework_TestCase
class ArgInfoTest extends TestCase
{
public function test()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
use CLIFramework\Logger;
use CLIFramework\Autoload\ComposerAutoloadGenerator;
use PHPUnit\Framework\TestCase;

class ComposerAutoloadGeneratorTest extends PHPUnit_Framework_TestCase
class ComposerAutoloadGeneratorTest extends TestCase
{
public function test()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/BufferTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
use CLIFramework\Buffer;
use PHPUnit\Framework\TestCase;

class BufferTest extends PHPUnit_Framework_TestCase
class BufferTest extends TestCase
{
public function testAppend()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ExampleApplication extends CLIFramework\Application {
}


class ZshCompletionCommandTest extends PHPUnit_Framework_TestCase
class ZshCompletionCommandTest extends \PHPUnit\Framework\TestCase
{

public function test()
Expand Down
4 changes: 3 additions & 1 deletion tests/CLIFramework/CommandLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
*
*/

class CommandLoaderTest extends PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class CommandLoaderTest extends TestCase
{
public function test()
{
Expand Down
5 changes: 3 additions & 2 deletions tests/CLIFramework/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

use CLIFramework\Command;
use CLIFramework\Application;
use PHPUnit\Framework\TestCase;

class CommandTest extends \PHPUnit_Framework_TestCase
class CommandTest extends TestCase
{
private $command;

public function setUp()
protected function setUp(): void
{
$this->command = new CommandTestCommand();
}
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/CompletionUtilsTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
use CLIFramework\CompletionUtils;
use PHPUnit\Framework\TestCase;

class CompletionUtilsTest extends PHPUnit_Framework_TestCase
class CompletionUtilsTest extends TestCase
{
public function testSplitWords()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/Component/Progress/ETACalculatorTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
use CLIFramework\Component\Progress\ETACalculator;
use PHPUnit\Framework\TestCase;

class ETACalculatorTest extends PHPUnit_Framework_TestCase
class ETACalculatorTest extends TestCase
{

public function testCalculateRemainingSeconds()
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/Component/Table/DateFormatCellTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
use CLIFramework\Component\Table\DateFormatCell;
use PHPUnit\Framework\TestCase;

class DateFormatCellTest extends PHPUnit_Framework_TestCase
class DateFormatCellTest extends TestCase
{
public function testDateFormat()
{
Expand Down
7 changes: 4 additions & 3 deletions tests/CLIFramework/Component/Table/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
use CLIFramework\Component\Table\CurrencyCellAttribute;
use CLIFramework\Component\Table\SpellOutNumberFormatCell;
use CLIFramework\Component\Table\RowSeparator;
use PHPUnit\Framework\TestCase;

class TableTest extends PHPUnit_Framework_TestCase
class TableTest extends TestCase
{

public function testNumberFormatCell()
Expand Down Expand Up @@ -181,7 +182,7 @@ public function testMarkdownTable()
$this->assertStringEqualsFile('tests/data/markdown-table.txt', $out);
}

static public function assertStringEqualsFile($file, $str, $message = NULL, $canonicalize = false, $ignoreCase = false) {
public static function assertStringEqualsFile($file, $str, $message = NULL, $canonicalize = false, $ignoreCase = false): void {
if ($str instanceof Table) {
$str = $str->render();
}
Expand All @@ -190,7 +191,7 @@ static public function assertStringEqualsFile($file, $str, $message = NULL, $can
echo "Actual:\n";
echo $str , "\n";
}
parent::assertStringEqualsFile($file, $str, $message, $canonicalize, $ignoreCase);
parent::assertStringEqualsFile($file, $str, (string)$message, $canonicalize, $ignoreCase);
}

}
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/Config/GlobalConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
namespace tests\CLIFramework\Config;

use CLIFramework\Config\GlobalConfig;
use PHPUnit\Framework\TestCase;

class GlobalConfigTest extends \PHPUnit_Framework_TestCase
class GlobalConfigTest extends TestCase
{
/**
* @test
Expand Down
3 changes: 2 additions & 1 deletion tests/CLIFramework/ConsoleInfo/EnvConsoleInfoTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
use CLIFramework\ConsoleInfo\EnvConsoleInfo;
use PHPUnit\Framework\TestCase;

class EnvConsoleInfoTest extends PHPUnit_Framework_TestCase
class EnvConsoleInfoTest extends TestCase
{
public function test()
{
Expand Down

0 comments on commit ec530d4

Please sign in to comment.