From 74934ffdbbda86c115e944a24c15f9a2edd5f507 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Fri, 2 Oct 2020 18:47:23 -0400 Subject: [PATCH] 4.x - rename GetClassT to TDependentGetClass --- .../Analyzer/Statements/Block/SwitchCaseAnalyzer.php | 4 ++-- .../Expression/Call/FunctionCallAnalyzer.php | 4 ++-- .../Statements/Expression/Call/NewAnalyzer.php | 4 ++-- .../Expression/Call/StaticCallAnalyzer.php | 2 +- .../Type/Comparator/ScalarTypeComparator.php | 12 ++++++------ .../Type/SimpleNegatedAssertionReconciler.php | 2 +- src/Psalm/Internal/Type/UnionTemplateHandler.php | 2 +- .../Atomic/{GetClassT.php => TDependentGetClass.php} | 2 +- .../Atomic/{GetTypeT.php => TDependentGetType.php} | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) rename src/Psalm/Type/Atomic/{GetClassT.php => TDependentGetClass.php} (95%) rename src/Psalm/Type/Atomic/{GetTypeT.php => TDependentGetType.php} (92%) diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php index 901045475..86bcf1f6b 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php @@ -122,7 +122,7 @@ class SwitchCaseAnalyzer $type_statements = []; foreach ($switch_var_type->getAtomicTypes() as $type) { - if ($type instanceof Type\Atomic\GetClassT) { + if ($type instanceof Type\Atomic\TDependentGetClass) { $type_statements[] = new PhpParser\Node\Expr\FuncCall( new PhpParser\Node\Name(['get_class']), [ @@ -131,7 +131,7 @@ class SwitchCaseAnalyzer ), ] ); - } elseif ($type instanceof Type\Atomic\GetTypeT) { + } elseif ($type instanceof Type\Atomic\TDependentGetType) { $type_statements[] = new PhpParser\Node\Expr\FuncCall( new PhpParser\Node\Name(['gettype']), [ diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php index 90c2243b1..5478e0d18 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php @@ -1338,13 +1338,13 @@ class FunctionCallAnalyzer extends CallAnalyzer if (isset($context->vars_in_scope[$var_id])) { $atomic_type = $function_name->parts === ['get_class'] - ? new Type\Atomic\GetClassT( + ? new Type\Atomic\TDependentGetClass( $var_id, $context->vars_in_scope[$var_id]->hasMixed() ? Type::getObject() : $context->vars_in_scope[$var_id] ) - : new Type\Atomic\GetTypeT($var_id); + : new Type\Atomic\TDependentGetType($var_id); $statements_analyzer->node_data->setType($real_stmt, new Type\Union([$atomic_type])); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php index 851b7517d..9bee4a314 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php @@ -209,7 +209,7 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna if ($lhs_type_part instanceof Type\Atomic\TLiteralClassString || $lhs_type_part instanceof Type\Atomic\TClassString - || $lhs_type_part instanceof Type\Atomic\GetClassT + || $lhs_type_part instanceof Type\Atomic\TDependentGetClass ) { if (!$statements_analyzer->node_data->getType($stmt)) { if ($lhs_type_part instanceof Type\Atomic\TClassString) { @@ -238,7 +238,7 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna } } } - } elseif ($lhs_type_part instanceof Type\Atomic\GetClassT) { + } elseif ($lhs_type_part instanceof Type\Atomic\TDependentGetClass) { $generated_type = new Type\Atomic\TObject(); if ($lhs_type_part->as_type->hasObjectType() diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php index 8176380b4..81efdb612 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php @@ -261,7 +261,7 @@ class StaticCallAnalyzer extends CallAnalyzer } $intersection_types = $lhs_type_part->as_type->extra_types; - } elseif ($lhs_type_part instanceof Type\Atomic\GetClassT + } elseif ($lhs_type_part instanceof Type\Atomic\TDependentGetClass && !$lhs_type_part->as_type->hasObject() ) { $fq_class_name = 'object'; diff --git a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php index 7eed6500b..c593275f2 100644 --- a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php @@ -15,8 +15,8 @@ use Psalm\Type\Atomic\TFalse; use Psalm\Type\Atomic\TFloat; use Psalm\Type\Atomic\TTemplateParam; use Psalm\Type\Atomic\TTemplateParamClass; -use Psalm\Type\Atomic\GetClassT; -use Psalm\Type\Atomic\GetTypeT; +use Psalm\Type\Atomic\TDependentGetClass; +use Psalm\Type\Atomic\TDependentGetType; use Psalm\Type\Atomic\THtmlEscapedString; use Psalm\Type\Atomic\TInt; use Psalm\Type\Atomic\TLiteralClassString; @@ -114,7 +114,7 @@ class ScalarTypeComparator return false; } - if ($container_type_part instanceof GetClassT) { + if ($container_type_part instanceof TDependentGetClass) { $first_type = array_values($container_type_part->as_type->getAtomicTypes())[0]; $container_type_part = new TClassString( @@ -123,7 +123,7 @@ class ScalarTypeComparator ); } - if ($input_type_part instanceof GetClassT) { + if ($input_type_part instanceof TDependentGetClass) { $first_type = array_values($input_type_part->as_type->getAtomicTypes())[0]; if ($first_type instanceof TTemplateParam) { @@ -143,7 +143,7 @@ class ScalarTypeComparator } } - if ($input_type_part instanceof GetTypeT) { + if ($input_type_part instanceof TDependentGetType) { $input_type_part = new TString(); if ($container_type_part instanceof TLiteralString) { @@ -151,7 +151,7 @@ class ScalarTypeComparator } } - if ($container_type_part instanceof GetTypeT) { + if ($container_type_part instanceof TDependentGetType) { $container_type_part = new TString(); if ($input_type_part instanceof TLiteralString) { diff --git a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php index 0b2557f00..07e86b212 100644 --- a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php @@ -654,7 +654,7 @@ class SimpleNegatedAssertionReconciler extends Reconciler if (isset($existing_var_atomic_types['string'])) { if (!$existing_var_atomic_types['string'] instanceof Type\Atomic\TNonEmptyString && !$existing_var_atomic_types['string'] instanceof Type\Atomic\TClassString - && !$existing_var_atomic_types['string'] instanceof Type\Atomic\GetClassT + && !$existing_var_atomic_types['string'] instanceof Type\Atomic\TDependentGetClass ) { $did_remove_type = true; diff --git a/src/Psalm/Internal/Type/UnionTemplateHandler.php b/src/Psalm/Internal/Type/UnionTemplateHandler.php index 6006ea8e2..15133293d 100644 --- a/src/Psalm/Internal/Type/UnionTemplateHandler.php +++ b/src/Psalm/Internal/Type/UnionTemplateHandler.php @@ -829,7 +829,7 @@ class UnionTemplateHandler } else { $valid_input_atomic_types[] = new Atomic\TObject(); } - } elseif ($input_atomic_type instanceof Atomic\GetClassT) { + } elseif ($input_atomic_type instanceof Atomic\TDependentGetClass) { $valid_input_atomic_types[] = new Atomic\TObject(); } } diff --git a/src/Psalm/Type/Atomic/GetClassT.php b/src/Psalm/Type/Atomic/TDependentGetClass.php similarity index 95% rename from src/Psalm/Type/Atomic/GetClassT.php rename to src/Psalm/Type/Atomic/TDependentGetClass.php index f8c2e9332..8eb7327bc 100644 --- a/src/Psalm/Type/Atomic/GetClassT.php +++ b/src/Psalm/Type/Atomic/TDependentGetClass.php @@ -6,7 +6,7 @@ use Psalm\Type\Union; /** * Represents a string whose value is a fully-qualified class found by get_class($var) */ -class GetClassT extends TString +class TDependentGetClass extends TString { /** * Used to hold information as to what this refers to diff --git a/src/Psalm/Type/Atomic/GetTypeT.php b/src/Psalm/Type/Atomic/TDependentGetType.php similarity index 92% rename from src/Psalm/Type/Atomic/GetTypeT.php rename to src/Psalm/Type/Atomic/TDependentGetType.php index 537c1eab2..f1de269a8 100644 --- a/src/Psalm/Type/Atomic/GetTypeT.php +++ b/src/Psalm/Type/Atomic/TDependentGetType.php @@ -4,7 +4,7 @@ namespace Psalm\Type\Atomic; /** * Represents a string whose value is that of a type found by gettype($var) */ -class GetTypeT extends TString +class TDependentGetType extends TString { /** * Used to hold information as to what this refers to