Skip to content

Commit

Permalink
Merge pull request #190 from eliashaeussler/fix/implicit-nullable-types
Browse files Browse the repository at this point in the history
Add support for PHP 8.4
  • Loading branch information
GenieTim authored Nov 26, 2024
2 parents de2b2cc + ce90fe1 commit 4e546ee
Show file tree
Hide file tree
Showing 43 changed files with 107 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_style_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.3
php-version: 8.1
coverage: none # disable xdebug, pcov
- run: composer install --no-progress
# fix code style, automatically
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"
symfony:
- 5.*
- 6.*
- 7.*
dependency-version:
# - prefer-lowest
- prefer-stable
exclude:
- {php: "8.0", symfony: "7.*"}
- {php: "8.1", symfony: "7.*"}
- {php: "8.2", symfony: "5.*"}

name: PHP ${{ matrix.php }} - S ${{ matrix.symfony }} - ${{ matrix.dependency-version }} - tests
Expand Down
10 changes: 6 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ parameters:
paths:
- src
# - tests

# things we disable for the moment, but one day...
inferPrivatePropertyTypeFromConstructor: true
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
-
-
message: '#Unsafe usage of new static\(\).#'
path: %currentWorkingDirectory%
-
message: '#Parameter \#1 \$command of class Symfony\\Component\\Process\\Process constructor expects array, string given.#'
path: src/GitElephant/Command/Caller/Caller.php
-
identifier: missingType.iterableValue
-
identifier: missingType.generics

includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
8 changes: 4 additions & 4 deletions src/GitElephant/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ class BaseCommand
/**
* the command subject
*
* @var string|SubCommandCommand|null
* @var array|string|SubCommandCommand|null
*/
private $commandSubject = null;

/**
* the command second subject (i.e. for branch)
*
* @var string|SubCommandCommand|null
* @var array|string|SubCommandCommand|null
*/
private $commandSubject2 = null;

