mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Import instead of using fqn exceptions
This commit is contained in:
parent
245920e53c
commit
711be643c6
@ -78,7 +78,7 @@
|
||||
-->
|
||||
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
|
||||
<properties>
|
||||
<property name="allowFullyQualifiedExceptions" type="bool" value="true"/>
|
||||
<property name="allowFullyQualifiedExceptions" type="bool" value="false"/>
|
||||
<property name="allowFullyQualifiedGlobalFunctions" type="bool" value="true"/>
|
||||
<property name="allowFullyQualifiedGlobalConstants" type="bool" value="true"/>
|
||||
<property name="allowFullyQualifiedGlobalClasses" type="bool" value="true"/>
|
||||
|
@ -11,6 +11,7 @@ use LanguageServerProtocol\Range;
|
||||
use LanguageServerProtocol\SignatureInformation;
|
||||
use LanguageServerProtocol\TextEdit;
|
||||
use PhpParser;
|
||||
use Psalm\Exception\UnanalyzedFileException;
|
||||
use Psalm\Internal\Analyzer\NamespaceAnalyzer;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Block\ForeachAnalyzer;
|
||||
@ -1196,7 +1197,7 @@ class Codebase
|
||||
$is_open = $this->file_provider->isOpen($file_path);
|
||||
|
||||
if (!$is_open) {
|
||||
throw new \Psalm\Exception\UnanalyzedFileException($file_path . ' is not open');
|
||||
throw new UnanalyzedFileException($file_path . ' is not open');
|
||||
}
|
||||
|
||||
$file_contents = $this->getFileContents($file_path);
|
||||
@ -1249,7 +1250,7 @@ class Codebase
|
||||
$is_open = $this->file_provider->isOpen($file_path);
|
||||
|
||||
if (!$is_open) {
|
||||
throw new \Psalm\Exception\UnanalyzedFileException($file_path . ' is not open');
|
||||
throw new UnanalyzedFileException($file_path . ' is not open');
|
||||
}
|
||||
|
||||
$file_contents = $this->getFileContents($file_path);
|
||||
@ -1385,7 +1386,7 @@ class Codebase
|
||||
$is_open = $this->file_provider->isOpen($file_path);
|
||||
|
||||
if (!$is_open) {
|
||||
throw new \Psalm\Exception\UnanalyzedFileException($file_path . ' is not open');
|
||||
throw new UnanalyzedFileException($file_path . ' is not open');
|
||||
}
|
||||
|
||||
$file_contents = $this->getFileContents($file_path);
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Psalm\Config;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Exception\ConfigException;
|
||||
use SimpleXMLElement;
|
||||
|
||||
use function in_array;
|
||||
@ -27,10 +28,10 @@ class ErrorLevelFileFilter extends FileFilter
|
||||
$filter->error_level = (string) $config['type'];
|
||||
|
||||
if (!in_array($filter->error_level, Config::$ERROR_LEVELS, true)) {
|
||||
throw new \Psalm\Exception\ConfigException('Unexpected error level ' . $filter->error_level);
|
||||
throw new ConfigException('Unexpected error level ' . $filter->error_level);
|
||||
}
|
||||
} else {
|
||||
throw new \Psalm\Exception\ConfigException('<type> element expects a level');
|
||||
throw new ConfigException('<type> element expects a level');
|
||||
}
|
||||
|
||||
return $filter;
|
||||
@ -50,10 +51,10 @@ class ErrorLevelFileFilter extends FileFilter
|
||||
$filter->error_level = (string) $e['type'];
|
||||
|
||||
if (!in_array($filter->error_level, Config::$ERROR_LEVELS, true)) {
|
||||
throw new \Psalm\Exception\ConfigException('Unexpected error level ' . $filter->error_level);
|
||||
throw new ConfigException('Unexpected error level ' . $filter->error_level);
|
||||
}
|
||||
} else {
|
||||
throw new \Psalm\Exception\ConfigException('<type> element expects a level');
|
||||
throw new ConfigException('<type> element expects a level');
|
||||
}
|
||||
|
||||
return $filter;
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Psalm\Config;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Exception\ConfigException;
|
||||
use SimpleXMLElement;
|
||||
|
||||
use function array_filter;
|
||||
@ -34,7 +35,7 @@ class IssueHandler
|
||||
$handler->error_level = (string) $e['errorLevel'];
|
||||
|
||||
if (!in_array($handler->error_level, Config::$ERROR_LEVELS, true)) {
|
||||
throw new \Psalm\Exception\ConfigException('Unexpected error level ' . $handler->error_level);
|
||||
throw new ConfigException('Unexpected error level ' . $handler->error_level);
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +58,7 @@ class IssueHandler
|
||||
public function setErrorLevel(string $error_level): void
|
||||
{
|
||||
if (!in_array($error_level, Config::$ERROR_LEVELS, true)) {
|
||||
throw new \Psalm\Exception\ConfigException('Unexpected error level ' . $error_level);
|
||||
throw new ConfigException('Unexpected error level ' . $error_level);
|
||||
}
|
||||
|
||||
$this->error_level = $error_level;
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Psalm\Config;
|
||||
|
||||
use Psalm\Exception\ConfigException;
|
||||
use SimpleXMLElement;
|
||||
|
||||
use function stripos;
|
||||
@ -25,7 +26,7 @@ class ProjectFileFilter extends FileFilter
|
||||
|
||||
if (isset($e->ignoreFiles)) {
|
||||
if (!$inclusive) {
|
||||
throw new \Psalm\Exception\ConfigException('Cannot nest ignoreFiles inside itself');
|
||||
throw new ConfigException('Cannot nest ignoreFiles inside itself');
|
||||
}
|
||||
|
||||
/** @var \SimpleXMLElement $e->ignoreFiles */
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Internal\Analyzer;
|
||||
|
||||
use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Exception\ComplicatedExpressionException;
|
||||
use Psalm\Internal\Algebra;
|
||||
use Psalm\Internal\Clause;
|
||||
use Psalm\Issue\ParadoxicalCondition;
|
||||
@ -40,7 +41,7 @@ class AlgebraAnalyzer
|
||||
): void {
|
||||
try {
|
||||
$negated_formula2 = Algebra::negateFormula($formula_2);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ use Amp\Loop;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\RefactorException;
|
||||
use Psalm\Exception\UnsupportedIssueToFixException;
|
||||
use Psalm\FileManipulation;
|
||||
use Psalm\Internal\Codebase\TaintFlowGraph;
|
||||
@ -735,14 +736,14 @@ class ProjectAnalyzer
|
||||
$destination_parts = explode('::', $destination);
|
||||
|
||||
if (!$this->codebase->classlikes->hasFullyQualifiedClassName($source_parts[0])) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Source class ' . $source_parts[0] . ' doesn’t exist'
|
||||
);
|
||||
}
|
||||
|
||||
if (count($source_parts) === 1 && count($destination_parts) === 1) {
|
||||
if ($this->codebase->classlikes->hasFullyQualifiedClassName($destination_parts[0])) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Destination class ' . $destination_parts[0] . ' already exists'
|
||||
);
|
||||
}
|
||||
@ -784,13 +785,13 @@ class ProjectAnalyzer
|
||||
strtolower($destination_parts[1])
|
||||
)
|
||||
)) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Destination method ' . $destination . ' already exists'
|
||||
);
|
||||
}
|
||||
|
||||
if (!$this->codebase->classlikes->classExists($destination_parts[0])) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Destination class ' . $destination_parts[0] . ' doesn’t exist'
|
||||
);
|
||||
}
|
||||
@ -806,7 +807,7 @@ class ProjectAnalyzer
|
||||
$destination_class_storage->parent_classes[strtolower($source_method_id->fq_class_name)]
|
||||
)
|
||||
) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Cannot move non-static method ' . $source
|
||||
. ' into unrelated class ' . $destination_parts[0]
|
||||
);
|
||||
@ -823,25 +824,25 @@ class ProjectAnalyzer
|
||||
|
||||
if ($source_parts[1][0] === '$') {
|
||||
if ($destination_parts[1][0] !== '$') {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Destination property must be of the form Foo::$bar'
|
||||
);
|
||||
}
|
||||
|
||||
if (!$this->codebase->properties->propertyExists($source, true)) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Property ' . $source . ' does not exist'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->codebase->properties->propertyExists($destination, true)) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Destination property ' . $destination . ' already exists'
|
||||
);
|
||||
}
|
||||
|
||||
if (!$this->codebase->classlikes->classExists($destination_parts[0])) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Destination class ' . $destination_parts[0] . ' doesn’t exist'
|
||||
);
|
||||
}
|
||||
@ -852,7 +853,7 @@ class ProjectAnalyzer
|
||||
$source_storage = $this->codebase->properties->getStorage($source);
|
||||
|
||||
if (!$source_storage->is_static) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Cannot move non-static property ' . $source
|
||||
);
|
||||
}
|
||||
@ -873,7 +874,7 @@ class ProjectAnalyzer
|
||||
|
||||
if (isset($source_class_constants[$source_parts[1]])) {
|
||||
if (!$this->codebase->classlikes->hasFullyQualifiedClassName($destination_parts[0])) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Destination class ' . $destination_parts[0] . ' doesn’t exist'
|
||||
);
|
||||
}
|
||||
@ -884,7 +885,7 @@ class ProjectAnalyzer
|
||||
);
|
||||
|
||||
if (isset($destination_class_constants[$destination_parts[1]])) {
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Destination constant ' . $destination . ' already exists'
|
||||
);
|
||||
}
|
||||
@ -901,7 +902,7 @@ class ProjectAnalyzer
|
||||
continue;
|
||||
}
|
||||
|
||||
throw new \Psalm\Exception\RefactorException(
|
||||
throw new RefactorException(
|
||||
'Psalm cannot locate ' . $source
|
||||
);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\ScopeAnalysisException;
|
||||
use Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer;
|
||||
use Psalm\Internal\Analyzer\StatementsAnalyzer;
|
||||
use Psalm\Internal\Clause;
|
||||
@ -116,7 +117,7 @@ class IfConditionalAnalyzer
|
||||
$externally_applied_if_cond_expr,
|
||||
$outer_context
|
||||
) === false) {
|
||||
throw new \Psalm\Exception\ScopeAnalysisException();
|
||||
throw new ScopeAnalysisException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +165,7 @@ class IfConditionalAnalyzer
|
||||
$if_conditional_context->inside_conditional = true;
|
||||
|
||||
if (ExpressionAnalyzer::analyze($statements_analyzer, $cond, $if_conditional_context) === false) {
|
||||
throw new \Psalm\Exception\ScopeAnalysisException();
|
||||
throw new ScopeAnalysisException();
|
||||
}
|
||||
|
||||
$if_conditional_context->inside_conditional = false;
|
||||
|
@ -5,6 +5,8 @@ use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\ComplicatedExpressionException;
|
||||
use Psalm\Exception\ScopeAnalysisException;
|
||||
use Psalm\Internal\Algebra;
|
||||
use Psalm\Internal\Algebra\FormulaGenerator;
|
||||
use Psalm\Internal\Analyzer\AlgebraAnalyzer;
|
||||
@ -62,7 +64,7 @@ class ElseIfAnalyzer
|
||||
$cond_referenced_var_ids = $if_conditional_scope->cond_referenced_var_ids;
|
||||
$assigned_in_conditional_var_ids = $if_conditional_scope->assigned_in_conditional_var_ids;
|
||||
$entry_clauses = $if_conditional_scope->entry_clauses;
|
||||
} catch (\Psalm\Exception\ScopeAnalysisException $e) {
|
||||
} catch (ScopeAnalysisException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -191,7 +193,7 @@ class ElseIfAnalyzer
|
||||
$negated_elseif_types = Algebra::getTruthsFromFormula(
|
||||
Algebra::negateFormula($elseif_clauses)
|
||||
);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
$reconcilable_elseif_types = [];
|
||||
$negated_elseif_types = [];
|
||||
}
|
||||
@ -424,7 +426,7 @@ class ElseIfAnalyzer
|
||||
Algebra::negateFormula($elseif_clauses)
|
||||
)
|
||||
);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
$if_scope->negated_clauses = [];
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ namespace Psalm\Internal\Analyzer\Statements\Block;
|
||||
use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\ComplicatedExpressionException;
|
||||
use Psalm\Exception\ScopeAnalysisException;
|
||||
use Psalm\Internal\Algebra;
|
||||
use Psalm\Internal\Algebra\FormulaGenerator;
|
||||
use Psalm\Internal\Analyzer\AlgebraAnalyzer;
|
||||
@ -103,7 +105,7 @@ class IfElseAnalyzer
|
||||
$post_if_context = $if_conditional_scope->post_if_context;
|
||||
$cond_referenced_var_ids = $if_conditional_scope->cond_referenced_var_ids;
|
||||
$assigned_in_conditional_var_ids = $if_conditional_scope->assigned_in_conditional_var_ids;
|
||||
} catch (\Psalm\Exception\ScopeAnalysisException $e) {
|
||||
} catch (ScopeAnalysisException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -198,7 +200,7 @@ class IfElseAnalyzer
|
||||
|
||||
try {
|
||||
$if_scope->negated_clauses = Algebra::negateFormula($if_clauses);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
try {
|
||||
$if_scope->negated_clauses = FormulaGenerator::getFormula(
|
||||
$cond_object_id,
|
||||
@ -209,7 +211,7 @@ class IfElseAnalyzer
|
||||
$codebase,
|
||||
false
|
||||
);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
$if_scope->negated_clauses = [];
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\ComplicatedExpressionException;
|
||||
use Psalm\Internal\Algebra;
|
||||
use Psalm\Internal\Algebra\FormulaGenerator;
|
||||
use Psalm\Internal\Analyzer\ScopeAnalyzer;
|
||||
@ -494,7 +495,7 @@ class LoopAnalyzer
|
||||
|
||||
try {
|
||||
$negated_pre_condition_clauses = Algebra::negateFormula(array_merge(...$pre_condition_clauses));
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
$negated_pre_condition_clauses = [];
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\ComplicatedExpressionException;
|
||||
use Psalm\Internal\Algebra;
|
||||
use Psalm\Internal\Algebra\FormulaGenerator;
|
||||
use Psalm\Internal\Analyzer\AlgebraAnalyzer;
|
||||
@ -431,7 +432,7 @@ class SwitchCaseAnalyzer
|
||||
if ($case_clauses && $case_equality_expr) {
|
||||
try {
|
||||
$negated_case_clauses = Algebra::negateFormula($case_clauses);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
$case_equality_expr_id = \spl_object_id($case_equality_expr);
|
||||
|
||||
try {
|
||||
@ -445,7 +446,7 @@ class SwitchCaseAnalyzer
|
||||
false,
|
||||
false
|
||||
);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
$negated_case_clauses = [];
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ namespace Psalm\Internal\Analyzer\Statements\Expression\BinaryOp;
|
||||
use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\ComplicatedExpressionException;
|
||||
use Psalm\Exception\ScopeAnalysisException;
|
||||
use Psalm\Internal\Algebra;
|
||||
use Psalm\Internal\Algebra\FormulaGenerator;
|
||||
use Psalm\Internal\Analyzer\Statements\Block\IfConditionalAnalyzer;
|
||||
@ -81,7 +83,7 @@ class OrAnalyzer
|
||||
if ($stmt->left instanceof PhpParser\Node\Expr\BinaryOp\BooleanOr) {
|
||||
$post_leaving_if_context = clone $context;
|
||||
}
|
||||
} catch (\Psalm\Exception\ScopeAnalysisException $e) {
|
||||
} catch (ScopeAnalysisException $e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -139,7 +141,7 @@ class OrAnalyzer
|
||||
|
||||
try {
|
||||
$negated_left_clauses = Algebra::negateFormula($left_clauses);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
try {
|
||||
$negated_left_clauses = FormulaGenerator::getFormula(
|
||||
$left_cond_id,
|
||||
@ -150,7 +152,7 @@ class OrAnalyzer
|
||||
$codebase,
|
||||
false
|
||||
);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace Psalm\Internal\Analyzer\Statements\Expression\Fetch;
|
||||
use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CircularReferenceException;
|
||||
use Psalm\FileManipulation;
|
||||
use Psalm\Internal\Analyzer\ClassLikeAnalyzer;
|
||||
use Psalm\Internal\Analyzer\ClassLikeNameOptions;
|
||||
@ -234,7 +235,7 @@ class ClassConstFetchAnalyzer
|
||||
);
|
||||
} catch (\InvalidArgumentException $_) {
|
||||
return true;
|
||||
} catch (\Psalm\Exception\CircularReferenceException $e) {
|
||||
} catch (CircularReferenceException $e) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new CircularReference(
|
||||
'Constant ' . $const_id . ' contains a circular reference',
|
||||
@ -521,7 +522,7 @@ class ClassConstFetchAnalyzer
|
||||
);
|
||||
} catch (\InvalidArgumentException $_) {
|
||||
return true;
|
||||
} catch (\Psalm\Exception\CircularReferenceException $e) {
|
||||
} catch (CircularReferenceException $e) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new CircularReference(
|
||||
'Constant ' . $const_id . ' contains a circular reference',
|
||||
|
@ -6,6 +6,7 @@ use Psalm\CodeLocation;
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\FileIncludeException;
|
||||
use Psalm\Exception\UnpreparedAnalysisException;
|
||||
use Psalm\Internal\Analyzer\FileAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer;
|
||||
use Psalm\Internal\Analyzer\StatementsAnalyzer;
|
||||
@ -202,7 +203,7 @@ class IncludeAnalyzer
|
||||
$context,
|
||||
$global_context
|
||||
);
|
||||
} catch (\Psalm\Exception\UnpreparedAnalysisException $e) {
|
||||
} catch (UnpreparedAnalysisException $e) {
|
||||
if ($config->skip_checks_on_unresolvable_includes) {
|
||||
$context->check_classes = false;
|
||||
$context->check_variables = false;
|
||||
|
@ -4,6 +4,7 @@ namespace Psalm\Internal\Analyzer\Statements\Expression;
|
||||
use PhpParser;
|
||||
use Psalm\Aliases;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Exception\CircularReferenceException;
|
||||
use Psalm\FileSource;
|
||||
use Psalm\Internal\Analyzer\ClassLikeAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\BinaryOp\ArithmeticOpAnalyzer;
|
||||
@ -286,7 +287,7 @@ class SimpleTypeInferer
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (\InvalidArgumentException | \Psalm\Exception\CircularReferenceException $e) {
|
||||
} catch (\InvalidArgumentException | CircularReferenceException $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace Psalm\Internal\Analyzer\Statements\Expression;
|
||||
use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\ScopeAnalysisException;
|
||||
use Psalm\Internal\Algebra;
|
||||
use Psalm\Internal\Algebra\FormulaGenerator;
|
||||
use Psalm\Internal\Analyzer\AlgebraAnalyzer;
|
||||
@ -54,7 +55,7 @@ class TernaryAnalyzer
|
||||
|
||||
$cond_referenced_var_ids = $if_conditional_scope->cond_referenced_var_ids;
|
||||
$assigned_in_conditional_var_ids = $if_conditional_scope->assigned_in_conditional_var_ids;
|
||||
} catch (\Psalm\Exception\ScopeAnalysisException $e) {
|
||||
} catch (ScopeAnalysisException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\DocblockParseException;
|
||||
use Psalm\Exception\IncorrectDocblockException;
|
||||
use Psalm\Internal\Analyzer\CommentAnalyzer;
|
||||
use Psalm\Internal\Analyzer\StatementsAnalyzer;
|
||||
use Psalm\Internal\ReferenceConstraint;
|
||||
@ -60,7 +61,7 @@ class StaticAnalyzer
|
||||
$statements_analyzer->getSource()->getAliases(),
|
||||
$statements_analyzer->getSource()->getTemplateTypeMap()
|
||||
);
|
||||
} catch (\Psalm\Exception\IncorrectDocblockException $e) {
|
||||
} catch (IncorrectDocblockException $e) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new MissingDocblockType(
|
||||
$e->getMessage(),
|
||||
|
@ -7,6 +7,7 @@ use Psalm\Codebase;
|
||||
use Psalm\Context;
|
||||
use Psalm\DocComment;
|
||||
use Psalm\Exception\DocblockParseException;
|
||||
use Psalm\Exception\IncorrectDocblockException;
|
||||
use Psalm\FileManipulation;
|
||||
use Psalm\Internal\Analyzer\Statements\Block\DoAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Block\ForAnalyzer;
|
||||
@ -458,14 +459,14 @@ class StatementsAnalyzer extends SourceAnalyzer
|
||||
$template_type_map,
|
||||
$file_storage->type_aliases
|
||||
);
|
||||
} catch (\Psalm\Exception\IncorrectDocblockException $e) {
|
||||
} catch (IncorrectDocblockException $e) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new MissingDocblockType(
|
||||
$e->getMessage(),
|
||||
new CodeLocation($statements_analyzer->getSource(), $stmt)
|
||||
)
|
||||
);
|
||||
} catch (\Psalm\Exception\DocblockParseException $e) {
|
||||
} catch (DocblockParseException $e) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new InvalidDocblock(
|
||||
$e->getMessage(),
|
||||
|
@ -6,6 +6,7 @@ use Composer\Autoload\ClassLoader;
|
||||
use Psalm\Config;
|
||||
use Psalm\Config\Creator;
|
||||
use Psalm\ErrorBaseline;
|
||||
use Psalm\Exception\ConfigCreationException;
|
||||
use Psalm\Exception\ConfigException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\CliUtils;
|
||||
@ -531,7 +532,7 @@ final class Psalm
|
||||
$init_level,
|
||||
$vendor_dir
|
||||
);
|
||||
} catch (\Psalm\Exception\ConfigCreationException $e) {
|
||||
} catch (ConfigCreationException $e) {
|
||||
die($e->getMessage() . PHP_EOL);
|
||||
}
|
||||
|
||||
@ -565,7 +566,7 @@ final class Psalm
|
||||
$config_level = (int) $options['error-level'];
|
||||
|
||||
if (!in_array($config_level, [1, 2, 3, 4, 5, 6, 7, 8], true)) {
|
||||
throw new \Psalm\Exception\ConfigException(
|
||||
throw new ConfigException(
|
||||
'Invalid error level ' . $config_level
|
||||
);
|
||||
}
|
||||
@ -645,7 +646,7 @@ final class Psalm
|
||||
new FileProvider,
|
||||
$options['set-baseline']
|
||||
);
|
||||
} catch (\Psalm\Exception\ConfigException $e) {
|
||||
} catch (ConfigException $e) {
|
||||
$issue_baseline = [];
|
||||
}
|
||||
|
||||
@ -701,7 +702,7 @@ final class Psalm
|
||||
echo str_repeat('-', 30) . "\n";
|
||||
echo $total_fixed_issues . ' errors fixed' . "\n";
|
||||
}
|
||||
} catch (\Psalm\Exception\ConfigException $exception) {
|
||||
} catch (ConfigException $exception) {
|
||||
fwrite(STDERR, 'Could not update baseline file: ' . $exception->getMessage() . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
@ -768,7 +769,7 @@ final class Psalm
|
||||
$init_level,
|
||||
$vendor_dir
|
||||
);
|
||||
} catch (\Psalm\Exception\ConfigCreationException $e) {
|
||||
} catch (ConfigCreationException $e) {
|
||||
die($e->getMessage() . PHP_EOL);
|
||||
}
|
||||
|
||||
@ -1049,7 +1050,7 @@ final class Psalm
|
||||
new FileProvider,
|
||||
$baseline_file_path
|
||||
);
|
||||
} catch (\Psalm\Exception\ConfigException $exception) {
|
||||
} catch (ConfigException $exception) {
|
||||
fwrite(STDERR, 'Error while reading baseline: ' . $exception->getMessage() . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace Psalm\Internal\Cli;
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Composer\XdebugHandler\XdebugHandler;
|
||||
use Psalm\Config;
|
||||
use Psalm\Exception\UnsupportedIssueToFixException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\CliUtils;
|
||||
use Psalm\Internal\Composer;
|
||||
@ -376,7 +377,7 @@ HELP;
|
||||
} else {
|
||||
try {
|
||||
$project_analyzer->setIssuesToFix($keyed_issues);
|
||||
} catch (\Psalm\Exception\UnsupportedIssueToFixException $e) {
|
||||
} catch (UnsupportedIssueToFixException $e) {
|
||||
fwrite(STDERR, $e->getMessage() . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ use PackageVersions\Versions;
|
||||
use Phar;
|
||||
use Psalm\Config;
|
||||
use Psalm\Config\Creator;
|
||||
use Psalm\Exception\ConfigException;
|
||||
use Psalm\Exception\ConfigNotFoundException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\Composer;
|
||||
use Psalm\Report;
|
||||
@ -496,7 +498,7 @@ HELP;
|
||||
} else {
|
||||
try {
|
||||
$config = Config::getConfigForPath($current_dir, $current_dir);
|
||||
} catch (\Psalm\Exception\ConfigNotFoundException $e) {
|
||||
} catch (ConfigNotFoundException $e) {
|
||||
if (!$create_if_non_existent) {
|
||||
if (in_array($output_format, [Report::TYPE_CONSOLE, Report::TYPE_PHP_STORM])) {
|
||||
fwrite(
|
||||
@ -517,7 +519,7 @@ HELP;
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (\Psalm\Exception\ConfigException $e) {
|
||||
} catch (ConfigException $e) {
|
||||
fwrite(
|
||||
STDERR,
|
||||
$e->getMessage() . PHP_EOL
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Psalm\Internal\Codebase;
|
||||
|
||||
use Psalm\Exception\CircularReferenceException;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\Fetch\ConstFetchAnalyzer;
|
||||
use Psalm\Internal\Analyzer\StatementsAnalyzer;
|
||||
use Psalm\Internal\Scanner\UnresolvedConstant;
|
||||
@ -24,7 +25,7 @@ class ConstantTypeResolver
|
||||
$c_id = \spl_object_id($c);
|
||||
|
||||
if (isset($visited_constant_ids[$c_id])) {
|
||||
throw new \Psalm\Exception\CircularReferenceException('Found a circular reference');
|
||||
throw new CircularReferenceException('Found a circular reference');
|
||||
}
|
||||
|
||||
if ($c instanceof UnresolvedConstant\ScalarValue) {
|
||||
|
@ -17,6 +17,7 @@ use LanguageServerProtocol\TextDocumentIdentifier;
|
||||
use LanguageServerProtocol\TextDocumentItem;
|
||||
use LanguageServerProtocol\VersionedTextDocumentIdentifier;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Exception\UnanalyzedFileException;
|
||||
use Psalm\Internal\LanguageServer\LanguageServer;
|
||||
|
||||
use function count;
|
||||
@ -165,7 +166,7 @@ class TextDocument
|
||||
|
||||
try {
|
||||
$reference_location = $this->codebase->getReferenceAtPosition($file_path, $position);
|
||||
} catch (\Psalm\Exception\UnanalyzedFileException $e) {
|
||||
} catch (UnanalyzedFileException $e) {
|
||||
$this->codebase->file_provider->openFile($file_path);
|
||||
$this->server->queueFileAnalysis($file_path, $textDocument->uri);
|
||||
|
||||
@ -209,7 +210,7 @@ class TextDocument
|
||||
|
||||
try {
|
||||
$reference_location = $this->codebase->getReferenceAtPosition($file_path, $position);
|
||||
} catch (\Psalm\Exception\UnanalyzedFileException $e) {
|
||||
} catch (UnanalyzedFileException $e) {
|
||||
$this->codebase->file_provider->openFile($file_path);
|
||||
$this->server->queueFileAnalysis($file_path, $textDocument->uri);
|
||||
|
||||
@ -265,7 +266,7 @@ class TextDocument
|
||||
|
||||
try {
|
||||
$completion_data = $this->codebase->getCompletionDataAtPosition($file_path, $position);
|
||||
} catch (\Psalm\Exception\UnanalyzedFileException $e) {
|
||||
} catch (UnanalyzedFileException $e) {
|
||||
$this->codebase->file_provider->openFile($file_path);
|
||||
$this->server->queueFileAnalysis($file_path, $textDocument->uri);
|
||||
|
||||
@ -311,7 +312,7 @@ class TextDocument
|
||||
|
||||
try {
|
||||
$argument_location = $this->codebase->getFunctionArgumentAtPosition($file_path, $position);
|
||||
} catch (\Psalm\Exception\UnanalyzedFileException $e) {
|
||||
} catch (UnanalyzedFileException $e) {
|
||||
$this->codebase->file_provider->openFile($file_path);
|
||||
$this->server->queueFileAnalysis($file_path, $textDocument->uri);
|
||||
|
||||
|
@ -11,6 +11,7 @@ use Psalm\Aliases;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Config;
|
||||
use Psalm\Exception\ComplicatedExpressionException;
|
||||
use Psalm\Exception\DocblockParseException;
|
||||
use Psalm\Exception\IncorrectDocblockException;
|
||||
use Psalm\Internal\Algebra;
|
||||
@ -311,7 +312,7 @@ class FunctionLikeNodeScanner
|
||||
|
||||
try {
|
||||
$negated_formula = Algebra::negateFormula($if_clauses);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
$var_assertions = [];
|
||||
break;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use PhpParser;
|
||||
use Psalm\Aliases;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Exception\DocblockParseException;
|
||||
use Psalm\Exception\TypeParseTreeException;
|
||||
use Psalm\FileSource;
|
||||
@ -573,7 +574,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements FileSour
|
||||
? $e->getJourneyMessage()
|
||||
: $e->message;
|
||||
|
||||
throw new \Psalm\Exception\CodeException(
|
||||
throw new CodeException(
|
||||
'Error with core stub file docblocks: '
|
||||
. $issue_type
|
||||
. ' - ' . $e->getShortLocationWithPrevious()
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Internal\Provider\ReturnTypeProvider;
|
||||
|
||||
use PhpParser;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Exception\ComplicatedExpressionException;
|
||||
use Psalm\Internal\Algebra;
|
||||
use Psalm\Internal\Algebra\FormulaGenerator;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\CallAnalyzer;
|
||||
@ -256,7 +257,7 @@ class ArrayFilterReturnTypeProvider implements FunctionReturnTypeProviderInterfa
|
||||
$statements_source,
|
||||
$codebase
|
||||
);
|
||||
} catch (\Psalm\Exception\ComplicatedExpressionException $e) {
|
||||
} catch (ComplicatedExpressionException $e) {
|
||||
$filter_clauses = [];
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Internal\Type;
|
||||
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Exception\TypeParseTreeException;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\Fetch\VariableFetchAnalyzer;
|
||||
use Psalm\Internal\Analyzer\StatementsAnalyzer;
|
||||
use Psalm\Internal\Analyzer\TraitAnalyzer;
|
||||
@ -192,7 +193,7 @@ class AssertionReconciler extends Reconciler
|
||||
|
||||
try {
|
||||
$new_type = Type::parseString($assertion, null, $template_type_map);
|
||||
} catch (\Psalm\Exception\TypeParseTreeException $e) {
|
||||
} catch (TypeParseTreeException $e) {
|
||||
$new_type = Type::getMixed();
|
||||
}
|
||||
}
|
||||
@ -341,7 +342,7 @@ class AssertionReconciler extends Reconciler
|
||||
} else {
|
||||
$new_type_part = Atomic::create($assertion, null, $template_type_map);
|
||||
}
|
||||
} catch (\Psalm\Exception\TypeParseTreeException $e) {
|
||||
} catch (TypeParseTreeException $e) {
|
||||
$new_type_part = new TMixed();
|
||||
|
||||
if ($code_location) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Psalm\Internal\Type;
|
||||
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Exception\CircularReferenceException;
|
||||
use Psalm\Internal\Type\SimpleAssertionReconciler;
|
||||
use Psalm\Internal\Type\SimpleNegatedAssertionReconciler;
|
||||
use Psalm\Internal\Type\TypeParser;
|
||||
@ -247,7 +248,7 @@ class TypeExpander
|
||||
$matching_constant,
|
||||
\ReflectionProperty::IS_PRIVATE
|
||||
);
|
||||
} catch (\Psalm\Exception\CircularReferenceException $e) {
|
||||
} catch (CircularReferenceException $e) {
|
||||
$class_constant = null;
|
||||
}
|
||||
|
||||
@ -337,7 +338,7 @@ class TypeExpander
|
||||
$return_type->const_name,
|
||||
\ReflectionProperty::IS_PRIVATE
|
||||
);
|
||||
} catch (\Psalm\Exception\CircularReferenceException $e) {
|
||||
} catch (CircularReferenceException $e) {
|
||||
$class_constant_type = null;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Psalm\Type;
|
||||
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Exception\TypeParseTreeException;
|
||||
use Psalm\Internal\Analyzer\StatementsAnalyzer;
|
||||
use Psalm\Internal\Type\TemplateResult;
|
||||
use Psalm\Internal\Type\TypeAlias;
|
||||
@ -289,11 +290,11 @@ abstract class Atomic implements TypeNode
|
||||
}
|
||||
|
||||
if (strpos($value, '-') && strpos($value, 'OCI-') !== 0) {
|
||||
throw new \Psalm\Exception\TypeParseTreeException('Unrecognized type ' . $value);
|
||||
throw new TypeParseTreeException('Unrecognized type ' . $value);
|
||||
}
|
||||
|
||||
if (is_numeric($value[0])) {
|
||||
throw new \Psalm\Exception\TypeParseTreeException('First character of type cannot be numeric');
|
||||
throw new TypeParseTreeException('First character of type cannot be numeric');
|
||||
}
|
||||
|
||||
if (isset($template_type_map[$value])) {
|
||||
@ -313,7 +314,7 @@ abstract class Atomic implements TypeNode
|
||||
return new TTypeAlias($type_alias->declaring_fq_classlike_name, $type_alias->alias_name);
|
||||
}
|
||||
|
||||
throw new \Psalm\Exception\TypeParseTreeException('Invalid type alias ' . $value . ' provided');
|
||||
throw new TypeParseTreeException('Invalid type alias ' . $value . ' provided');
|
||||
}
|
||||
|
||||
return new TNamedObject($value);
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
@ -141,7 +142,7 @@ class AnnotationTest extends TestCase
|
||||
|
||||
public function testPhpStormGenericsInvalidArgument(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('InvalidScalarArgument');
|
||||
|
||||
Config::getInstance()->allow_phpstorm_generics = true;
|
||||
@ -163,7 +164,7 @@ class AnnotationTest extends TestCase
|
||||
|
||||
public function testPhpStormGenericsNoTypehint(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('PossiblyInvalidMethodCall');
|
||||
|
||||
Config::getInstance()->allow_phpstorm_generics = true;
|
||||
@ -182,7 +183,7 @@ class AnnotationTest extends TestCase
|
||||
|
||||
public function testInvalidParamDefault(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('InvalidParamDefault');
|
||||
|
||||
$this->addFile(
|
||||
@ -219,7 +220,7 @@ class AnnotationTest extends TestCase
|
||||
|
||||
public function testInvalidTypehintParamDefaultButAllowedInConfig(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('InvalidParamDefault');
|
||||
|
||||
Config::getInstance()->add_param_default_to_docblock_type = true;
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
@ -13,7 +14,7 @@ class ArrayAccessTest extends TestCase
|
||||
|
||||
public function testEnsureArrayOffsetsExist(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('PossiblyUndefinedStringArrayOffset');
|
||||
|
||||
Config::getInstance()->ensure_array_string_offsets_exist = true;
|
||||
@ -88,7 +89,7 @@ class ArrayAccessTest extends TestCase
|
||||
|
||||
public function testComplainAfterFirstIsset(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('PossiblyUndefinedStringArrayOffset');
|
||||
|
||||
Config::getInstance()->ensure_array_string_offsets_exist = true;
|
||||
@ -106,7 +107,7 @@ class ArrayAccessTest extends TestCase
|
||||
|
||||
public function testEnsureArrayIntOffsetsExist(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('PossiblyUndefinedIntArrayOffset');
|
||||
|
||||
Config::getInstance()->ensure_array_int_offsets_exist = true;
|
||||
@ -186,7 +187,7 @@ class ArrayAccessTest extends TestCase
|
||||
{
|
||||
Config::getInstance()->ensure_array_int_offsets_exist = true;
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('PossiblyUndefinedIntArrayOffset');
|
||||
|
||||
$this->addFile(
|
||||
@ -296,7 +297,7 @@ class ArrayAccessTest extends TestCase
|
||||
{
|
||||
Config::getInstance()->ensure_array_int_offsets_exist = true;
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('PossiblyUndefinedIntArrayOffset');
|
||||
|
||||
$this->addFile(
|
||||
@ -319,7 +320,7 @@ class ArrayAccessTest extends TestCase
|
||||
{
|
||||
Config::getInstance()->ensure_array_int_offsets_exist = true;
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('PossiblyUndefinedIntArrayOffset');
|
||||
|
||||
$this->addFile(
|
||||
|
@ -2,13 +2,14 @@
|
||||
namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
class BadFormatTest extends TestCase
|
||||
{
|
||||
public function testMissingSemicolon(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ParseError - somefile.php:9');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
'<?php
|
||||
@ -29,7 +30,7 @@ class BadFormatTest extends TestCase
|
||||
public function testClassMethodWithNoStmts(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ParseError - somefile.php:3');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
'<?php
|
||||
@ -44,7 +45,7 @@ class BadFormatTest extends TestCase
|
||||
public function testInterfaceWithProperties(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ParseError - somefile.php:3');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
'<?php
|
||||
@ -59,7 +60,7 @@ class BadFormatTest extends TestCase
|
||||
public function testTypingReturnType(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ParseError - somefile.php:5');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
'<?php
|
||||
@ -78,7 +79,7 @@ class BadFormatTest extends TestCase
|
||||
public function testOverriddenUse(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ParseError - somefile.php:6');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
'<?php
|
||||
@ -95,7 +96,7 @@ class BadFormatTest extends TestCase
|
||||
public function testBadArray() : void
|
||||
{
|
||||
$this->expectExceptionMessage('ParseError - somefile.php:2');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
'<?php
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
use function class_exists;
|
||||
|
||||
@ -99,7 +100,7 @@ class BinaryOperationTest extends TestCase
|
||||
}'
|
||||
);
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('RedundantIdentityWithTrue');
|
||||
|
||||
$this->analyzeFile('somefile.php', new Context());
|
||||
@ -122,7 +123,7 @@ class BinaryOperationTest extends TestCase
|
||||
}'
|
||||
);
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('RedundantIdentityWithTrue');
|
||||
|
||||
$this->analyzeFile('somefile.php', new Context());
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
class ClassLikeStringTest extends TestCase
|
||||
{
|
||||
@ -12,7 +13,7 @@ class ClassLikeStringTest extends TestCase
|
||||
public function testDontAllowStringStandInForNewClass(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidStringClass');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->allow_string_standin_for_class = false;
|
||||
|
||||
$this->addFile(
|
||||
@ -31,7 +32,7 @@ class ClassLikeStringTest extends TestCase
|
||||
public function testDontAllowStringStandInForStaticMethodCall(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidStringClass');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->allow_string_standin_for_class = false;
|
||||
|
||||
$this->addFile(
|
||||
|
@ -5,6 +5,7 @@ use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\UnpopulatedClasslikeException;
|
||||
use Psalm\Plugin\EventHandler\AfterClassLikeVisitInterface;
|
||||
use Psalm\Plugin\EventHandler\Event\AfterClassLikeVisitEvent;
|
||||
use Psalm\PluginRegistrationSocket;
|
||||
@ -202,7 +203,7 @@ class CodebaseTest extends TestCase
|
||||
$this->codebase->classlike_storage_provider->create('A');
|
||||
$this->codebase->classlike_storage_provider->create('B');
|
||||
|
||||
$this->expectException(\Psalm\Exception\UnpopulatedClasslikeException::class);
|
||||
$this->expectException(UnpopulatedClasslikeException::class);
|
||||
|
||||
$this->codebase->classExtends('A', 'B');
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use Composer\Autoload\ClassLoader;
|
||||
use Psalm\Config;
|
||||
use Psalm\Config\IssueHandler;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Exception\ConfigException;
|
||||
use Psalm\Internal\Analyzer\FileAnalyzer;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
@ -936,7 +937,7 @@ class ConfigTest extends TestCase
|
||||
public function testValidThrowInvalidCatch(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidCatch');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
@ -984,7 +985,7 @@ class ConfigTest extends TestCase
|
||||
public function testInvalidThrowValidCatch(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidThrow');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
@ -1266,7 +1267,7 @@ class ConfigTest extends TestCase
|
||||
|
||||
public function testNotIgnoredException() : void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('MissingThrowsDocblock');
|
||||
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
|
@ -7,6 +7,7 @@ use PhpParser\Node\Stmt\ClassLike;
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\FileSource;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\IncludeCollector;
|
||||
@ -83,7 +84,7 @@ class PluginTest extends TestCase
|
||||
public function testStringAnalyzerPlugin(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidClass');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2) . DIRECTORY_SEPARATOR,
|
||||
@ -117,7 +118,7 @@ class PluginTest extends TestCase
|
||||
public function testStringAnalyzerPluginWithClassConstant(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidClass');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2) . DIRECTORY_SEPARATOR,
|
||||
@ -155,7 +156,7 @@ class PluginTest extends TestCase
|
||||
public function testStringAnalyzerPluginWithClassConstantConcat(): void
|
||||
{
|
||||
$this->expectExceptionMessage('UndefinedMethod');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2) . DIRECTORY_SEPARATOR,
|
||||
@ -226,7 +227,7 @@ class PluginTest extends TestCase
|
||||
public function testEchoAnalyzerPluginWithUnescapedConcatenatedString(): void
|
||||
{
|
||||
$this->expectExceptionMessage('TypeCoercion');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2) . DIRECTORY_SEPARATOR,
|
||||
@ -264,7 +265,7 @@ class PluginTest extends TestCase
|
||||
public function testEchoAnalyzerPluginWithUnescapedString(): void
|
||||
{
|
||||
$this->expectExceptionMessage('TypeCoercion');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2) . DIRECTORY_SEPARATOR,
|
||||
@ -398,7 +399,7 @@ class PluginTest extends TestCase
|
||||
public function testFloatCheckerPlugin(): void
|
||||
{
|
||||
$this->expectExceptionMessage('NoFloatAssignment');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2) . DIRECTORY_SEPARATOR,
|
||||
@ -819,7 +820,7 @@ class PluginTest extends TestCase
|
||||
public function testPropertyProviderHooksInvalidAssignment(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidPropertyAssignmentValue');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
require_once __DIR__ . '/Plugin/PropertyPlugin.php';
|
||||
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
@ -860,7 +861,7 @@ class PluginTest extends TestCase
|
||||
public function testMethodProviderHooksInvalidArg(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidScalarArgument');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
require_once __DIR__ . '/Plugin/MethodPlugin.php';
|
||||
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
@ -903,7 +904,7 @@ class PluginTest extends TestCase
|
||||
public function testFunctionProviderHooksInvalidArg(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidScalarArgument');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
require_once __DIR__ . '/Plugin/FunctionPlugin.php';
|
||||
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
@ -1146,7 +1147,7 @@ class PluginTest extends TestCase
|
||||
|
||||
$this->project_analyzer->trackTaintedInputs();
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessageRegExp('/TaintedHtml/');
|
||||
|
||||
$this->analyzeFile($file_path, new Context());
|
||||
|
@ -10,6 +10,7 @@ use Psalm\Config;
|
||||
use Psalm\Config\IssueHandler;
|
||||
use Psalm\Context;
|
||||
use Psalm\DocComment;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\Provider\FakeFileProvider;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
@ -225,7 +226,7 @@ class DocumentationTest extends TestCase
|
||||
$this->project_analyzer->getCodebase()->config->setCustomErrorLevel($error_level, Config::REPORT_SUPPRESS);
|
||||
}
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/');
|
||||
|
||||
$codebase = $this->project_analyzer->getCodebase();
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Psalm\Tests\FileUpdates;
|
||||
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\Provider\FakeFileProvider;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
@ -86,7 +87,7 @@ class ErrorAfterUpdateTest extends TestCase
|
||||
$this->file_provider->registerFile($file_path, $contents);
|
||||
}
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/');
|
||||
|
||||
$codebase->reloadFiles($this->project_analyzer, array_keys($end_files));
|
||||
|
@ -4,6 +4,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
use Psalm\Tests\Internal\Provider;
|
||||
@ -97,7 +98,7 @@ class ForbiddenCodeTest extends TestCase
|
||||
public function testForbiddenEchoFunctionViaFunctions(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ForbiddenCode');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
@ -124,7 +125,7 @@ class ForbiddenCodeTest extends TestCase
|
||||
public function testForbiddenEchoFunctionViaFlag(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ForbiddenEcho');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
@ -168,7 +169,7 @@ class ForbiddenCodeTest extends TestCase
|
||||
public function testForbiddenPrintFunction(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ForbiddenCode');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
@ -217,7 +218,7 @@ class ForbiddenCodeTest extends TestCase
|
||||
public function testForbiddenVarExportFunction(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ForbiddenCode');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
@ -245,7 +246,7 @@ class ForbiddenCodeTest extends TestCase
|
||||
public function testForbiddenEmptyFunction(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ForbiddenCode');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
@ -272,7 +273,7 @@ class ForbiddenCodeTest extends TestCase
|
||||
public function testForbiddenExitFunction(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ForbiddenCode');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
@ -300,7 +301,7 @@ class ForbiddenCodeTest extends TestCase
|
||||
public function testForbiddenDieFunction(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ForbiddenCode');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
@ -328,7 +329,7 @@ class ForbiddenCodeTest extends TestCase
|
||||
public function testForbiddenEvalExpression(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ForbiddenCode');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__, 2),
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Internal\Analyzer\FileAnalyzer;
|
||||
|
||||
use function getcwd;
|
||||
@ -85,7 +86,7 @@ class IncludeTest extends TestCase
|
||||
$config = $codebase->config;
|
||||
$config->skip_checks_on_unresolvable_includes = false;
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/');
|
||||
|
||||
$codebase->scanFiles();
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
use function getcwd;
|
||||
|
||||
@ -15,7 +16,7 @@ class IssueSuppressionTest extends TestCase
|
||||
|
||||
public function testIssueSuppressedOnFunction(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UnusedPsalmSuppress');
|
||||
|
||||
$this->addFile(
|
||||
@ -39,7 +40,7 @@ class IssueSuppressionTest extends TestCase
|
||||
|
||||
public function testIssueSuppressedOnStatement(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UnusedPsalmSuppress');
|
||||
|
||||
$this->addFile(
|
||||
@ -54,7 +55,7 @@ class IssueSuppressionTest extends TestCase
|
||||
|
||||
public function testUnusedSuppressAllOnFunction(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UnusedPsalmSuppress');
|
||||
|
||||
|
||||
@ -72,7 +73,7 @@ class IssueSuppressionTest extends TestCase
|
||||
|
||||
public function testUnusedSuppressAllOnStatement(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UnusedPsalmSuppress');
|
||||
|
||||
$this->addFile(
|
||||
@ -111,7 +112,7 @@ class IssueSuppressionTest extends TestCase
|
||||
|
||||
public function testMissingThrowsDocblockSuppressedWithoutThrow(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UnusedPsalmSuppress');
|
||||
Config::getInstance()->check_for_throws_docblock = true;
|
||||
|
||||
@ -131,7 +132,7 @@ class IssueSuppressionTest extends TestCase
|
||||
|
||||
public function testMissingThrowsDocblockSuppressedDuplicate(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UnusedPsalmSuppress');
|
||||
Config::getInstance()->check_for_throws_docblock = true;
|
||||
|
||||
@ -178,7 +179,7 @@ class IssueSuppressionTest extends TestCase
|
||||
|
||||
public function testUncaughtThrowInGlobalScopeSuppressedWithoutThrow(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UnusedPsalmSuppress');
|
||||
Config::getInstance()->check_for_throws_in_global_scope = true;
|
||||
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
@ -71,7 +72,7 @@ class MagicMethodAnnotationTest extends TestCase
|
||||
public function testAnnotationWithoutCallConfig(): void
|
||||
{
|
||||
$this->expectExceptionMessage('UndefinedMethod');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->use_phpdoc_method_without_magic_or_parent = false;
|
||||
|
||||
$this->addFile(
|
||||
@ -948,7 +949,7 @@ class MagicMethodAnnotationTest extends TestCase
|
||||
);
|
||||
|
||||
$error_message = 'UndefinedMagicMethod';
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage($error_message);
|
||||
$this->analyzeFile('somefile.php', new Context());
|
||||
}
|
||||
@ -1085,7 +1086,7 @@ class MagicMethodAnnotationTest extends TestCase
|
||||
);
|
||||
|
||||
$error_message = 'UndefinedMagicMethod';
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage($error_message);
|
||||
$this->analyzeFile('somefile.php', new Context());
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
use function class_exists;
|
||||
|
||||
@ -101,7 +102,7 @@ class MethodSignatureTest extends TestCase
|
||||
public function testMismatchingCovariantReturnIn73(): void
|
||||
{
|
||||
$this->expectExceptionMessage('MethodSignatureMismatch');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
|
||||
$this->project_analyzer->setPhpVersion('7.3', 'tests');
|
||||
|
||||
@ -152,7 +153,7 @@ class MethodSignatureTest extends TestCase
|
||||
public function testMismatchingCovariantReturnIn73WithSelf(): void
|
||||
{
|
||||
$this->expectExceptionMessage('MethodSignatureMismatch');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
|
||||
$this->project_analyzer->setPhpVersion('7.3', 'tests');
|
||||
|
||||
@ -199,7 +200,7 @@ class MethodSignatureTest extends TestCase
|
||||
public function testMismatchingCovariantParamIn73(): void
|
||||
{
|
||||
$this->expectExceptionMessage('MethodSignatureMismatch');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
|
||||
$this->project_analyzer->setPhpVersion('7.3', 'tests');
|
||||
|
||||
@ -244,7 +245,7 @@ class MethodSignatureTest extends TestCase
|
||||
public function testExtendDocblockParamTypeWithWrongDocblockParam(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ImplementedParamTypeMismatch');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
if (class_exists('SoapClient') === false) {
|
||||
$this->markTestSkipped('Cannot run test, base class "SoapClient" does not exist!');
|
||||
}
|
||||
@ -279,7 +280,7 @@ class MethodSignatureTest extends TestCase
|
||||
|
||||
public function testExtendDocblockParamTypeWithWrongParam() : void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('MethodSignatureMismatch');
|
||||
|
||||
if (class_exists('SoapClient') === false) {
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
@ -14,7 +15,7 @@ class PropertyTypeTest extends TestCase
|
||||
public function testForgetPropertyAssignments(): void
|
||||
{
|
||||
$this->expectExceptionMessage('NullableReturnStatement');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->remember_property_assignments_after_call = false;
|
||||
|
||||
$this->addFile(
|
||||
@ -193,7 +194,7 @@ class PropertyTypeTest extends TestCase
|
||||
Config::getInstance()->remember_property_assignments_after_call = false;
|
||||
|
||||
$this->expectExceptionMessage('TypeDoesNotContainNull - somefile.php:22:29');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
@ -231,7 +232,7 @@ class PropertyTypeTest extends TestCase
|
||||
Config::getInstance()->remember_property_assignments_after_call = false;
|
||||
|
||||
$this->expectExceptionMessage('TypeDoesNotContainNull - somefile.php:18:29');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
|
@ -3,6 +3,10 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Exception\ConfigException;
|
||||
use Psalm\Exception\InvalidClasslikeOverrideException;
|
||||
use Psalm\Exception\InvalidMethodOverrideException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\IncludeCollector;
|
||||
use Psalm\Internal\Provider\FakeFileProvider;
|
||||
@ -62,7 +66,7 @@ class StubTest extends TestCase
|
||||
|
||||
public function testNonexistentStubFile(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\ConfigException::class);
|
||||
$this->expectException(ConfigException::class);
|
||||
$this->expectExceptionMessage('Cannot resolve stubfile path');
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
Config::loadFromXML(
|
||||
@ -395,7 +399,7 @@ class StubTest extends TestCase
|
||||
public function testStubVariadicFunctionWrongArgType(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidScalarArgument');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__),
|
||||
@ -428,7 +432,7 @@ class StubTest extends TestCase
|
||||
public function testUserVariadicWithFalseVariadic(): void
|
||||
{
|
||||
$this->expectExceptionMessage('TooManyArguments');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__),
|
||||
@ -651,7 +655,7 @@ class StubTest extends TestCase
|
||||
public function testNoStubFunction(): void
|
||||
{
|
||||
$this->expectExceptionMessage('UndefinedFunction - /src/somefile.php:2:22 - Function barBar does not exist');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__),
|
||||
@ -984,7 +988,7 @@ class StubTest extends TestCase
|
||||
public function testStubFileWithPartialClassDefinitionWithCoercion(): void
|
||||
{
|
||||
$this->expectExceptionMessage('TypeCoercion');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__),
|
||||
@ -1029,7 +1033,7 @@ class StubTest extends TestCase
|
||||
public function testStubFileWithPartialClassDefinitionGeneralReturnType(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidReturnStatement');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
dirname(__DIR__),
|
||||
@ -1194,7 +1198,7 @@ class StubTest extends TestCase
|
||||
echo "hello";'
|
||||
);
|
||||
|
||||
$this->expectException(\Psalm\Exception\InvalidClasslikeOverrideException::class);
|
||||
$this->expectException(InvalidClasslikeOverrideException::class);
|
||||
|
||||
$this->analyzeFile($file_path, new Context());
|
||||
}
|
||||
@ -1225,7 +1229,7 @@ class StubTest extends TestCase
|
||||
echo "hello";'
|
||||
);
|
||||
|
||||
$this->expectException(\Psalm\Exception\InvalidMethodOverrideException::class);
|
||||
$this->expectException(InvalidMethodOverrideException::class);
|
||||
|
||||
$this->analyzeFile($file_path, new Context());
|
||||
}
|
||||
@ -1291,7 +1295,7 @@ class StubTest extends TestCase
|
||||
}'
|
||||
);
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('A|null');
|
||||
|
||||
$this->analyzeFile($file_path, new Context());
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Internal\Analyzer\IssueData;
|
||||
use Psalm\IssueBuffer;
|
||||
|
||||
@ -44,7 +45,7 @@ class TaintTest extends TestCase
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessageRegExp('/\b' . \preg_quote($error_message, '/') . '\b/');
|
||||
|
||||
$file_path = self::$src_dir_path . 'somefile.php';
|
||||
|
@ -3,13 +3,14 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
class ThrowsAnnotationTest extends TestCase
|
||||
{
|
||||
public function testUndefinedClassAsThrows() : void
|
||||
{
|
||||
$this->expectExceptionMessage('UndefinedDocblockClass - somefile.php:3:28');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
@ -28,7 +29,7 @@ class ThrowsAnnotationTest extends TestCase
|
||||
public function testNonThrowableClassAsThrows() : void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidThrow');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
@ -69,7 +70,7 @@ class ThrowsAnnotationTest extends TestCase
|
||||
public function testUndocumentedThrow(): void
|
||||
{
|
||||
$this->expectExceptionMessage('MissingThrowsDocblock');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->check_for_throws_docblock = true;
|
||||
|
||||
$this->addFile(
|
||||
@ -177,7 +178,7 @@ class ThrowsAnnotationTest extends TestCase
|
||||
public function testUndocumentedThrowInFunctionCall(): void
|
||||
{
|
||||
$this->expectExceptionMessage('MissingThrowsDocblock');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->check_for_throws_docblock = true;
|
||||
|
||||
$this->addFile(
|
||||
@ -323,7 +324,7 @@ class ThrowsAnnotationTest extends TestCase
|
||||
public function testUncaughtThrowInFunctionCall(): void
|
||||
{
|
||||
$this->expectExceptionMessage('MissingThrowsDocblock');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->check_for_throws_docblock = true;
|
||||
|
||||
$this->addFile(
|
||||
@ -362,7 +363,7 @@ class ThrowsAnnotationTest extends TestCase
|
||||
public function testEmptyThrows(): void
|
||||
{
|
||||
$this->expectExceptionMessage('MissingDocblockType');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->check_for_throws_docblock = true;
|
||||
|
||||
$this->addFile(
|
||||
@ -548,7 +549,7 @@ class ThrowsAnnotationTest extends TestCase
|
||||
public function testDocumentedThrowInInterfaceWithOverriddenDocblock(): void
|
||||
{
|
||||
$this->expectExceptionMessage('MissingThrowsDocblock');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->check_for_throws_docblock = true;
|
||||
|
||||
$this->addFile(
|
||||
@ -583,7 +584,7 @@ class ThrowsAnnotationTest extends TestCase
|
||||
public function testDocumentedThrowInsideCatch(): void
|
||||
{
|
||||
$this->expectExceptionMessage('MissingThrowsDocblock');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->check_for_throws_docblock = true;
|
||||
|
||||
$this->addFile(
|
||||
|
@ -3,12 +3,13 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
class ThrowsInGlobalScopeTest extends TestCase
|
||||
{
|
||||
public function testUncaughtDocumentedThrowCall(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UncaughtThrowInGlobalScope');
|
||||
Config::getInstance()->check_for_throws_in_global_scope = true;
|
||||
|
||||
@ -102,7 +103,7 @@ class ThrowsInGlobalScopeTest extends TestCase
|
||||
|
||||
public function testUncaughtDocumentedThrowCallInNamespace(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UncaughtThrowInGlobalScope');
|
||||
Config::getInstance()->check_for_throws_in_global_scope = true;
|
||||
|
||||
@ -136,7 +137,7 @@ class ThrowsInGlobalScopeTest extends TestCase
|
||||
|
||||
public function testUncaughtThrow(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessage('UncaughtThrowInGlobalScope');
|
||||
|
||||
Config::getInstance()->check_for_throws_in_global_scope = true;
|
||||
@ -270,7 +271,7 @@ class ThrowsInGlobalScopeTest extends TestCase
|
||||
public function testUncaughtDocumentedThrowCallWhenSuppressingFirst(): void
|
||||
{
|
||||
$this->expectExceptionMessage('UncaughtThrowInGlobalScope');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
Config::getInstance()->check_for_throws_in_global_scope = true;
|
||||
|
||||
$this->addFile(
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests\Traits;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
|
||||
use function is_int;
|
||||
use function preg_quote;
|
||||
@ -72,7 +73,7 @@ trait InvalidCodeAnalysisTestTrait
|
||||
|
||||
// $error_message = preg_replace('/ src[\/\\\\]somefile\.php/', ' src/somefile.php', $error_message);
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
|
||||
if (\method_exists($this, 'expectExceptionMessageMatches')) {
|
||||
$this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Codebase;
|
||||
use Psalm\Exception\TypeParseTreeException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\Codebase\InternalCallMapHandler;
|
||||
use Psalm\Internal\Provider\FakeFileProvider;
|
||||
@ -82,13 +83,13 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testBadNullableCharacterInUnion(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('int|array|?');
|
||||
}
|
||||
|
||||
public function testBadNullableCharacterInUnionWithFollowing(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('int|array|?|bool');
|
||||
}
|
||||
|
||||
@ -99,7 +100,7 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testArrayWithoutClosingBracket(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('array<int, int');
|
||||
}
|
||||
|
||||
@ -206,13 +207,13 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testIntersectionOfTKeyedArrayWithConflictingProperties(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('array{a: string}&array{a: int}');
|
||||
}
|
||||
|
||||
public function testIntersectionOfTwoRegularArrays() : void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('string[]&array<string, string>');
|
||||
}
|
||||
|
||||
@ -224,13 +225,13 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testIntersectionOfUnionOfTKeyedArray(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('array{a: int}&array{a: string}|array{b: int}');
|
||||
}
|
||||
|
||||
public function testIntersectionOfTKeyedArrayAndObject(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('array{a: int}&T1');
|
||||
}
|
||||
|
||||
@ -294,13 +295,13 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testInvalidType(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('array(A)');
|
||||
}
|
||||
|
||||
public function testBracketedUnionAndIntersection(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('(A|B)&C');
|
||||
}
|
||||
|
||||
@ -327,7 +328,7 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testTKeyedArrayWithClassConstantKey(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('array{self::FOO: string}');
|
||||
}
|
||||
|
||||
@ -338,13 +339,13 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testTKeyedArrayWithoutClosingBracket(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('array{a: int, b: string');
|
||||
}
|
||||
|
||||
public function testTKeyedArrayInType(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('array{a:[]}');
|
||||
}
|
||||
|
||||
@ -413,7 +414,7 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testCallableWithoutClosingBracket(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('callable(int, string');
|
||||
}
|
||||
|
||||
@ -545,7 +546,7 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testConditionalTypeWithCallableElseBool(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('(T is string ? callable() : bool)', null, ['T' => ['' => Type::getArray()]]);
|
||||
}
|
||||
|
||||
@ -595,13 +596,13 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testCallableWithTrailingColon(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('callable(int):');
|
||||
}
|
||||
|
||||
public function testCallableWithAnotherBadVariadic(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('callable(int, string..) : void');
|
||||
}
|
||||
|
||||
@ -615,85 +616,85 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testCallableWithVariadicAndDefault(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('callable(int, string...=) : void');
|
||||
}
|
||||
|
||||
public function testBadVariadic(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('string...');
|
||||
}
|
||||
|
||||
public function testBadFullStop(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('string.');
|
||||
}
|
||||
|
||||
public function testBadSemicolon(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('string;');
|
||||
}
|
||||
|
||||
public function testBadGenericString(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('string<T>');
|
||||
}
|
||||
|
||||
public function testBadAmpersand(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('&array');
|
||||
}
|
||||
|
||||
public function testBadColon(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString(':array');
|
||||
}
|
||||
|
||||
public function testBadBrackets(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('max(a)');
|
||||
}
|
||||
|
||||
public function testMoreBadBrackets(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('max(a):void');
|
||||
}
|
||||
|
||||
public function testGeneratorWithWBadBrackets(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('Generator{string, A}');
|
||||
}
|
||||
|
||||
public function testBadEquals(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('=array');
|
||||
}
|
||||
|
||||
public function testBadBar(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('|array');
|
||||
}
|
||||
|
||||
public function testBadColonDash(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('array|string:-');
|
||||
}
|
||||
|
||||
public function testDoubleBar(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
Type::parseString('PDO||Closure|numeric');
|
||||
}
|
||||
|
||||
@ -942,7 +943,7 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testIntMaskWithInvalidClassConstant(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
|
||||
Type::parseString('int-mask<A::*>');
|
||||
}
|
||||
@ -956,7 +957,7 @@ class TypeParseTest extends TestCase
|
||||
|
||||
public function testIntMaskOfWithInvalidClassConstant(): void
|
||||
{
|
||||
$this->expectException(\Psalm\Exception\TypeParseTreeException::class);
|
||||
$this->expectException(TypeParseTreeException::class);
|
||||
|
||||
Type::parseString('int-mask-of<A::FOO>');
|
||||
}
|
||||
@ -1021,7 +1022,7 @@ class TypeParseTest extends TestCase
|
||||
|
||||
try {
|
||||
Type::parseString($return_type);
|
||||
} catch (\Psalm\Exception\TypeParseTreeException $e) {
|
||||
} catch (TypeParseTreeException $e) {
|
||||
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
|
||||
}
|
||||
}
|
||||
@ -1033,7 +1034,7 @@ class TypeParseTest extends TestCase
|
||||
|
||||
try {
|
||||
Type::parseString($param_type_1);
|
||||
} catch (\Psalm\Exception\TypeParseTreeException $e) {
|
||||
} catch (TypeParseTreeException $e) {
|
||||
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
|
||||
}
|
||||
}
|
||||
@ -1041,7 +1042,7 @@ class TypeParseTest extends TestCase
|
||||
if ($param_type_2 && $param_type_2 !== 'mixed') {
|
||||
try {
|
||||
Type::parseString($param_type_2);
|
||||
} catch (\Psalm\Exception\TypeParseTreeException $e) {
|
||||
} catch (TypeParseTreeException $e) {
|
||||
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
|
||||
}
|
||||
}
|
||||
@ -1049,7 +1050,7 @@ class TypeParseTest extends TestCase
|
||||
if ($param_type_3 && $param_type_3 !== 'mixed') {
|
||||
try {
|
||||
Type::parseString($param_type_3);
|
||||
} catch (\Psalm\Exception\TypeParseTreeException $e) {
|
||||
} catch (TypeParseTreeException $e) {
|
||||
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
|
||||
}
|
||||
}
|
||||
@ -1057,7 +1058,7 @@ class TypeParseTest extends TestCase
|
||||
if ($param_type_4 && $param_type_4 !== 'mixed') {
|
||||
try {
|
||||
Type::parseString($param_type_4);
|
||||
} catch (\Psalm\Exception\TypeParseTreeException $e) {
|
||||
} catch (TypeParseTreeException $e) {
|
||||
self::assertTrue(false, $e . ' | ' . print_r($signature, true));
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\Provider\FakeFileProvider;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
@ -85,7 +86,7 @@ class UnusedCodeTest extends TestCase
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessageRegExp('/\b' . \preg_quote($error_message, '/') . '\b/');
|
||||
|
||||
$file_path = self::$src_dir_path . 'somefile.php';
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\Provider\FakeFileProvider;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
@ -79,7 +80,7 @@ class UnusedVariableTest extends TestCase
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->expectExceptionMessageRegExp('/\b' . preg_quote($error_message, '/') . '\b/');
|
||||
|
||||
$file_path = self::$src_dir_path . 'somefile.php';
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception\CodeException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\IncludeCollector;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
@ -18,7 +19,7 @@ class VariadicTest extends TestCase
|
||||
public function testVariadicArrayBadParam(): void
|
||||
{
|
||||
$this->expectExceptionMessage('InvalidScalarArgument');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
$this->expectException(CodeException::class);
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
'<?php
|
||||
|
Loading…
x
Reference in New Issue
Block a user