From 9bbb11599a35e589828a5be9733546dc47e15ac6 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Mon, 5 Oct 2020 10:08:41 -0400 Subject: [PATCH] 4.x - change/remove some default config values --- config.xsd | 7 ++--- src/Psalm/Config.php | 27 +------------------ .../FunctionLike/ReturnTypeAnalyzer.php | 4 --- .../Expression/Call/FunctionCallAnalyzer.php | 7 +++-- tests/TypeReconciliation/ValueTest.php | 1 - 5 files changed, 6 insertions(+), 40 deletions(-) diff --git a/config.xsd b/config.xsd index e05f71b62..e979611b8 100644 --- a/config.xsd +++ b/config.xsd @@ -57,21 +57,18 @@ - - - + - - + diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index 326e60776..84fbbe2cc 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -267,16 +267,6 @@ class Config /** @var bool */ public $strict_binary_operands = false; - /** @var bool */ - public $add_void_docblocks = true; - - /** - * If true, assert() calls can be used to check types of variables - * - * @var bool - */ - public $use_assert_for_type = true; - /** * @var bool */ @@ -419,12 +409,9 @@ class Config public $use_phpstorm_meta_path = true; /** - * Whether to resolve file and directory paths from the location of the config file, - * instead of the current working directory. - * * @var bool */ - public $resolve_from_config_file = false; + public $resolve_from_config_file = true; /** * @var string[] @@ -588,11 +575,6 @@ class Config */ public $globals = []; - /** - * @var bool - */ - public $parse_sql = false; - /** * @var int */ @@ -807,8 +789,6 @@ class Config 'resolveFromConfigFile' => 'resolve_from_config_file', 'allowFileIncludes' => 'allow_includes', 'strictBinaryOperands' => 'strict_binary_operands', - 'requireVoidReturnType' => 'add_void_docblocks', - 'useAssertForType' => 'use_assert_for_type', 'rememberPropertyAssignmentsAfterCall' => 'remember_property_assignments_after_call', 'allowPhpStormGenerics' => 'allow_phpstorm_generics', 'allowStringToStandInForClass' => 'allow_string_standin_for_class', @@ -939,11 +919,6 @@ class Config $config->max_string_length = $attribute_text; } - if (isset($config_xml['parseSql'])) { - $attribute_text = (string) $config_xml['parseSql']; - $config->parse_sql = $attribute_text === 'true' || $attribute_text === '1'; - } - if (isset($config_xml['inferPropertyTypesFromConstructor'])) { $attribute_text = (string) $config_xml['inferPropertyTypesFromConstructor']; $config->infer_property_types_from_constructor = $attribute_text === 'true' || $attribute_text === '1'; diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php index bb52d4291..ed6571710 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php @@ -222,10 +222,6 @@ class ReturnTypeAnalyzer $inferred_return_type = $inferred_yield_type; } - if (!$return_type && !$codebase->config->add_void_docblocks && $inferred_return_type->isVoid()) { - return null; - } - $unsafe_return_type = false; // prevent any return types that do not return a value from being used in PHP typehints diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php index 8333cd87d..a18b17b39 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php @@ -394,10 +394,9 @@ class FunctionCallAnalyzer extends CallAnalyzer $context->vars_possibly_in_scope[$var_id] = true; } - if ($config->use_assert_for_type && - $function_name instanceof PhpParser\Node\Name && - $function_name->parts === ['assert'] && - isset($stmt->args[0]) + if ($function_name instanceof PhpParser\Node\Name + && $function_name->parts === ['assert'] + && isset($stmt->args[0]) ) { self::processAssertFunctionEffects( $statements_analyzer, diff --git a/tests/TypeReconciliation/ValueTest.php b/tests/TypeReconciliation/ValueTest.php index e93b3b60b..39e9127ac 100644 --- a/tests/TypeReconciliation/ValueTest.php +++ b/tests/TypeReconciliation/ValueTest.php @@ -23,7 +23,6 @@ class ValueTest extends \Psalm\Tests\TestCase ); $this->project_analyzer->setPhpVersion('7.3'); - $this->project_analyzer->getCodebase()->config->parse_sql = true; } /**