Skip to content

Commit 0266d66

Browse files
committed
Merge branch 'release/1.0.6'
2 parents ffa2361 + 0f313c1 commit 0266d66

27 files changed

+217
-101
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: SonarCloud
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
- feature/*
7+
- feat/*
8+
pull_request:
9+
types: [ opened, synchronize, reopened ]
10+
jobs:
11+
sonarcloud:
12+
name: SonarCloud
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup PHP with Xdebug
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: 7.4
23+
coverage: xdebug
24+
25+
- name: Install dependencies with composer
26+
run: composer update --no-ansi --no-interaction --no-progress
27+
28+
- name: Generate coverage report with phpunit/phpunit
29+
run: vendor/bin/phpunit --coverage-clover coverage.xml --log-junit report.xml
30+
31+
- name: Fix phpunit files paths
32+
run: sed -i 's@'$GITHUB_WORKSPACE/'@''@g' coverage.xml report.xml
33+
34+
- name: SonarCloud Scan
35+
uses: SonarSource/sonarcloud-github-action@master
36+
env:
37+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/sonars.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Sonars
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
- feature/*
7+
- feat/*
8+
- release/*
9+
pull_request:
10+
types: [ opened, synchronize, reopened ]
11+
jobs:
12+
sonarcloud:
13+
name: Sonars
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
statuses: write
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup PHP with Xdebug
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: 7.4
29+
coverage: xdebug
30+
31+
- name: Install dependencies with composer
32+
run: composer update --no-ansi --no-interaction --no-progress
33+
34+
- name: Generate coverage report with phpunit
35+
run: vendor/bin/phpunit --coverage-clover coverage.xml --log-junit report.xml
36+
37+
- name: Monitor coverage
38+
uses: slavcodev/coverage-monitor-action@v1
39+
with:
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
coverage_path: coverage.xml
42+
threshold_alert: 90
43+
threshold_warning: 95
44+
45+
- name: Codecov analyze
46+
uses: codecov/codecov-action@v3
47+
with:
48+
files: coverage.xml
49+
50+
- name: Fix phpunit files paths
51+
run: sed -i 's@'$GITHUB_WORKSPACE/'@''@g' coverage.xml report.xml
52+
53+
- name: SonarCloud Scan
54+
uses: SonarSource/sonarcloud-github-action@master
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 1.0.6 - 2024/12/10
4+
- Add Sonar tools
5+
- Minor type hinting
6+
37
## 1.0.5 - 2022/03/24
48
- Update PHP CS Fixer and corresponding setting file
59
- Add PHPStan

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.4'
2-
31
services:
42
php:
53
build:

phpunit.xml.dist

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="vendor/autoload.php"
8+
>
39
<coverage>
410
<include>
5-
<directory>./</directory>
11+
<directory suffix=".php">./src</directory>
612
</include>
7-
<exclude>
8-
<directory>./tests</directory>
9-
<directory>./vendor</directory>
10-
</exclude>
1113
</coverage>
1214
<php>
1315
<ini name="error_reporting" value="-1"/>

sonar-project.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
sonar.projectKey=WsdlToPhp_WsdlHandler
2+
sonar.organization=wsdltophp
3+
sonar.php.coverage.reportPaths=coverage.xml
4+
sonar.php.tests.reportPath=report.xml
5+
6+
sonar.sources=src/
7+
sonar.tests=tests/

src/AbstractDocument.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace WsdlToPhp\WsdlHandler;
66

7-
use DOMElement;
87
use WsdlToPhp\DomHandler\AbstractDomDocumentHandler;
98
use WsdlToPhp\DomHandler\DomDocumentHandler;
109
use WsdlToPhp\DomHandler\ElementHandler;
@@ -83,7 +82,7 @@ public function getAttributeTargetNamespaceValue(): string
8382
return $namespace;
8483
}
8584

86-
protected function getElementHandler(DOMElement $element, AbstractDomDocumentHandler $domDocument, int $index = -1): ElementHandler
85+
protected function getElementHandler(\DOMElement $element, AbstractDomDocumentHandler $domDocument, int $index = -1): ElementHandler
8786
{
8887
$handlerName = Tag::class;
8988
if (class_exists($elementNameClass = sprintf('%s\Tag\Tag%s', __NAMESPACE__, ucfirst(implode('', array_slice(explode(':', $element->nodeName), -1, 1)))))) {

src/Tag/AbstractTag.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace WsdlToPhp\WsdlHandler\Tag;
66

7-
use DOMElement;
87
use WsdlToPhp\DomHandler\AbstractAttributeHandler as Attribute;
98
use WsdlToPhp\DomHandler\AbstractNodeHandler;
109
use WsdlToPhp\DomHandler\ElementHandler;
@@ -31,10 +30,10 @@ public function getSuitableParent(bool $checkName = true, array $additionalTags
3130
if ($this->getParent() instanceof AbstractNodeHandler) {
3231
$parentTags = $strict ? $additionalTags : $this->getSuitableParentTags($additionalTags);
3332
$parentNode = $this->getParent()->getNode();
34-
while ($maxDeep-- > 0 && ($parentNode instanceof DOMElement) && !empty($parentNode->nodeName) && (!preg_match('/'.implode('|', $parentTags).'/i', $parentNode->nodeName) || ($checkName && preg_match('/'.implode('|', $parentTags).'/i', $parentNode->nodeName) && (!$parentNode->hasAttribute('name') || '' === $parentNode->getAttribute('name'))))) {
33+
while ($maxDeep-- > 0 && ($parentNode instanceof \DOMElement) && !empty($parentNode->nodeName) && (!preg_match('/'.implode('|', $parentTags).'/i', $parentNode->nodeName) || ($checkName && preg_match('/'.implode('|', $parentTags).'/i', $parentNode->nodeName) && (!$parentNode->hasAttribute('name') || '' === $parentNode->getAttribute('name'))))) {
3534
$parentNode = $parentNode->parentNode;
3635
}
37-
if ($parentNode instanceof DOMElement) {
36+
if ($parentNode instanceof \DOMElement) {
3837
$parentNode = $this->getDomDocumentHandler()->getHandler($parentNode);
3938
} else {
4039
$parentNode = null;

src/Wsdl.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace WsdlToPhp\WsdlHandler;
66

7-
use DOMNode;
87
use WsdlToPhp\WsdlHandler\Tag\AbstractTag;
98

109
class Wsdl extends AbstractDocument
@@ -45,7 +44,7 @@ public function getElementsByName(string $name, bool $includeExternals = false):
4544
], $includeExternals);
4645
}
4746

48-
public function getElementsByNameAndAttributes(string $name, array $attributes, ?DOMNode $node = null, bool $includeExternals = false): array
47+
public function getElementsByNameAndAttributes(string $name, array $attributes, ?\DOMNode $node = null, bool $includeExternals = false): array
4948
{
5049
if ($includeExternals) {
5150
$elements = $this->useParentMethodAndExternals(__FUNCTION__, [
@@ -92,7 +91,7 @@ protected function useParentMethodAndExternals(string $method, array $parameters
9291
return $result;
9392
}
9493

95-
protected function useExternalSchemas(string $method, array $parameters, $parentResult, bool $returnOne = false)
94+
protected function useExternalSchemas(string $method, array $parameters, ?array $parentResult, bool $returnOne = false)
9695
{
9796
$result = $parentResult;
9897

tests/AbstractTestCase.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace WsdlToPhp\WsdlHandler\Tests;
66

7-
use DOMDocument;
87
use PHPUnit\Framework\TestCase as PHPUnitFrameworkTestCase;
98
use WsdlToPhp\WsdlHandler\Schema;
109
use WsdlToPhp\WsdlHandler\Wsdl;
@@ -210,9 +209,9 @@ public static function wsdlUnitTestInstance(): Wsdl
210209

211210
public static function getWsdl(string $wsdlPath, bool $addExternalSchemas = true): Wsdl
212211
{
213-
$wsdlKey = sprintf('%s_%s', $wsdlPath, ((int) $addExternalSchemas));
212+
$wsdlKey = sprintf('%s_%s', $wsdlPath, (int) $addExternalSchemas);
214213
if (!array_key_exists($wsdlKey, self::$instances)) {
215-
$doc = new DOMDocument('1.0', 'utf-8');
214+
$doc = new \DOMDocument('1.0', 'utf-8');
216215
$doc->load($wsdlPath);
217216
self::$instances[$wsdlKey] = new Wsdl($doc);
218217
}
@@ -223,7 +222,7 @@ public static function getWsdl(string $wsdlPath, bool $addExternalSchemas = true
223222
public static function getSchema(string $schemaPath): Schema
224223
{
225224
if (!array_key_exists($schemaPath, self::$instances)) {
226-
$doc = new DOMDocument('1.0', 'utf-8');
225+
$doc = new \DOMDocument('1.0', 'utf-8');
227226
$doc->load($schemaPath);
228227
self::$instances[$schemaPath] = new Schema($doc);
229228
}

0 commit comments

Comments
 (0)