Skip to content

Commit b6f6f97

Browse files
authored
Merge pull request #99 from stronk7/update_dependencies
Update project dependencies
2 parents 25dc417 + 3bf901b commit b6f6f97

File tree

7 files changed

+64
-46
lines changed

7 files changed

+64
-46
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@
5858
"type": "package",
5959
"package": {
6060
"name": "moodlehq/moodle-local_moodlecheck",
61-
"version": "1.0.6",
61+
"version": "1.0.7",
6262
"source": {
6363
"url": "https://github.com/moodlehq/moodle-local_moodlecheck.git",
6464
"type": "git",
65-
"reference": "5edcc27e76081de295a2107681bb88232a828a99"
65+
"reference": "v1.0.7"
6666
}
6767
}
6868
}
@@ -71,7 +71,7 @@
7171
"php": ">=7.0.8",
7272
"moodlehq/moodle-local_codechecker": "^3.0.1",
7373
"moodlehq/moodle-local_ci": "^1.0.9",
74-
"moodlehq/moodle-local_moodlecheck": "^1.0.6",
74+
"moodlehq/moodle-local_moodlecheck": "^1.0.7",
7575
"sebastian/phpcpd": "^3.0",
7676
"phpmd/phpmd": "^2.2",
7777
"symfony/dotenv": "^3.4",
@@ -83,7 +83,7 @@
8383
"php-parallel-lint/php-parallel-lint": "^1.2.0",
8484
"php-parallel-lint/php-console-highlighter": "^0.5",
8585
"psr/log": "^1.0",
86-
"nikic/php-parser": "^3.0",
86+
"nikic/php-parser": "^4.0",
8787
"stecman/symfony-console-completion": "^0.7.0",
8888
"marcj/topsort": "^1.0",
8989
"padraic/phar-updater": "^1.0"

composer.lock

Lines changed: 35 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

psalm-baseline.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,11 @@
7979
<code>$input-&gt;getOption('moodle')</code>
8080
</PossiblyInvalidArgument>
8181
</file>
82+
<file src="src/Parser/StatementFilter.php">
83+
<PossiblyInvalidCast occurrences="3">
84+
<code>$assign-&gt;var-&gt;name</code>
85+
<code>$assign-&gt;var-&gt;name</code>
86+
<code>$var-&gt;name</code>
87+
</PossiblyInvalidCast>
88+
</file>
8289
</files>

src/Bridge/MessDetectorRenderer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public function renderReport(Report $report)
5757
$groupByFile = [];
5858
/** @var RuleViolation $violation */
5959
foreach ($report->getRuleViolations() as $violation) {
60-
$groupByFile[$violation->getFileName()][] = $violation;
60+
if ($filename = $violation->getFileName()) {
61+
$groupByFile[$filename][] = $violation;
62+
}
6163
}
6264

6365
/** @var ProcessingError $error */

src/Command/MessDetectorCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use MoodlePluginCI\Bridge\MessDetectorRenderer;
1616
use PHPMD\PHPMD;
17+
use PHPMD\Report;
1718
use PHPMD\RuleSetFactory;
1819
use PHPMD\Writer\StreamWriter;
1920
use Symfony\Component\Console\Input\InputInterface;
@@ -52,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5253
$ruleSetFactory->setMinimumPriority(5);
5354

5455
$messDetector = new PHPMD();
55-
$messDetector->processFiles(implode(',', $files), $rules, [$renderer], $ruleSetFactory);
56+
$messDetector->processFiles(implode(',', $files), $rules, [$renderer], $ruleSetFactory, new Report());
5657

5758
return 0;
5859
}

src/Parser/StatementFilter.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PhpParser\Node\Expr\Variable;
1919
use PhpParser\Node\Scalar\String_;
2020
use PhpParser\Node\Stmt\Class_;
21+
use PhpParser\Node\Stmt\Expression;
2122
use PhpParser\Node\Stmt\Function_;
2223
use PhpParser\Node\Stmt\Namespace_;
2324

@@ -94,9 +95,15 @@ public function filterNamespaces(array $statements)
9495
*/
9596
public function filterAssignments(array $statements)
9697
{
97-
return array_filter($statements, function ($statement) {
98-
return $statement instanceof Assign;
98+
$stmts = array_filter($statements, function ($statement) {
99+
// Since php-parser 4.0, expression statements are enclosed into
100+
// new Stmt\Expression node, confirm our Assignment is there.
101+
return $statement instanceof Expression && $statement->expr instanceof Assign;
99102
});
103+
// Return the Assignments only.
104+
return array_map(function ($statement) {
105+
return $statement->expr;
106+
}, $stmts);
100107
}
101108

102109
/**
@@ -111,7 +118,7 @@ public function filterAssignments(array $statements)
111118
public function findFirstVariableAssignment(array $statements, $name, $notFoundError = null)
112119
{
113120
foreach ($this->filterAssignments($statements) as $assign) {
114-
if ($assign->var instanceof Variable && $assign->var->name === $name) {
121+
if ($assign->var instanceof Variable && (string) $assign->var->name === $name) {
115122
return $assign;
116123
}
117124
}
@@ -137,11 +144,11 @@ public function findFirstPropertyFetchAssignment(array $statements, $variable, $
137144
if (!$assign->var instanceof PropertyFetch) {
138145
continue;
139146
}
140-
if ($assign->var->name !== $property) {
147+
if ((string) $assign->var->name !== $property) {
141148
continue;
142149
}
143150
$var = $assign->var->var;
144-
if ($var instanceof Variable && $var->name === $variable) {
151+
if ($var instanceof Variable && (string) $var->name === $variable) {
145152
return $assign;
146153
}
147154
}

src/PluginValidate/Finder/FunctionFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function findTokens($file, FileTokens $fileTokens)
2727
$statements = $this->parser->parseFile($file);
2828

2929
foreach ($this->filter->filterFunctions($statements) as $function) {
30-
$fileTokens->compare($function->name);
30+
$fileTokens->compare((string) $function->name);
3131
}
3232
}
3333
}

0 commit comments

Comments
 (0)