Skip to content

Commit 5554c19

Browse files
authored
Merge pull request #516 from phpmetrics/fix/externals-visitor
Fix/externals visitor
2 parents 40a576a + b6b81af commit 5554c19

File tree

7 files changed

+13
-15
lines changed

7 files changed

+13
-15
lines changed

.semver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
:major: 3
33
:minor: 0
44
:patch: 0
5-
:special: rc6
5+
:special: rc7

artifacts/bintray.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"licenses": ["MIT"]
1111
},
1212
"version": {
13-
"name": "v3.0.0rc6",
13+
"name": "v3.0.0rc7",
1414
"desc": "Latest version of PhpMetrics",
15-
"released": "2024-02-08",
16-
"vcs_tag": "v3.0.0rc6",
15+
"released": "2025-02-04",
16+
"vcs_tag": "v3.0.0rc7",
1717
"attributes": [],
1818
"gpgSign": false
1919
},

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"squizlabs/php_codesniffer": "^3.11",
4545
"symfony/dom-crawler": "^6.4",
4646
"roave/security-advisories": "dev-latest",
47-
"vimeo/psalm": "^6.2"
47+
"vimeo/psalm": "^6.3"
4848
},
4949
"bin": [
5050
"bin/phpmetrics"

qa/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ RUN apk update && \
3535
# Allow phar writing.
3636
echo 'phar.readonly=0' >> ${PHP_INI_DIR}/conf.d/docker-php-phar-readonly.ini && \
3737
# Fetching the PHP Infection from release to fetch.
38-
echo "Looking for the latest PHP Infection 0.29.x version…" && \
39-
RELEASES=$(curl -sS https://api.github.com/repos/infection/infection/releases | jq --compact-output --raw-output 'map(select( .tag_name | test("^0.29.[0-9]+$") ))') && \
38+
echo "Looking for the latest PHP Infection 0.28.x version…" && \
39+
RELEASES=$(curl -sS https://api.github.com/repos/infection/infection/releases | jq --compact-output --raw-output 'map(select( .tag_name | test("^0.28.[0-9]+$") ))') && \
4040
NB_RELEASES=$(echo "${RELEASES}" | jq --compact-output --raw-output 'length') && \
41-
if [ "${NB_RELEASES}" == "0" ]; then echo "ERROR: Not a single patch version found for minor version 0.29 of PHP Infection."; exit 1; fi && \
41+
if [ "${NB_RELEASES}" == "0" ]; then echo "ERROR: Not a single patch version found for minor version 0.28 of PHP Infection."; exit 1; fi && \
4242
LATEST_FOR_MINOR=$(echo "${RELEASES}" | jq --compact-output --raw-output '. | max_by( .tag_name | split(".") | map(tonumber) ) | {tag: .tag_name, src: .assets[]|select(.name == "infection.phar").browser_download_url}') && \
4343
INFECTION_TAG=$(echo "${LATEST_FOR_MINOR}" | jq --compact-output --raw-output '.tag') && \
4444
URL_SRC=$(echo "${LATEST_FOR_MINOR}" | jq --compact-output --raw-output '.src') && \

qa/psalm-baseline.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
</PropertyTypeCoercion>
3636
</file>
3737
<file src="../src/Hal/Metric/Class_/Coupling/ExternalsVisitor.php">
38-
<PossiblyUndefinedArrayOffset>
39-
<code><![CDATA[$resolvedClassName]]></code>
40-
</PossiblyUndefinedArrayOffset>
38+
<PossiblyFalseOperand>
39+
<code><![CDATA[strstr($classNameToResolve, '\\')]]></code>
40+
</PossiblyFalseOperand>
4141
<UndefinedPropertyFetch>
4242
<code><![CDATA[$node->class]]></code>
4343
</UndefinedPropertyFetch>

releases/phpmetrics.phar

150 KB
Binary file not shown.

src/Hal/Metric/Class_/Coupling/ExternalsVisitor.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use PhpParser\NodeVisitorAbstract;
1414
use Stringable;
1515
use function array_map;
16-
use function explode;
1716
use function in_array;
1817
use function ltrim;
1918
use function preg_match_all;
@@ -237,9 +236,8 @@ private function resolveClassName(string $classNameToResolve): null|string
237236
if ($useAlias === $classNameToResolve && !str_contains($classNameToResolve, '\\')) {
238237
return (string)$use->name;
239238
}
240-
[$resolvedAlias, $resolvedClassName] = explode('\\', $classNameToResolve, 2);
241-
if ($useAlias === $resolvedAlias) {
242-
return $use->name . '\\' . $resolvedClassName;
239+
if ($useAlias === strstr($classNameToResolve, '\\', true)) {
240+
return $use->name . strstr($classNameToResolve, '\\');
243241
}
244242
}
245243

0 commit comments

Comments
 (0)