Skip to content

Commit

Permalink
Update for PHP 8.1; Add better help color support
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksagona committed Oct 7, 2023
1 parent 9a83a0b commit 968677a
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 168 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ on:
pull_request:
branches: [ master ]

env:
XDEBUG_MODE: debug,coverage

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '7.4', '8.0' ]
php-versions: [ '8.1', '8.2' ]

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
composer.lock
bin
public
script
vendor

kettle
.phpunit.result.cache
.phpunit.cache
2 changes: 1 addition & 1 deletion LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3 Clause License

Copyright (c) 2009-2023, NOLA Interactive, LLC.
Copyright (c) 2009-2024, NOLA Interactive, LLC.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Install `pop-console` using Composer.

composer require popphp/pop-console

Or, require it in your composer.json file

"require": {
"popphp/pop-console" : "4.0.*"
}

BASIC USAGE
-----------
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
}
],
"require": {
"php": ">=7.4.0",
"popphp/popphp": "^3.7.2"
"php": ">=8.1.0",
"popphp/popphp": "^4.0.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0.0"
"phpunit/phpunit": "^10.0.0"
},
"autoload": {
"psr-4": {
Expand All @@ -41,7 +41,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.2.x-dev"
"dev-master": "4.0.x-dev"
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<report>
<html outputDirectory="/tmp/pop-console-cc" lowUpperBound="35" highLowerBound="70"/>
</report>
Expand All @@ -14,4 +11,9 @@
</testsuite>
</testsuites>
<logging/>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
62 changes: 32 additions & 30 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @link https://github.com/popphp/popphp-framework
* @author Nick Sagona, III <[email protected]>
* @copyright Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
* @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
* @license http://www.popphp.org/license New BSD License
*/

Expand All @@ -19,45 +19,47 @@
* @category Pop
* @package Pop\Console
* @author Nick Sagona, III <[email protected]>
* @copyright Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
* @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
* @license http://www.popphp.org/license New BSD License
* @version 3.2.0
* @version 4.0.0
*/
class Command
{

/**
* Command name
* @var string
* @var ?string
*/
protected $name = null;
protected ?string $name = null;

/**
* Command params
* @var string
* @var ?string
*/
protected $params = null;
protected ?string $params = null;

/**
* Command help
* @var string
* @var ?string
*/
protected $help = null;
protected ?string $help = null;

/**
* Instantiate the command object
*
* @param string $name
* @param string $params
* @param string $help
* @return Command
* @param string $name
* @param ?string $params
* @param ?string $help
*/
public function __construct($name, $params = null, $help = null)
public function __construct(string $name, ?string $params = null, ?string $help = null)
{
$this->name = $name;
$this->params = $params;
$this->help = $help;
return $this;
$this->setName($name);
if ($params !== null) {
$this->setParams($params);
}
if ($help !== null) {
$this->setHelp($help);
}
}

/**
Expand All @@ -66,7 +68,7 @@ public function __construct($name, $params = null, $help = null)
* @param string $name
* @return Command
*/
public function setName($name)
public function setName(string $name): Command
{
$this->name = $name;
return $this;
Expand All @@ -78,7 +80,7 @@ public function setName($name)
* @param string $params
* @return Command
*/
public function setParams($params)
public function setParams(string $params): Command
{
$this->params = $params;
return $this;
Expand All @@ -90,7 +92,7 @@ public function setParams($params)
* @param string $help
* @return Command
*/
public function setHelp($help)
public function setHelp(string $help): Command
{
$this->help = $help;
return $this;
Expand All @@ -101,7 +103,7 @@ public function setHelp($help)
*
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}
Expand All @@ -111,37 +113,37 @@ public function getName()
*
* @return string
*/
public function getParams()
public function getParams(): string
{
return $this->params;
}

/**
* Determine if the command has params
*
* @return boolean
* @return bool
*/
public function hasParams()
public function hasParams(): bool
{
return (null !== $this->params);
}

/**
* Get the command help
*
* @return string
* @return string|null
*/
public function getHelp()
public function getHelp(): string|null
{
return $this->help;
}

/**
* Determine if the command has help
*
* @return boolean
* @return bool
*/
public function hasHelp()
public function hasHelp(): bool
{
return (null !== $this->help);
}
Expand All @@ -151,7 +153,7 @@ public function hasHelp()
*
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->name . ((null !== $this->params) ? ' ' . $this->params : null);
}
Expand Down
Loading

0 comments on commit 968677a

Please sign in to comment.