mirror of
https://github.com/danog/psalm.git
synced 2024-12-12 17:27:28 +01:00
New tag @self-out (WIP)
This commit is contained in:
parent
0f4cd893bd
commit
20cde0ca2c
@ -467,6 +467,24 @@ class CommentAnalyzer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($parsed_docblock->tags['self-out'])) {
|
||||||
|
foreach ($parsed_docblock->tags['param-out'] as $offset => $param) {
|
||||||
|
$line_parts = self::splitDocLine($param);
|
||||||
|
|
||||||
|
if (count($line_parts) === 1 && isset($line_parts[0][0]) && $line_parts[0][0] === '$') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($line_parts) > 1) {
|
||||||
|
$line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0]));
|
||||||
|
$info->self_out[] = [
|
||||||
|
'type' => str_replace("\n", '', $line_parts[0]),
|
||||||
|
'line_number' => $comment->getLine() + substr_count($comment_text, "\n", 0, $offset),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($parsed_docblock->tags['psalm-flow'])) {
|
if (isset($parsed_docblock->tags['psalm-flow'])) {
|
||||||
$flow = trim(reset($parsed_docblock->tags['psalm-flow']));
|
$flow = trim(reset($parsed_docblock->tags['psalm-flow']));
|
||||||
$info->flow = $flow;
|
$info->flow = $flow;
|
||||||
|
@ -1509,7 +1509,11 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
|
|||||||
),
|
),
|
||||||
$statements_analyzer->getSuppressedIssues()
|
$statements_analyzer->getSuppressedIssues()
|
||||||
)) {
|
)) {
|
||||||
|
//var_dump($actual_type->getId());
|
||||||
|
//var_dump($context);
|
||||||
|
//die;
|
||||||
// fall through
|
// fall through
|
||||||
|
//throw new \Exception('there');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1016,6 +1016,10 @@ class PropertyAssignmentAnalyzer
|
|||||||
),
|
),
|
||||||
$statements_analyzer->getSuppressedIssues()
|
$statements_analyzer->getSuppressedIssues()
|
||||||
)) {
|
)) {
|
||||||
|
//var_dump($context);
|
||||||
|
//$context->vars_in_scope['$this->t'] = new \Psalm\Type\Atomic\TNamedObject("Closed");
|
||||||
|
//die;
|
||||||
|
//throw new \Exception('here');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1297,13 +1297,18 @@ class AssignmentAnalyzer
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$var_id = ExpressionIdentifier::getVarId(
|
$var_id = ExpressionIdentifier::getVarId(
|
||||||
$stmt,
|
$stmt,
|
||||||
$statements_analyzer->getFQCLN(),
|
$statements_analyzer->getFQCLN(),
|
||||||
$statements_analyzer
|
$statements_analyzer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//$var_id = '$f';
|
||||||
|
//$context->byref_constraints[$var_id] = new \Psalm\Internal\ReferenceConstraint($by_ref_type);
|
||||||
|
//$context->vars_possibly_in_scope[$var_id] = true;
|
||||||
|
//$context->vars_in_scope[$var_id] = new Type\Union([new Type\Atomic\TInt()]);
|
||||||
|
//return;
|
||||||
|
|
||||||
if ($var_id) {
|
if ($var_id) {
|
||||||
if (!$by_ref_type->hasMixed() && $constrain_type) {
|
if (!$by_ref_type->hasMixed() && $constrain_type) {
|
||||||
$context->byref_constraints[$var_id] = new \Psalm\Internal\ReferenceConstraint($by_ref_type);
|
$context->byref_constraints[$var_id] = new \Psalm\Internal\ReferenceConstraint($by_ref_type);
|
||||||
|
@ -829,9 +829,13 @@ class ArgumentsAnalyzer
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//var_dump($by_ref_type);die;
|
||||||
|
|
||||||
$by_ref_type = $by_ref_type ?: Type::getMixed();
|
$by_ref_type = $by_ref_type ?: Type::getMixed();
|
||||||
|
|
||||||
|
//var_dump($by_ref_type);
|
||||||
|
//var_dump($by_ref_out_type);
|
||||||
|
|
||||||
AssignmentAnalyzer::assignByRefParam(
|
AssignmentAnalyzer::assignByRefParam(
|
||||||
$statements_analyzer,
|
$statements_analyzer,
|
||||||
$arg->value,
|
$arg->value,
|
||||||
|
@ -85,6 +85,8 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
|
|||||||
? $context->vars_in_scope[$lhs_var_id]
|
? $context->vars_in_scope[$lhs_var_id]
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
var_dump($class_type);
|
||||||
|
|
||||||
if ($stmt_var_type = $statements_analyzer->node_data->getType($stmt->var)) {
|
if ($stmt_var_type = $statements_analyzer->node_data->getType($stmt->var)) {
|
||||||
$class_type = $stmt_var_type;
|
$class_type = $stmt_var_type;
|
||||||
} elseif (!$class_type) {
|
} elseif (!$class_type) {
|
||||||
@ -360,6 +362,7 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var_dump($result->existent_method_ids);
|
||||||
if (!$result->existent_method_ids) {
|
if (!$result->existent_method_ids) {
|
||||||
return self::checkMethodArgs(
|
return self::checkMethodArgs(
|
||||||
null,
|
null,
|
||||||
|
@ -2439,6 +2439,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
|
|||||||
$class_template_types = $this->class_template_types;
|
$class_template_types = $this->class_template_types;
|
||||||
|
|
||||||
foreach ($docblock_info->params_out as $docblock_param_out) {
|
foreach ($docblock_info->params_out as $docblock_param_out) {
|
||||||
|
|
||||||
$param_name = substr($docblock_param_out['name'], 1);
|
$param_name = substr($docblock_param_out['name'], 1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -2475,6 +2476,10 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($docblock_info->self_out as $self_out) {
|
||||||
|
var_dump($self_out);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($docblock_info->taint_sink_params as $taint_sink_param) {
|
foreach ($docblock_info->taint_sink_params as $taint_sink_param) {
|
||||||
$param_name = substr($taint_sink_param['name'], 1);
|
$param_name = substr($taint_sink_param['name'], 1);
|
||||||
|
|
||||||
|
@ -41,6 +41,11 @@ class FunctionDocblockComment
|
|||||||
*/
|
*/
|
||||||
public $params_out = [];
|
public $params_out = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<int, array{type:string, line_number: int}>
|
||||||
|
*/
|
||||||
|
public $self_out = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array<int, array{name:string, type:string, line_number: int}>
|
* @var array<int, array{name:string, type:string, line_number: int}>
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user