Skip to content

Commit

Permalink
Composer update #72 & fix semver OR condition (#73)
Browse files Browse the repository at this point in the history
* Composer update #72 & fix semver OR condition

phpunit ^9.0
php-file-iterator ^3.0

in composer OR condition is represented through double pipes (||).
https://getcomposer.org/doc/articles/versions.md#version-range

* Remove travis check
* Enable github actions for ci check on php 7.3 and 7.4
  • Loading branch information
calbrecht authored Jan 23, 2021
1 parent 79342b7 commit 17f8bce
Show file tree
Hide file tree
Showing 36 changed files with 840 additions and 710 deletions.
24 changes: 24 additions & 0 deletions .github/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions .github/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
description = "A php test environment flake";

outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages."${system}";

phpEnv = phpPackage: (phpPackage.buildEnv {
extensions = { enabled, all }: (enabled ++ [ all.xdebug ]);
extraConfig = ''
memory_limit=-1
xdebug.mode=coverage
'' +
pkgs.lib.optionalString (pkgs.lib.versionOlder phpPackage.version "8.0") ''
xdebug.coverage_enable=1
'';
});

phpVersions = [
"php73"
"php74"
"php80"
];
in
{
packages."${system}" = builtins.listToAttrs
(builtins.map
(name:
{
name = "env-${name}";
value = pkgs.symlinkJoin {
name = "env-${name}";
paths = [
(phpEnv pkgs."${name}")
(phpEnv pkgs."${name}").packages.composer2
];
};
}
)
phpVersions);
};
}
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Simple Nix Flakes powered php ci.

on: [push, pull_request]

jobs:
ci:

runs-on: ubuntu-latest

strategy:
matrix:
php: [php73, php74]

steps:
- uses: actions/checkout@v2
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0

