1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00

Fix Psalm errors in StringChecker example, add it to psalm.xml

This commit is contained in:
Nicky Robinson 2017-02-09 16:08:53 -05:00
parent 871755ce54
commit cbcd0722d2
2 changed files with 9 additions and 0 deletions

View File

@ -2,6 +2,7 @@
namespace Psalm\Example\Plugin; namespace Psalm\Example\Plugin;
use Psalm\Checker; use Psalm\Checker;
use Psalm\Checker\StatementsChecker;
use Psalm\Context; use Psalm\Context;
use Psalm\CodeLocation; use Psalm\CodeLocation;
@ -17,6 +18,7 @@ class StringChecker extends \Psalm\Plugin
/** /**
* Checks an expression * Checks an expression
* *
* @param StatementsChecker $statements_checker
* @param \PhpParser\Node\Expr $stmt * @param \PhpParser\Node\Expr $stmt
* @param Context $context * @param Context $context
* @param CodeLocation $code_location * @param CodeLocation $code_location
@ -24,6 +26,7 @@ class StringChecker extends \Psalm\Plugin
* @return null|false * @return null|false
*/ */
public function checkExpression( public function checkExpression(
StatementsChecker $statements_checker,
\PhpParser\Node\Expr $stmt, \PhpParser\Node\Expr $stmt,
Context $context, Context $context,
CodeLocation $code_location, CodeLocation $code_location,
@ -36,8 +39,10 @@ class StringChecker extends \Psalm\Plugin
if (preg_match($class_or_class_method, $stmt->value)) { if (preg_match($class_or_class_method, $stmt->value)) {
$fq_class_name = preg_split('/[:]/', $stmt->value)[0]; $fq_class_name = preg_split('/[:]/', $stmt->value)[0];
$file_checker = $statements_checker->getFileChecker();
if (Checker\ClassChecker::checkFullyQualifiedClassLikeName( if (Checker\ClassChecker::checkFullyQualifiedClassLikeName(
$fq_class_name, $fq_class_name,
$file_checker,
$code_location, $code_location,
$suppressed_issues $suppressed_issues
) === false ) === false
@ -48,6 +53,7 @@ class StringChecker extends \Psalm\Plugin
if ($fq_class_name !== $stmt->value) { if ($fq_class_name !== $stmt->value) {
if (Checker\MethodChecker::checkMethodExists( if (Checker\MethodChecker::checkMethodExists(
$stmt->value, $stmt->value,
$file_checker,
$code_location, $code_location,
$suppressed_issues $suppressed_issues
) )

View File

@ -9,9 +9,12 @@
<projectFiles> <projectFiles>
<directory name="src" /> <directory name="src" />
<directory name="tests" /> <directory name="tests" />
<directory name="examples" />
<ignoreFiles> <ignoreFiles>
<file name="src/Psalm/CallMap.php" /> <file name="src/Psalm/CallMap.php" />
<directory name="tests/stubs" /> <directory name="tests/stubs" />
<!-- @todo fix this -->
<file name="examples/TemplateChecker.php" />
</ignoreFiles> </ignoreFiles>
</projectFiles> </projectFiles>