Expand Down Expand Up @@ -112,7 +112,7 @@ class BaseCommand
*
* @param null|\GitElephant\Repository $repo The repo object to read
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
if (!is_null($repo)) {
$this->addGlobalConfigs($repo->getGlobalConfigs());
Expand Down Expand Up @@ -148,7 +148,7 @@ public function clearAll(): void
* @param Repository $repo
* @return static
*/
public static function getInstance(Repository $repo = null)
public static function getInstance(?Repository $repo = null)
{
return new static($repo);
}
Expand Down
4 changes: 2 additions & 2 deletions src/GitElephant/Command/BranchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BranchCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down Expand Up @@ -69,7 +69,7 @@ public function contains(string $reference): string
* @throws \RuntimeException
* @return string the command
*/
public function create(string $name, string $startPoint = null): string
public function create(string $name, ?string $startPoint = null): string
{
$this->clearAll();
$this->addCommandName(self::BRANCH_COMMAND);
Expand Down
4 changes: 2 additions & 2 deletions src/GitElephant/Command/Caller/Caller.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct($gitPath, $repositoryPath)
public function execute(
string $cmd,
bool $git = true,
string $cwd = null,
?string $cwd = null,
array $acceptedExitCodes = [0]
): CallerInterface {
if ($git) {
Expand Down Expand Up @@ -107,7 +107,7 @@ public function execute(
$text .= "\n" . $process->getOutput();
throw new \RuntimeException($text);
}

$this->rawOutput = $process->getOutput();
// rtrim values
$values = array_map('rtrim', explode(PHP_EOL, $process->getOutput()));
Expand Down
2 changes: 1 addition & 1 deletion src/GitElephant/Command/Caller/CallerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface CallerInterface
public function execute(
string $cmd,
bool $git = true,
string $cwd = null
?string $cwd = null
): CallerInterface;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/GitElephant/Command/CatFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CatFileCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down
10 changes: 5 additions & 5 deletions src/GitElephant/Command/CloneCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CloneCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand All @@ -57,9 +57,9 @@ public function __construct(Repository $repo = null)
*/
public function cloneUrl(
string $url,
string $to = null,
string $repoReference = null,
int $depth = null,
?string $to = null,
?string $repoReference = null,
?int $depth = null,
bool $recursive = false
): string {
// get binary version before reset
Expand Down Expand Up @@ -90,7 +90,7 @@ public function cloneUrl(
$this->addCommandArgument('--shallow-submodules');
}
}

if ($recursive) {
$this->addCommandArgument('--recursive');
}
Expand Down
2 changes: 1 addition & 1 deletion src/GitElephant/Command/DiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DiffCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down
2 changes: 1 addition & 1 deletion src/GitElephant/Command/DiffTreeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DiffTreeCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down
4 changes: 2 additions & 2 deletions src/GitElephant/Command/FetchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class FetchCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public function fetch($remote = null, $branch = null, array $options = []): stri
foreach ($normalizedOptions as $value) {
$this->addCommandArgument($value);
}

if (!is_null($remote)) {
$this->addCommandSubject($remote);
}
Expand Down
8 changes: 4 additions & 4 deletions src/GitElephant/Command/LogCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class LogCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand All @@ -57,7 +57,7 @@ public function __construct(Repository $repo = null)
* @throws \RuntimeException
* @return string
*/
public function showObjectLog(NodeObject $obj, $branch = null, int $limit = null, int $offset = null): string
public function showObjectLog(NodeObject $obj, $branch = null, ?int $limit = null, ?int $offset = null): string
{
$subject = null;
if (null !== $branch) {
Expand All @@ -84,7 +84,7 @@ public function showObjectLog(NodeObject $obj, $branch = null, int $limit = null
* @throws \RuntimeException
* @return string
*/
public function showLog($ref, $path = null, $limit = null, int $offset = null, bool $firstParent = false): string
public function showLog($ref, $path = null, $limit = null, ?int $offset = null, bool $firstParent = false): string
{
$this->clearAll();

Expand Down Expand Up @@ -114,7 +114,7 @@ public function showLog($ref, $path = null, $limit = null, int $offset = null, b
if (null !== $path && !empty($path)) {
$this->addPath($path);
}

$this->addCommandSubject($ref);

return $this->getCommand();
Expand Down
4 changes: 2 additions & 2 deletions src/GitElephant/Command/LogRangeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LogRangeCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down Expand Up @@ -94,7 +94,7 @@ public function showLog(
if (null !== $path && !empty($path)) {
$this->addPath($path);
}

$this->addCommandSubject($refStart . '..' . $refEnd);

return $this->getCommand();
Expand Down
2 changes: 1 addition & 1 deletion src/GitElephant/Command/LsTreeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LsTreeCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down
6 changes: 3 additions & 3 deletions src/GitElephant/Command/MainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MainCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public function commit(
bool $stageAll = false,
$author = null,
bool $allowEmpty = false,
\DateTimeInterface $date = null
?\DateTimeInterface $date = null
): string {
$this->clearAll();

Expand All @@ -170,7 +170,7 @@ public function commit(
if ($allowEmpty) {
$this->addCommandArgument('--allow-empty');
}

if (null !== $date) {
$this->addCommandArgument('--date');
$this->addCommandArgument($date->format(\DateTimeInterface::RFC822));
Expand Down
4 changes: 2 additions & 2 deletions src/GitElephant/Command/MergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MergeCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down Expand Up @@ -76,7 +76,7 @@ public function merge(Branch $with, $message = '', array $options = []): string
$this->addCommandArgument('-m');
$this->addCommandArgument($message);
}

$this->addCommandSubject($with->getFullRef());

return $this->getCommand();
Expand Down
2 changes: 1 addition & 1 deletion src/GitElephant/Command/MvCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MvCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down
2 changes: 1 addition & 1 deletion src/GitElephant/Command/PullCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PullCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down
6 changes: 3 additions & 3 deletions src/GitElephant/Command/PushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PushCommand extends BaseCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand All @@ -49,7 +49,7 @@ public function __construct(Repository $repo = null)
* @throws \RuntimeException
* @return string
*/
public function push($remote = 'origin', $branch = 'master', string $args = null): string
public function push($remote = 'origin', $branch = 'master', ?string $args = null): string
{
$this->clearAll();

Expand All @@ -63,7 +63,7 @@ public function push($remote = 'origin', $branch = 'master', string $args = null
$this->addCommandName(self::GIT_PUSH_COMMAND);
$this->addCommandSubject($remote);
$this->addCommandSubject2($branch);

if (!is_null($args)) {
$this->addCommandArgument($args);
}
Expand Down
4 changes: 2 additions & 2 deletions src/GitElephant/Command/Remote/AddSubCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AddSubCommand extends SubCommandCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand Down Expand Up @@ -97,7 +97,7 @@ public function prepare($name, $url, $options = []): self
$this->addCmdSwitchOptions(),
$this->addCmdValueOptions()
);

$this->addCommandName(self::GIT_REMOTE_ADD);
$this->addCommandSubject($name);
$this->addCommandSubject($url);
Expand Down
4 changes: 2 additions & 2 deletions src/GitElephant/Command/Remote/ShowSubCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ShowSubCommand extends SubCommandCommand
* @param \GitElephant\Repository $repo The repository object this command
* will interact with
*/
public function __construct(Repository $repo = null)
public function __construct(?Repository $repo = null)
{
parent::__construct($repo);
}
Expand All @@ -69,7 +69,7 @@ public function prepare($name = null, $queryRemotes = true): self
if ($name) {
$this->addCommandSubject($name);
}

if (!$queryRemotes) {
$this->addCommandArgument('-n');
}
Expand Down
Loading

0 comments on commit 4e546ee

Please sign in to comment.