Skip to content

Commit

Permalink
Fix issues found with Vimeo’s code
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed May 11, 2020
1 parent f3a6e1a commit 48da7a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,13 @@ public static function analyze(
&& !$assign_value_type->hasArrayAccessInterface($codebase)
) {
if ($assign_value_type->hasArray()) {
if (IssueBuffer::accepts(
if (($assign_value_atomic_type instanceof Type\Atomic\TFalse
&& $assign_value_type->ignore_falsable_issues)
|| ($assign_value_atomic_type instanceof Type\Atomic\TNull
&& $assign_value_type->ignore_nullable_issues)
) {
// do nothing
} elseif (IssueBuffer::accepts(
new PossiblyInvalidArrayAccess(
'Cannot access array value on non-array variable '
. $array_var_id . ' of type ' . $assign_value_atomic_type->getId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2783,6 +2783,10 @@ public static function checkFunctionArgumentType(
$codebase->analyzer->incrementNonMixedCount($statements_analyzer->getFilePath());
}

if ($function_param->by_ref) {
$param_type->possibly_undefined = true;
}

$param_type = TypeAnalyzer::simplifyUnionType(
$codebase,
$param_type
Expand Down Expand Up @@ -3810,7 +3814,10 @@ protected static function applyAssertionsToContext(

$codebase = $statements_analyzer->getCodebase();

if ($first_appearance && $context->vars_in_scope[$var_id]->hasMixed()) {
if ($first_appearance
&& isset($context->vars_in_scope[$var_id])
&& $context->vars_in_scope[$var_id]->hasMixed()
) {
if (!$context->collect_initializations
&& !$context->collect_mutations
&& $statements_analyzer->getFilePath() === $statements_analyzer->getRootFilePath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ public static function analyzeInstance(
continue;
}

if ($interface_exists) {
if (!$class_exists) {
$property_id = $lhs_type_part->value . '::$' . $prop_name;

if (IssueBuffer::accepts(
Expand Down

0 comments on commit 48da7a4

Please sign in to comment.