Skip to content

Commit

Permalink
Merge pull request #99 from stronk7/update_dependencies
Browse files Browse the repository at this point in the history
Update project dependencies
  • Loading branch information
kabalin authored May 13, 2021
2 parents 25dc417 + 3bf901b commit b6f6f97
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 46 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
"type": "package",
"package": {
"name": "moodlehq/moodle-local_moodlecheck",
"version": "1.0.6",
"version": "1.0.7",
"source": {
"url": "https://github.com/moodlehq/moodle-local_moodlecheck.git",
"type": "git",
"reference": "5edcc27e76081de295a2107681bb88232a828a99"
"reference": "v1.0.7"
}
}
}
Expand All @@ -71,7 +71,7 @@
"php": ">=7.0.8",
"moodlehq/moodle-local_codechecker": "^3.0.1",
"moodlehq/moodle-local_ci": "^1.0.9",
"moodlehq/moodle-local_moodlecheck": "^1.0.6",
"moodlehq/moodle-local_moodlecheck": "^1.0.7",
"sebastian/phpcpd": "^3.0",
"phpmd/phpmd": "^2.2",
"symfony/dotenv": "^3.4",
Expand All @@ -83,7 +83,7 @@
"php-parallel-lint/php-parallel-lint": "^1.2.0",
"php-parallel-lint/php-console-highlighter": "^0.5",
"psr/log": "^1.0",
"nikic/php-parser": "^3.0",
"nikic/php-parser": "^4.0",
"stecman/symfony-console-completion": "^0.7.0",
"marcj/topsort": "^1.0",
"padraic/phar-updater": "^1.0"
Expand Down
69 changes: 35 additions & 34 deletions composer.lock

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

7 changes: 7 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,11 @@
<code>$input-&gt;getOption('moodle')</code>
</PossiblyInvalidArgument>
</file>
<file src="src/Parser/StatementFilter.php">
<PossiblyInvalidCast occurrences="3">
<code>$assign-&gt;var-&gt;name</code>
<code>$assign-&gt;var-&gt;name</code>
<code>$var-&gt;name</code>
</PossiblyInvalidCast>
</file>
</files>
4 changes: 3 additions & 1 deletion src/Bridge/MessDetectorRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public function renderReport(Report $report)
$groupByFile = [];
/** @var RuleViolation $violation */
foreach ($report->getRuleViolations() as $violation) {
$groupByFile[$violation->getFileName()][] = $violation;
if ($filename = $violation->getFileName()) {
$groupByFile[$filename][] = $violation;
}
}

/** @var ProcessingError $error */
Expand Down
3 changes: 2 additions & 1 deletion src/Command/MessDetectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use MoodlePluginCI\Bridge\MessDetectorRenderer;
use PHPMD\PHPMD;
use PHPMD\Report;
use PHPMD\RuleSetFactory;
use PHPMD\Writer\StreamWriter;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -52,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$ruleSetFactory->setMinimumPriority(5);

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

return 0;
}
Expand Down
17 changes: 12 additions & 5 deletions src/Parser/StatementFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Namespace_;

Expand Down Expand Up @@ -94,9 +95,15 @@ public function filterNamespaces(array $statements)
*/
public function filterAssignments(array $statements)
{
return array_filter($statements, function ($statement) {
return $statement instanceof Assign;
$stmts = array_filter($statements, function ($statement) {
// Since php-parser 4.0, expression statements are enclosed into
// new Stmt\Expression node, confirm our Assignment is there.
return $statement instanceof Expression && $statement->expr instanceof Assign;
});
// Return the Assignments only.
return array_map(function ($statement) {
return $statement->expr;
}, $stmts);
}

/**
Expand All @@ -111,7 +118,7 @@ public function filterAssignments(array $statements)
public function findFirstVariableAssignment(array $statements, $name, $notFoundError = null)
{
foreach ($this->filterAssignments($statements) as $assign) {
if ($assign->var instanceof Variable && $assign->var->name === $name) {
if ($assign->var instanceof Variable && (string) $assign->var->name === $name) {
return $assign;
}
}
Expand All @@ -137,11 +144,11 @@ public function findFirstPropertyFetchAssignment(array $statements, $variable, $
if (!$assign->var instanceof PropertyFetch) {
continue;
}
if ($assign->var->name !== $property) {
if ((string) $assign->var->name !== $property) {
continue;
}
$var = $assign->var->var;
if ($var instanceof Variable && $var->name === $variable) {
if ($var instanceof Variable && (string) $var->name === $variable) {
return $assign;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/PluginValidate/Finder/FunctionFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function findTokens($file, FileTokens $fileTokens)
$statements = $this->parser->parseFile($file);

foreach ($this->filter->filterFunctions($statements) as $function) {
$fileTokens->compare($function->name);
$fileTokens->compare((string) $function->name);
}
}
}

0 comments on commit b6f6f97

Please sign in to comment.