- uses: cachix/install-nix-action@v12
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
extra_nix_config: |
experimental-features = nix-command flakes
- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: /home/runner/.cache/composer
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- run: |
rm -fr vendor
nix shell .github#env-${{ matrix.php }} --command composer ci-prepare
nix shell .github#env-${{ matrix.php }} --command composer ci
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
],
"git-commit": "git-commit",
"git-version": "git-version",
"output": "phpcb-2.3.1.phar"
"output": "phpcb-2.3.2.phar"
}
21 changes: 12 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.3",
"ext-dom": "*",
"monolog/monolog": "~1.7|~2.0",
"phpunit/php-file-iterator": "~2.0",
"symfony/console": "~3.4|~4.0|~5.0"
"monolog/monolog": "~1.7||~2.0",
"phpunit/php-file-iterator": "~2.0||^3.0",
"symfony/console": "~3.4||~4.0||~5.0"
},
"require-dev": {
"humbug/box": "^3.8.3",
"mayflower/mo4-coding-standard": "^5.0",
"mayflower/mo4-coding-standard": "^6.0",
"phploc/phploc": "*",
"phpmd/phpmd": "1.5.*|~2.6",
"phpmd/phpmd": "1.5.*||~2.6",
"phpstan/phpstan": "^0.12.5",
"phpunit/phpunit": "~8.4",
"phpunit/phpunit": "~8.4||^9.0",
"sebastian/phpcpd": "*"
},
"autoload": {
Expand All @@ -50,9 +50,12 @@
"phploc -q --log-xml=build/logs/phploc.xml src || true",
"@browser"
],
"travis": [
"ci-prepare": [
"composer update --prefer-dist --no-interaction --no-progress"
],
"ci": [
"phpcs -s --standard=MO4 src/PHPCodeBrowser/",
"phpstan analyse --no-progress --level=1 src/PHPCodeBrowser/",
"phpstan analyse --no-progress",
"phpunit"
],
"clean": "rm -rf build/logs/* build/code-browser",
Expand Down
15 changes: 0 additions & 15 deletions phpstan_baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,10 @@ parameters:
-
message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#"
count: 1
path: src/PHPCodeBrowser/AbstractPlugin.php

-
message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#"
count: 5
path: src/PHPCodeBrowser/Plugins/ErrorCPD.php

-
message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#"
count: 1
path: src/PHPCodeBrowser/Plugins/ErrorCRAP.php

-
message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#"
count: 2
path: src/PHPCodeBrowser/Plugins/ErrorCoverage.php

-
message: "#^Access to an undefined property DOMNode\\:\\:\\$wholeText\\.$#"
count: 1
path: src/PHPCodeBrowser/View/ViewReview.php

52 changes: 29 additions & 23 deletions src/PHPCodeBrowser/AbstractPlugin.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Abstract Plugin
*
Expand Down Expand Up @@ -36,45 +37,45 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category PHP_CodeBrowser
* @category PHP_CodeBrowser
*
* @author Elger Thiele <[email protected]>
* @author Michel Hartmann <[email protected]>
* @author Elger Thiele <[email protected]>
* @author Michel Hartmann <[email protected]>
*
* @copyright 2007-2010 Mayflower GmbH
*
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*
* @version SVN: $Id$
* @version SVN: $Id$
*
* @link http://www.phpunit.de/
* @link http://www.phpunit.de/
*
* @since File available since 0.1.0
* @since File available since 0.1.0
*/

namespace PHPCodeBrowser;

use \DOMElement;
use \DOMNode;
use \DOMNodeList;
use DOMElement;
use DOMNode;
use DOMNodeList;

/**
* AbstractPlugin
*
* @category PHP_CodeBrowser
* @category PHP_CodeBrowser
*
* @author Elger Thiele <[email protected]>
* @author Michel Hartmann <[email protected]>
* @author Elger Thiele <[email protected]>
* @author Michel Hartmann <[email protected]>
*
* @copyright 2007-2010 Mayflower GmbH
*
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*
* @version Release: @package_version@
* @version Release: @package_version@
*
* @link http://www.phpunit.de/
* @link http://www.phpunit.de/
*
* @since Class available since 0.1.0
* @since Class available since 0.1.0
*/
abstract class AbstractPlugin
{
Expand Down Expand Up @@ -179,7 +180,7 @@ public function getIssuesByFile(string $filename): array
$issues = [];

foreach ($this->getIssueNodes($filename) as $issueNode) {
$issues = array_merge(
$issues = \array_merge(
$issues,
$this->mapIssues($issueNode, $filename)
);
Expand All @@ -197,14 +198,14 @@ public function getFilesWithIssues(): array
{
$fileNames = [];
$issueNodes = $this->issueXml->query(
sprintf('/*/%s/file[@name]', $this->pluginName)
\sprintf('/*/%s/file[@name]', $this->pluginName)
);

foreach ($issueNodes as $node) {
$fileNames[] = $node->getAttribute('name');
}

return array_unique($fileNames);
return \array_unique($fileNames);
}

/**
Expand Down Expand Up @@ -250,12 +251,13 @@ public function mapIssues(DOMNode $element, string $filename): array
protected function getIssueNodes(string $filename): DOMNodeList
{
return $this->issueXml->query(
sprintf('/*/%s/file[@name="%s"]', $this->pluginName, $filename)
\sprintf('/*/%s/file[@name="%s"]', $this->pluginName, $filename)
);
}

/**
* Default method for retrieving the first line of an issue.
*
* @see self::mapIssues
*
* @param DOMElement $element
Expand All @@ -269,6 +271,7 @@ protected function getLineStart(DOMElement $element): int

/**
* Default method for retrieving the last line of an issue.
*
* @see self::mapIssues
*
* @param DOMElement $element
Expand All @@ -282,6 +285,7 @@ protected function getLineEnd(DOMElement $element): int

/**
* Default method for retrieving the source of an issue.
*
* @see self::mapIssues
*
* @return string
Expand All @@ -293,6 +297,7 @@ protected function getSource(): string

/**
* Default method for retrieving the description of an issue.
*
* @see self::mapIssues
*
* @param DOMElement $element
Expand All @@ -301,11 +306,12 @@ protected function getSource(): string
*/
protected function getDescription(DOMElement $element): string
{
return htmlentities($element->getAttribute($this->descriptionAttr));
return \htmlentities($element->getAttribute($this->descriptionAttr));
}

/**
* Default method for retrieving the severity of an issue.
*
* @see self::mapIssues
*
* @param DOMElement $element
Expand All @@ -314,6 +320,6 @@ protected function getDescription(DOMElement $element): string
*/
protected function getSeverity(DOMElement $element): string
{
return htmlentities($element->getAttribute($this->severityAttr));
return \htmlentities($element->getAttribute($this->severityAttr));
}
}
13 changes: 7 additions & 6 deletions src/PHPCodeBrowser/Application.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Application
*
Expand Down Expand Up @@ -36,19 +37,19 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @category PHP_CodeBrowser
* @category PHP_CodeBrowser
*
* @author Robin Gloster <[email protected]>
* @author Robin Gloster <[email protected]>
*
* @copyright 2007-2010 Mayflower GmbH
*
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*
* @version SVN: $Id$
* @version SVN: $Id$
*
* @link http://www.phpunit.de/
* @link http://www.phpunit.de/
*
* @since File available since 1.1
* @since File available since 1.1
*/

namespace PHPCodeBrowser;
Expand Down
Loading

0 comments on commit 17f8bce

Please sign in to comment.