mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Conversion of misc
This commit is contained in:
parent
3cbfdd5e37
commit
6ee3d44092
@ -18,6 +18,7 @@ use Psalm\Storage\MethodStorage;
|
||||
use Psalm\Type;
|
||||
use Psalm\Type\Atomic\TNamedObject;
|
||||
use Psalm\Type\Union;
|
||||
use Psalm\Internal\MethodIdentifier;
|
||||
|
||||
class TemplateAnalyzer extends Psalm\Internal\Analyzer\FileAnalyzer
|
||||
{
|
||||
@ -51,7 +52,7 @@ class TemplateAnalyzer extends Psalm\Internal\Analyzer\FileAnalyzer
|
||||
}
|
||||
|
||||
/** @psalm-suppress ArgumentTypeCoercion */
|
||||
$method_id = new \Psalm\Internal\MethodIdentifier(...explode('::', $matches[1]));
|
||||
$method_id = new MethodIdentifier(...explode('::', $matches[1]));
|
||||
|
||||
$this_params = $this->checkMethod($method_id, $first_stmt, $codebase);
|
||||
|
||||
@ -80,7 +81,7 @@ class TemplateAnalyzer extends Psalm\Internal\Analyzer\FileAnalyzer
|
||||
/**
|
||||
* @return Context|false
|
||||
*/
|
||||
private function checkMethod(\Psalm\Internal\MethodIdentifier $method_id, PhpParser\Node $stmt, Codebase $codebase)
|
||||
private function checkMethod(MethodIdentifier $method_id, PhpParser\Node $stmt, Codebase $codebase)
|
||||
{
|
||||
if (ClassLikeAnalyzer::checkFullyQualifiedClassLikeName(
|
||||
$this,
|
||||
@ -103,7 +104,7 @@ class TemplateAnalyzer extends Psalm\Internal\Analyzer\FileAnalyzer
|
||||
$this_context->vars_in_scope['$this'] = new Union([new TNamedObject($class_storage->name)]);
|
||||
|
||||
$this->project_analyzer->getMethodMutations(
|
||||
new \Psalm\Internal\MethodIdentifier($method_id->fq_class_name, '__construct'),
|
||||
new MethodIdentifier($method_id->fq_class_name, '__construct'),
|
||||
$this_context,
|
||||
$this->getRootFilePath(),
|
||||
$this->getRootFileName()
|
||||
|
@ -14,6 +14,7 @@ use Psalm\Plugin\EventHandler\Event\AfterFunctionCallAnalysisEvent;
|
||||
use Psalm\Plugin\EventHandler\Event\AfterMethodCallAnalysisEvent;
|
||||
use Psalm\Internal\Analyzer\StatementsAnalyzer;
|
||||
use Psalm\Internal\Analyzer\FunctionLike\ReturnTypeAnalyzer;
|
||||
use Psalm\Internal\MethodIdentifier;
|
||||
|
||||
use function explode;
|
||||
use function strtolower;
|
||||
@ -36,7 +37,7 @@ class FunctionCasingChecker implements AfterFunctionCallAnalysisInterface, After
|
||||
|
||||
try {
|
||||
/** @psalm-suppress ArgumentTypeCoercion */
|
||||
$method_id = new \Psalm\Internal\MethodIdentifier(...explode('::', $declaring_method_id));
|
||||
$method_id = new MethodIdentifier(...explode('::', $declaring_method_id));
|
||||
$function_storage = $codebase->methods->getStorage($method_id);
|
||||
|
||||
if ($function_storage->cased_name === '__call') {
|
||||
|
@ -340,7 +340,7 @@ class Codebase
|
||||
|
||||
self::$stubbed_constants = [];
|
||||
|
||||
$reflection = new Internal\Codebase\Reflection($providers->classlike_storage_provider, $this);
|
||||
$reflection = new Reflection($providers->classlike_storage_provider, $this);
|
||||
|
||||
$this->scanner = new Scanner(
|
||||
$this,
|
||||
@ -836,7 +836,7 @@ class Codebase
|
||||
bool $is_used = true
|
||||
): bool {
|
||||
return $this->methods->methodExists(
|
||||
Internal\MethodIdentifier::wrap($method_id),
|
||||
MethodIdentifier::wrap($method_id),
|
||||
is_string($calling_method_id) ? strtolower($calling_method_id) : strtolower((string) $calling_method_id),
|
||||
$code_location,
|
||||
null,
|
||||
@ -853,7 +853,7 @@ class Codebase
|
||||
*/
|
||||
public function getMethodParams($method_id): array
|
||||
{
|
||||
return $this->methods->getMethodParams(Internal\MethodIdentifier::wrap($method_id));
|
||||
return $this->methods->getMethodParams(MethodIdentifier::wrap($method_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -862,7 +862,7 @@ class Codebase
|
||||
*/
|
||||
public function isVariadic($method_id): bool
|
||||
{
|
||||
return $this->methods->isVariadic(Internal\MethodIdentifier::wrap($method_id));
|
||||
return $this->methods->isVariadic(MethodIdentifier::wrap($method_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -873,7 +873,7 @@ class Codebase
|
||||
public function getMethodReturnType($method_id, ?string &$self_class, array $call_args = []): ?Union
|
||||
{
|
||||
return $this->methods->getMethodReturnType(
|
||||
Internal\MethodIdentifier::wrap($method_id),
|
||||
MethodIdentifier::wrap($method_id),
|
||||
$self_class,
|
||||
null,
|
||||
$call_args
|
||||
@ -886,7 +886,7 @@ class Codebase
|
||||
*/
|
||||
public function getMethodReturnsByRef($method_id): bool
|
||||
{
|
||||
return $this->methods->getMethodReturnsByRef(Internal\MethodIdentifier::wrap($method_id));
|
||||
return $this->methods->getMethodReturnsByRef(MethodIdentifier::wrap($method_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -899,7 +899,7 @@ class Codebase
|
||||
CodeLocation &$defined_location = null
|
||||
): ?CodeLocation {
|
||||
return $this->methods->getMethodReturnTypeLocation(
|
||||
Internal\MethodIdentifier::wrap($method_id),
|
||||
MethodIdentifier::wrap($method_id),
|
||||
$defined_location
|
||||
);
|
||||
}
|
||||
@ -910,7 +910,7 @@ class Codebase
|
||||
*/
|
||||
public function getDeclaringMethodId($method_id): ?string
|
||||
{
|
||||
$new_method_id = $this->methods->getDeclaringMethodId(Internal\MethodIdentifier::wrap($method_id));
|
||||
$new_method_id = $this->methods->getDeclaringMethodId(MethodIdentifier::wrap($method_id));
|
||||
|
||||
return $new_method_id ? (string) $new_method_id : null;
|
||||
}
|
||||
@ -923,7 +923,7 @@ class Codebase
|
||||
*/
|
||||
public function getAppearingMethodId($method_id): ?string
|
||||
{
|
||||
$new_method_id = $this->methods->getAppearingMethodId(Internal\MethodIdentifier::wrap($method_id));
|
||||
$new_method_id = $this->methods->getAppearingMethodId(MethodIdentifier::wrap($method_id));
|
||||
|
||||
return $new_method_id ? (string) $new_method_id : null;
|
||||
}
|
||||
@ -931,11 +931,11 @@ class Codebase
|
||||
/**
|
||||
* @param string|MethodIdentifier $method_id
|
||||
*
|
||||
* @return array<string, Internal\MethodIdentifier>
|
||||
* @return array<string, MethodIdentifier>
|
||||
*/
|
||||
public function getOverriddenMethodIds($method_id): array
|
||||
{
|
||||
return $this->methods->getOverriddenMethodIds(Internal\MethodIdentifier::wrap($method_id));
|
||||
return $this->methods->getOverriddenMethodIds(MethodIdentifier::wrap($method_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -944,7 +944,7 @@ class Codebase
|
||||
*/
|
||||
public function getCasedMethodId($method_id): string
|
||||
{
|
||||
return $this->methods->getCasedMethodId(Internal\MethodIdentifier::wrap($method_id));
|
||||
return $this->methods->getCasedMethodId(MethodIdentifier::wrap($method_id));
|
||||
}
|
||||
|
||||
public function invalidateInformationForFile(string $file_path): void
|
||||
|
@ -32,6 +32,7 @@ use Psalm\Issue\FunctionIssue;
|
||||
use Psalm\Issue\MethodIssue;
|
||||
use Psalm\Issue\PropertyIssue;
|
||||
use Psalm\Issue\VariableIssue;
|
||||
use Psalm\Plugin\PluginEntryPointInterface;
|
||||
use Psalm\Progress\Progress;
|
||||
use Psalm\Progress\VoidProgress;
|
||||
use SimpleXMLElement;
|
||||
@ -1330,7 +1331,7 @@ class Config
|
||||
/**
|
||||
* @psalm-suppress InvalidStringClass
|
||||
*
|
||||
* @var Plugin\PluginEntryPointInterface
|
||||
* @var PluginEntryPointInterface
|
||||
*/
|
||||
$plugin_object = new $plugin_class_name;
|
||||
$plugin_object($socket, $plugin_config);
|
||||
|
@ -3,6 +3,7 @@ namespace Psalm;
|
||||
|
||||
use Psalm\Internal\Analyzer\ClassLikeAnalyzer;
|
||||
use Psalm\Internal\Scanner\FileScanner;
|
||||
use Psalm\Plugin\PluginEntryPointInterface;
|
||||
use Psalm\Plugin\RegistrationInterface;
|
||||
use SimpleXMLElement;
|
||||
use UnexpectedValueException;
|
||||
@ -14,7 +15,7 @@ use function str_replace;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
class FileBasedPluginAdapter implements Plugin\PluginEntryPointInterface
|
||||
class FileBasedPluginAdapter implements PluginEntryPointInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $path;
|
||||
|
@ -7,6 +7,7 @@ use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Internal\Analyzer\ClosureAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\ArrayAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\AssertionFinder;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\AssignmentAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\BinaryOpAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\BitwiseNotAnalyzer;
|
||||
@ -103,7 +104,7 @@ class ExpressionAnalyzer
|
||||
$negate = !$negate;
|
||||
}
|
||||
|
||||
Expression\AssertionFinder::scrapeAssertions(
|
||||
AssertionFinder::scrapeAssertions(
|
||||
$stmt,
|
||||
$context->self,
|
||||
$statements_analyzer,
|
||||
|
@ -32,6 +32,7 @@ use Psalm\Internal\Analyzer\Statements\ReturnAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\StaticAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\ThrowAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\UnsetAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\UnusedAssignmentRemover;
|
||||
use Psalm\Internal\Codebase\DataFlowGraph;
|
||||
use Psalm\Internal\Codebase\TaintFlowGraph;
|
||||
use Psalm\Internal\Codebase\VariableUseGraph;
|
||||
@ -329,7 +330,7 @@ class StatementsAnalyzer extends SourceAnalyzer
|
||||
ConstFetchAnalyzer::setConstType(
|
||||
$statements_analyzer,
|
||||
$const_name,
|
||||
Statements\Expression\SimpleTypeInferer::infer(
|
||||
SimpleTypeInferer::infer(
|
||||
$codebase,
|
||||
$statements_analyzer->node_data,
|
||||
$stmt->expr->getArgs()[1]->value,
|
||||
@ -733,7 +734,7 @@ class StatementsAnalyzer extends SourceAnalyzer
|
||||
|
||||
$project_analyzer = $this->getProjectAnalyzer();
|
||||
|
||||
$unused_var_remover = new Statements\UnusedAssignmentRemover();
|
||||
$unused_var_remover = new UnusedAssignmentRemover();
|
||||
|
||||
if ($this->data_flow_graph instanceof VariableUseGraph
|
||||
&& $codebase->config->limit_method_complexity
|
||||
|
@ -14,6 +14,10 @@ use Psalm\Internal\Analyzer\ClassLikeAnalyzer;
|
||||
use Psalm\Internal\Analyzer\CommentAnalyzer;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\SimpleTypeInferer;
|
||||
use Psalm\Internal\EventDispatcher;
|
||||
use Psalm\Internal\PhpVisitor\Reflector\ClassLikeNodeScanner;
|
||||
use Psalm\Internal\PhpVisitor\Reflector\ExpressionResolver;
|
||||
use Psalm\Internal\PhpVisitor\Reflector\ExpressionScanner;
|
||||
use Psalm\Internal\PhpVisitor\Reflector\FunctionLikeNodeScanner;
|
||||
use Psalm\Internal\Provider\NodeDataProvider;
|
||||
use Psalm\Internal\Scanner\FileScanner;
|
||||
use Psalm\Internal\Scanner\PhpStormMetaScanner;
|
||||
@ -77,12 +81,12 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements FileSour
|
||||
private $file_storage;
|
||||
|
||||
/**
|
||||
* @var array<Reflector\FunctionLikeNodeScanner>
|
||||
* @var array<FunctionLikeNodeScanner>
|
||||
*/
|
||||
private $functionlike_node_scanners = [];
|
||||
|
||||
/**
|
||||
* @var array<Reflector\ClassLikeNodeScanner>
|
||||
* @var array<ClassLikeNodeScanner>
|
||||
*/
|
||||
private $classlike_node_scanners = [];
|
||||
|
||||
@ -134,7 +138,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements FileSour
|
||||
foreach ($node->getComments() as $comment) {
|
||||
if ($comment instanceof PhpParser\Comment\Doc && !$node instanceof PhpParser\Node\Stmt\ClassLike) {
|
||||
try {
|
||||
$type_aliases = Reflector\ClassLikeNodeScanner::getTypeAliasesFromComment(
|
||||
$type_aliases = ClassLikeNodeScanner::getTypeAliasesFromComment(
|
||||
$comment,
|
||||
$this->aliases,
|
||||
$this->type_aliases,
|
||||
@ -167,7 +171,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements FileSour
|
||||
return null;
|
||||
}
|
||||
|
||||
$classlike_node_scanner = new Reflector\ClassLikeNodeScanner(
|
||||
$classlike_node_scanner = new ClassLikeNodeScanner(
|
||||
$this->codebase,
|
||||
$this->file_storage,
|
||||
$this->file_scanner,
|
||||
@ -217,7 +221,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements FileSour
|
||||
$functionlike_types += $functionlike_storage->template_types ?? [];
|
||||
}
|
||||
|
||||
$functionlike_node_scanner = new Reflector\FunctionLikeNodeScanner(
|
||||
$functionlike_node_scanner = new FunctionLikeNodeScanner(
|
||||
$this->codebase,
|
||||
$this->file_scanner,
|
||||
$this->file_storage,
|
||||
@ -298,7 +302,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements FileSour
|
||||
if (!$this->functionlike_node_scanners) {
|
||||
$this->exists_cond_expr = $node->cond;
|
||||
|
||||
if (Reflector\ExpressionResolver::enterConditional(
|
||||
if (ExpressionResolver::enterConditional(
|
||||
$this->codebase,
|
||||
$this->file_path,
|
||||
$this->exists_cond_expr
|
||||
@ -314,7 +318,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements FileSour
|
||||
$this->exists_cond_expr = null;
|
||||
} elseif (!$this->skip_if_descendants) {
|
||||
if ($this->exists_cond_expr
|
||||
&& Reflector\ExpressionResolver::enterConditional(
|
||||
&& ExpressionResolver::enterConditional(
|
||||
$this->codebase,
|
||||
$this->file_path,
|
||||
$this->exists_cond_expr
|
||||
@ -331,7 +335,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements FileSour
|
||||
$functionlike_storage = $functionlike_node_scanner->storage;
|
||||
}
|
||||
|
||||
Reflector\ExpressionScanner::scan(
|
||||
ExpressionScanner::scan(
|
||||
$this->codebase,
|
||||
$this->file_scanner,
|
||||
$this->file_storage,
|
||||
|
@ -8,6 +8,7 @@ use Psalm\Type;
|
||||
use Psalm\Type\Atomic\TArray;
|
||||
use Psalm\Type\Atomic\TKeyedArray;
|
||||
use Psalm\Type\Atomic\TList;
|
||||
use Psalm\Type\Union;
|
||||
|
||||
class InArrayReturnTypeProvider implements FunctionReturnTypeProviderInterface
|
||||
{
|
||||
@ -19,7 +20,7 @@ class InArrayReturnTypeProvider implements FunctionReturnTypeProviderInterface
|
||||
return ['in_array'];
|
||||
}
|
||||
|
||||
public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union
|
||||
public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Union
|
||||
{
|
||||
$call_args = $event->getCallArgs();
|
||||
$bool = Type::getBool();
|
||||
|
@ -1092,7 +1092,7 @@ INFO: PossiblyUndefinedGlobalVariable - somefile.php:17:6 - Possibly undefined g
|
||||
{
|
||||
$this->analyzeFileForReport();
|
||||
|
||||
$console_report_options = new Report\ReportOptions();
|
||||
$console_report_options = new ReportOptions();
|
||||
$console_report_options->show_snippet = false;
|
||||
$console_report_options->use_color = true;
|
||||
$console_report_options->in_ci = true;
|
||||
|
Loading…
Reference in New Issue
Block a user