Skip to content

Commit

Permalink
4.x - change/remove some default config values
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 5, 2020
1 parent d5f4fd5 commit 377dc8d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 40 deletions.
7 changes: 2 additions & 5 deletions config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,18 @@
</xs:annotation>
</xs:attribute>
<xs:attribute name="memoizeMethodCallResults" type="xs:boolean" default="false" />
<xs:attribute name="parseSql" type="xs:boolean" default="false" />
<xs:attribute name="rememberPropertyAssignmentsAfterCall" type="xs:boolean" default="true" />
<xs:attribute name="requireVoidReturnType" type="xs:boolean" default="true" />
<xs:attribute name="resolveFromConfigFile" type="xs:boolean" default="false" />
<xs:attribute name="resolveFromConfigFile" type="xs:boolean" default="true" />
<xs:attribute name="strictBinaryOperands" type="xs:boolean" default="false" />
<xs:attribute name="throwExceptionOnError" type="xs:boolean" default="false" />
<xs:attribute name="totallyTyped" type="xs:boolean" default="false" />
<xs:attribute name="errorLevel" type="xs:integer" default="1" />
<xs:attribute name="reportMixedIssues" type="xs:boolean" default="true" />
<xs:attribute name="useAssertForType" type="xs:boolean" default="true" />
<xs:attribute name="useDocblockTypes" type="xs:boolean" default="true" />
<xs:attribute name="useDocblockPropertyTypes" type="xs:boolean" default="false" />
<xs:attribute name="usePhpDocMethodsWithoutMagicCall" type="xs:boolean" default="false" />
<xs:attribute name="usePhpDocPropertiesWithoutMagicCall" type="xs:boolean" default="false" />
<xs:attribute name="skipChecksOnUnresolvableIncludes" type="xs:boolean" default="true" />
<xs:attribute name="skipChecksOnUnresolvableIncludes" type="xs:boolean" default="false" />
<xs:attribute name="sealAllMethods" type="xs:boolean" default="false" />
<xs:attribute name="runTaintAnalysis" type="xs:boolean" default="false" />
<xs:attribute name="usePhpStormMetaPath" type="xs:boolean" default="true" />
Expand Down
27 changes: 1 addition & 26 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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[]
Expand Down Expand Up @@ -588,11 +575,6 @@ class Config
*/
public $globals = [];

/**
* @var bool
*/
public $parse_sql = false;

/**
* @var int
*/
Expand Down Expand Up @@ -807,8 +789,6 @@ private static function fromXmlAndPaths(string $base_dir, string $file_contents,
'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',
Expand Down Expand Up @@ -939,11 +919,6 @@ private static function fromXmlAndPaths(string $base_dir, string $file_contents,
$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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ public static function verifyReturnType(
$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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,9 @@ public static function analyze(
$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,
Expand Down
1 change: 0 additions & 1 deletion tests/TypeReconciliation/ValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function setUp() : void
);

$this->project_analyzer->setPhpVersion('7.3');
$this->project_analyzer->getCodebase()->config->parse_sql = true;
}

/**
Expand Down

0 comments on commit 377dc8d

Please sign in to comment.