diff --git a/config.xsd b/config.xsd
index 6937af60edf..605ffd748ab 100644
--- a/config.xsd
+++ b/config.xsd
@@ -16,14 +16,6 @@
-
-
-
-
- Deprecated. Replaced by documenting never as a return type. It is going to be removed in Psalm 5.
-
-
-
diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php
index 3ec92a9ad48..734a89ae09e 100644
--- a/src/Psalm/Config.php
+++ b/src/Psalm/Config.php
@@ -488,13 +488,6 @@ class Config
/** @var ClassLoader|null */
private $composer_class_loader;
- /**
- * Custom functions that always exit
- *
- * @var array
- */
- public $exit_functions = [];
-
/**
* @var string
*/
@@ -1059,13 +1052,6 @@ private static function fromXmlAndPaths(
}
}
- if (isset($config_xml->exitFunctions) && isset($config_xml->exitFunctions->function)) {
- /** @var \SimpleXMLElement $exit_function */
- foreach ($config_xml->exitFunctions->function as $exit_function) {
- $config->exit_functions[strtolower((string) $exit_function['name'])] = true;
- }
- }
-
if (isset($config_xml->stubs) && isset($config_xml->stubs->file)) {
/** @var \SimpleXMLElement $stub_file */
foreach ($config_xml->stubs->file as $stub_file) {
diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
index 173602064e2..1d0dc466dda 100644
--- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php
@@ -144,7 +144,6 @@ public static function verifyReturnType(
&& ScopeAnalyzer::getControlActions(
$function_stmts,
$type_provider,
- $codebase->config->exit_functions,
[]
) !== [ScopeAnalyzer::ACTION_END]
&& !$inferred_yield_types
@@ -165,7 +164,6 @@ public static function verifyReturnType(
$control_actions = ScopeAnalyzer::getControlActions(
$function_stmts,
$type_provider,
- $codebase->config->exit_functions,
[],
false
);
diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php
index dc540335ab9..6cfa6af8f05 100644
--- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php
+++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php
@@ -23,8 +23,6 @@ class ReturnTypeCollector
* @return list a list of return types
*
* @psalm-suppress ComplexMethod to be refactored
- *
- * TODO: This would probably benefit from using the list of exit_functions
*/
public static function getReturnTypes(
Codebase $codebase,
diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
index 322d931889f..26eecdd75e6 100644
--- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
@@ -501,7 +501,6 @@ public function analyze(
$final_actions = ScopeAnalyzer::getControlActions(
$this->function->getStmts() ?: [],
null,
- $codebase->config->exit_functions,
[]
);
diff --git a/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php b/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
index 5e32dc4a419..f61d4a63605 100644
--- a/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php
@@ -12,7 +12,6 @@
use function array_values;
use function count;
use function in_array;
-use function strtolower;
/**
* @internal
@@ -65,7 +64,6 @@ public static function doesEverBreak(array $stmts): bool
/**
* @param array $stmts
- * @param array $exit_functions
* @param list<'loop'|'switch'> $break_types
* @param bool $return_is_exit Exit and Throw statements are treated differently from return if this is false
*
@@ -76,7 +74,6 @@ public static function doesEverBreak(array $stmts): bool
public static function getControlActions(
array $stmts,
?\Psalm\Internal\Provider\NodeDataProvider $nodes,
- array $exit_functions,
array $break_types,
bool $return_is_exit = true
): array {
@@ -107,32 +104,6 @@ public static function getControlActions(
return array_values(array_unique(array_merge($control_actions, [self::ACTION_END])));
}
- if ($exit_functions) {
- if ($stmt->expr instanceof PhpParser\Node\Expr\FuncCall
- || $stmt->expr instanceof PhpParser\Node\Expr\StaticCall
- ) {
- if ($stmt->expr instanceof PhpParser\Node\Expr\FuncCall) {
- /** @var string|null */
- $resolved_name = $stmt->expr->name->getAttribute('resolvedName');
-
- if ($resolved_name && isset($exit_functions[strtolower($resolved_name)])) {
- return array_values(array_unique(array_merge($control_actions, [self::ACTION_END])));
- }
- } elseif ($stmt->expr->class instanceof PhpParser\Node\Name
- && $stmt->expr->name instanceof PhpParser\Node\Identifier
- ) {
- /** @var string|null */
- $resolved_class_name = $stmt->expr->class->getAttribute('resolvedName');
-
- if ($resolved_class_name
- && isset($exit_functions[strtolower($resolved_class_name . '::' . $stmt->expr->name)])
- ) {
- return array_values(array_unique(array_merge($control_actions, [self::ACTION_END])));
- }
- }
- }
- }
-
continue;
}
@@ -172,7 +143,6 @@ public static function getControlActions(
$if_statement_actions = self::getControlActions(
$stmt->stmts,
$nodes,
- $exit_functions,
$break_types,
$return_is_exit
);
@@ -188,7 +158,6 @@ function ($action) {
? self::getControlActions(
$stmt->else->stmts,
$nodes,
- $exit_functions,
$break_types,
$return_is_exit
) : [];
@@ -209,7 +178,6 @@ function ($action) {
$elseif_control_actions = self::getControlActions(
$elseif->stmts,
$nodes,
- $exit_functions,
$break_types,
$return_is_exit
);
@@ -266,7 +234,6 @@ function ($action) {
$case_actions = self::getControlActions(
$case->stmts,
$nodes,
- $exit_functions,
array_merge($break_types, ['switch']),
$return_is_exit
);
@@ -332,7 +299,6 @@ function ($action) {
$loop_actions = self::getControlActions(
$stmt->stmts,
$nodes,
- $exit_functions,
array_merge($break_types, ['loop']),
$return_is_exit
);
@@ -391,7 +357,6 @@ function ($action) {
$try_statement_actions = self::getControlActions(
$stmt->stmts,
$nodes,
- $exit_functions,
$break_types,
$return_is_exit
);
@@ -412,7 +377,6 @@ function ($action) {
$catch_actions = self::getControlActions(
$catch->stmts,
$nodes,
- $exit_functions,
$break_types,
$return_is_exit
);
@@ -452,7 +416,6 @@ function ($action) {
$finally_statement_actions = self::getControlActions(
$stmt->finally->stmts,
$nodes,
- $exit_functions,
$break_types,
$return_is_exit
);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php
index 7e901947d76..5dfe518fb0c 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php
@@ -152,7 +152,6 @@ public static function analyze(
? ScopeAnalyzer::getControlActions(
$else->stmts,
$statements_analyzer->node_data,
- $codebase->config->exit_functions,
[]
)
: [ScopeAnalyzer::ACTION_NONE];
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php
index 9ff0bda05ae..72bfc2cbbe2 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php
@@ -308,7 +308,6 @@ function (array $carry, Clause $clause): array {
$final_actions = ScopeAnalyzer::getControlActions(
$elseif->stmts,
$statements_analyzer->node_data,
- $codebase->config->exit_functions,
[]
);
// has a return/throw at end
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php
index ac8e7e55d25..1ac2c1facc6 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php
@@ -69,7 +69,6 @@ public static function analyze(
$final_actions = ScopeAnalyzer::getControlActions(
$stmt->stmts,
$statements_analyzer->node_data,
- $codebase->config->exit_functions,
[]
);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php
index 26de808b925..138487a07c2 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php
@@ -76,7 +76,6 @@ public static function analyze(
$final_actions = ScopeAnalyzer::getControlActions(
$stmt->stmts,
null,
- $codebase->config->exit_functions,
[]
);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
index c09bd7509e7..1113b9f30e2 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php
@@ -3,7 +3,6 @@
use PhpParser;
use Psalm\CodeLocation;
-use Psalm\Config;
use Psalm\Context;
use Psalm\Internal\Algebra;
use Psalm\Internal\Algebra\FormulaGenerator;
@@ -90,7 +89,6 @@ public static function analyze(
$final_actions = ScopeAnalyzer::getControlActions(
$stmts,
$statements_analyzer->node_data,
- Config::getInstance()->exit_functions,
[]
);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php
index 495127f2d1d..db373f4f6cd 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php
@@ -65,8 +65,6 @@ public static function analyze(
$case_action_map = [];
- $config = \Psalm\Config::getInstance();
-
// create a map of case statement -> ultimate exit type
for ($i = count($stmt->cases) - 1; $i >= 0; --$i) {
$case = $stmt->cases[$i];
@@ -74,7 +72,6 @@ public static function analyze(
$case_actions = $case_action_map[$i] = ScopeAnalyzer::getControlActions(
$case->stmts,
$statements_analyzer->node_data,
- $config->exit_functions,
['switch']
);
diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
index 29b1978bec0..fdba3edd59d 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
@@ -49,7 +49,6 @@ public static function analyze(
$catch_actions[$i] = ScopeAnalyzer::getControlActions(
$catch->stmts,
$statements_analyzer->node_data,
- $codebase->config->exit_functions,
[]
);
$all_catches_leave = $all_catches_leave && !in_array(ScopeAnalyzer::ACTION_NONE, $catch_actions[$i], true);
@@ -102,7 +101,6 @@ public static function analyze(
$try_block_control_actions = ScopeAnalyzer::getControlActions(
$stmt->stmts,
$statements_analyzer->node_data,
- $codebase->config->exit_functions,
[]
);
@@ -358,7 +356,6 @@ function (string $fq_catch_class) use ($codebase): \Psalm\Type\Atomic\TNamedObje
$catch_actions[$i] = ScopeAnalyzer::getControlActions(
$catch->stmts,
$statements_analyzer->node_data,
- $codebase->config->exit_functions,
[]
);
diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php
index 63f023cd7b6..1f19046da8e 100644
--- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php
+++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php
@@ -282,7 +282,6 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal
$final_actions = \Psalm\Internal\Analyzer\ScopeAnalyzer::getControlActions(
$function_stmt->stmts,
null,
- $this->config->exit_functions,
[],
false
);
diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php
index 3c5050a9268..82b48b7b0fe 100644
--- a/tests/Config/ConfigTest.php
+++ b/tests/Config/ConfigTest.php
@@ -860,73 +860,6 @@ class MyMockClass {}
$this->analyzeFile($file_path, new Context());
}
- public function testExitFunctions(): void
- {
- $this->project_analyzer = $this->getProjectAnalyzerWithConfig(
- TestConfig::loadFromXML(
- dirname(__DIR__, 2),
- '
-
-
-
-
-
-
- '
- )
- );
-
- $file_path = getcwd() . '/src/somefile.php';
-
- $this->addFile(
- $file_path,
- 'analyzeFile($file_path, new Context());
- }
-
public function testValidThrowInvalidCatch(): void
{
$this->expectExceptionMessage('InvalidCatch');