Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop php <7.4 support, symfony <4.4, add php 8.1 to pipeline #151

Merged
merged 4 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/autoreview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
php-version: ['7.4']
php-version: ['8.0']

name: Autoreview on PHP ${{ matrix.php-version }}

Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,13 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-version: ['7.1', '7.2', '7.3', '7.4', '8.0']
php-version: ['7.4', '8.0', '8.1']
symfony-require: ['^4', '^5', '^6']
exclude:
- symfony-require: "^5"
php-version: "7.1"
- symfony-require: "^6"
php-version: "7.1"
- symfony-require: "^6"
php-version: "7.2"
- symfony-require: "^6"
php-version: "7.3"
- symfony-require: "^6"
php-version: "7.4"
include:
- { operating-system: 'windows-latest', php-version: '7.4', symfony-require: '^5' }
- { operating-system: 'windows-latest', php-version: '8.0', symfony-require: '^5' }

name: CI on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }}, with Symfony ${{ matrix.symfony-require }}

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/cs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ jobs:
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-

- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist

- name: Run ${{ matrix.check }}
- name: Run Code Style Checker
run: composer run cs-check
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PHP Magic Number Detector (PHPMND)

[![Minimum PHP version: 7.1.0](https://img.shields.io/badge/php-7.1.0%2B-blue.svg)](https://packagist.org/packages/povils/phpmnd)
[![Minimum PHP version: 7.4.0](https://img.shields.io/badge/php-7.4.0%2B-blue.svg)](https://packagist.org/packages/povils/phpmnd)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/povils/phpmnd/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/povils/phpmnd/?branch=master)
[![License](https://poser.pugx.org/povils/phpmnd/license)](https://packagist.org/packages/povils/phpmnd)
[![CI](https://github.com/povils/phpmnd/workflows/CI/badge.svg?branch=master)](https://github.com/povils/phpmnd)
Expand Down
4 changes: 2 additions & 2 deletions bin/phpmnd
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ if (\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) === false) {
exit(1);
}

if (\version_compare('7.1.0', \PHP_VERSION, '>')) {
if (\version_compare('7.4.0', \PHP_VERSION, '>')) {
\fwrite(
\STDERR,
\sprintf(
'This version of PHPMND is supported on PHP 7.1.' . \PHP_EOL .
'This version of PHPMND is supported on PHP 7.4.' . \PHP_EOL .
'You are using PHP %s%s.' . \PHP_EOL,
\PHP_VERSION,
\defined('PHP_BINARY') ? ' (' . \PHP_BINARY . ')' : ''
Expand Down
17 changes: 6 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"issues": "https://github.com/povils/phpmnd/issues"
},
"require": {
"php": "^7.1|^8.0",
"symfony/console": "^4.0||^5.0||^6.0",
"symfony/finder": "^4.0||^5.0||^6.0",
"nikic/php-parser": "^4.0",
"php-parallel-lint/php-console-highlighter": "^0.5",
"php": "^7.4 || ^8.0",
"symfony/console": "^4.4 || ^5.0 || ^6.0",
"symfony/finder": "^4.4 || ^5.0 || ^6.0",
"nikic/php-parser": "^4.13",
"php-parallel-lint/php-console-highlighter": "^1.0",
"phpunit/php-timer": "^2.0||^3.0||^4.0||^5.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0||^8.0||^9.0",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^2.8.1||^3.5"
},
"autoload": {
Expand All @@ -41,10 +41,5 @@
"test": "phpunit",
"cs-check": "phpcs -p --standard=PSR2 --runtime-set ignore_warnings_on_exit 1 src tests --ignore=tests/Fixtures/Files",
"cs-fix": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests --ignore=tests/Fixtures/Files"
},
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
}
}
16 changes: 6 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@
failOnRisky="true"
verbose="true"
>
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>

<testsuites>
<testsuite name="PHPMND Test Suite">
<directory>tests/</directory>

<exclude>tests/Fixtures</exclude>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src/</directory>

<exclude>
<directory>vendor/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
9 changes: 3 additions & 6 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Povils\PHPMND\Command;

use JakubOnderka\PhpConsoleColor\ConsoleColor;
use JakubOnderka\PhpConsoleHighlighter\Highlighter;
use PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;
use PHP_Parallel_Lint\PhpConsoleHighlighter\Highlighter;
use Povils\PHPMND\Console\Application;
use Povils\PHPMND\Console\Option;
use Povils\PHPMND\Detector;
Expand All @@ -30,10 +30,7 @@ class RunCommand extends BaseCommand
public const SUCCESS = 0;
public const FAILURE = 1;

/**
* @var Timer
*/
private $timer;
private Timer $timer;

protected function configure(): void
{
Expand Down
5 changes: 1 addition & 4 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ class Application extends BaseApplication
public const VERSION = '2.5.0';
private const NAME = 'phpmnd';

/**
* @var Container
*/
private $container;
private Container $container;

public function __construct(Container $container)
{
Expand Down
40 changes: 14 additions & 26 deletions src/Console/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ class Option
/**
* @var Extension[]
*/
private $extensions = [];
private array $extensions = [];

/**
* @var array
*/
private $ignoreNumbers = [0, 0., 1];
private array $ignoreNumbers = [0, 0., 1];

/**
* @var array
*/
private $ignoreFuncs = [
private array $ignoreFuncs = [
'intval',
'floatval',
'strval',
Expand All @@ -30,27 +30,15 @@ class Option
/**
* @var array
*/
private $ignoreStrings = ['', '0', '1'];
private array $ignoreStrings = ['', '0', '1'];

/**
* @var bool
*/
private $includeStrings = false;
private bool $includeStrings = false;

/**
* @var bool
*/
private $giveHint = false;
private bool $giveHint = false;

/**
* @var bool
*/
private $includeNumericStrings = false;
private bool $includeNumericStrings = false;

/**
* @var bool
*/
private $allowArrayMapping = false;
private bool $allowArrayMapping = false;

public function setExtensions(array $extensions): void
{
Expand Down Expand Up @@ -82,12 +70,12 @@ public function getIgnoreFuncs(): array
return $this->ignoreFuncs;
}

public function includeStrings(): ?bool
public function includeStrings(): bool
{
return $this->includeStrings;
}

public function setIncludeStrings(?bool $includeStrings): void
public function setIncludeStrings(bool $includeStrings): void
{
$this->includeStrings = $includeStrings;
}
Expand All @@ -112,22 +100,22 @@ public function setGiveHint(bool $giveHint): void
$this->giveHint = $giveHint;
}

public function includeNumericStrings(): ?bool
public function includeNumericStrings(): bool
{
return $this->includeNumericStrings;
}

public function setIncludeNumericStrings(?bool $includeNumericStrings): void
public function setIncludeNumericStrings(bool $includeNumericStrings): void
{
$this->includeNumericStrings = $includeNumericStrings;
}

public function allowArrayMapping(): ?bool
public function allowArrayMapping(): bool
{
return $this->allowArrayMapping;
}

public function setAllowArrayMapping(?bool $allowArrayMapping): void
public function setAllowArrayMapping(bool $allowArrayMapping): void
{
$this->allowArrayMapping = $allowArrayMapping;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

class Container
{
private $keys = [];
private $factories = [];
private $values = [];
private array $keys = [];
private array $factories = [];
private array $values = [];

private function __construct(array $values)
{
Expand Down
10 changes: 2 additions & 8 deletions src/DetectionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@

class DetectionResult
{
/**
* @var SplFileInfo
*/
private $file;
private SplFileInfo $file;

/**
* @var int
*/
private $line;
private int $line;

/**
* @var float|int|string
Expand Down
15 changes: 3 additions & 12 deletions src/Detector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,11 @@

class Detector
{
/**
* @var Option
*/
private $option;
private Option $option;

/**
* @var FileParser
*/
private $parser;
private FileParser $parser;

/**
* @var HintList
*/
private $hintList;
private HintList $hintList;

public function __construct(FileParser $parser, Option $option, HintList $hintList)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Extension/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

abstract class Extension
{
/**
* @var Option
*/
protected $option;
protected Option $option;

abstract public function extend(Node $node): bool;

Expand Down
14 changes: 7 additions & 7 deletions src/ExtensionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ class ExtensionResolver
/**
* @var Extension[]
*/
private $allExtensions;
private array $allExtensions = [];

/**
* @var Extension[]
*/
private $defaultExtensions;
private array $defaultExtensions = [];

/**
* @var Extension[]
*/
private $resolvedExtensions = [];
private array $resolvedExtensions = [];

public function resolve(array $extensionNames): array
{
$this->resolvedExtensions = $this->defaults();
if (($allKey = array_search(self::ALL_EXTENSIONS, $extensionNames)) !== false) {
if (($allKey = array_search(self::ALL_EXTENSIONS, $extensionNames, true)) !== false) {
$this->resolvedExtensions = $this->all();
unset($extensionNames[$allKey]);
}
Expand All @@ -56,7 +56,7 @@ public function resolve(array $extensionNames): array

public function defaults(): array
{
if (null === $this->defaultExtensions) {
if ([] === $this->defaultExtensions) {
$this->defaultExtensions = [
new ConditionExtension,
new ReturnExtension,
Expand All @@ -69,7 +69,7 @@ public function defaults(): array

public function all(): array
{
if (null === $this->allExtensions) {
if ([] === $this->allExtensions) {
$this->allExtensions = array_merge(
[
new ArgumentExtension,
Expand All @@ -95,7 +95,7 @@ private function addExtension(string $extensionName): void

return;
}
};
}
}
}

Expand Down
12 changes: 3 additions & 9 deletions src/FileReportGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@

class FileReportGenerator
{
/**
* @var SplFileInfo
*/
private $file;

/**
* @var Option
*/
private $option;
private SplFileInfo $file;

private Option $option;

public function __construct(SplFileInfo $file, Option $option)
{
Expand Down
Loading