From 5f749c8a331ed274ef9ec543b0b2841f234cedea Mon Sep 17 00:00:00 2001 From: orklah Date: Tue, 18 Jan 2022 18:14:39 +0100 Subject: [PATCH 1/3] remove forbidEcho --- config.xsd | 7 ------ docs/running_psalm/issues/ForbiddenEcho.md | 9 -------- src/Psalm/Config.php | 6 ----- .../Analyzer/Statements/EchoAnalyzer.php | 12 +--------- tests/ForbiddenCodeTest.php | 23 ------------------- 5 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 docs/running_psalm/issues/ForbiddenEcho.md diff --git a/config.xsd b/config.xsd index d3b8089f237..7ff3134e6d7 100644 --- a/config.xsd +++ b/config.xsd @@ -41,13 +41,6 @@ - - - - Deprecated. Will be replaced by adding echo to forbiddenFunctions in Psalm 5. - - - diff --git a/docs/running_psalm/issues/ForbiddenEcho.md b/docs/running_psalm/issues/ForbiddenEcho.md deleted file mode 100644 index 4aedd3ee055..00000000000 --- a/docs/running_psalm/issues/ForbiddenEcho.md +++ /dev/null @@ -1,9 +0,0 @@ -# ForbiddenEcho - -Emitted when Psalm encounters an echo statement and the `forbidEcho` flag in your config is set to `true` -This issue is deprecated and will be removed in Psalm 5. Adding echo to forbiddenFunctions in config will result in ForbiddenCode issue instead -```php - 'add_param_default_to_docblock_type', 'checkForThrowsDocblock' => 'check_for_throws_docblock', 'checkForThrowsInGlobalScope' => 'check_for_throws_in_global_scope', - 'forbidEcho' => 'forbid_echo', 'ignoreInternalFunctionFalseReturn' => 'ignore_internal_falsable_issues', 'ignoreInternalFunctionNullReturn' => 'ignore_internal_nullable_issues', 'includePhpVersionsInErrorBaseline' => 'include_php_versions_in_error_baseline', diff --git a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php index 1cfea01d028..a5177dc4418 100644 --- a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php @@ -96,17 +96,7 @@ public static function analyze( } } - if ($codebase->config->forbid_echo) { - if (IssueBuffer::accepts( - new ForbiddenEcho( - 'Use of echo', - new CodeLocation($statements_analyzer, $stmt) - ), - $statements_analyzer->getSource()->getSuppressedIssues() - )) { - return false; - } - } elseif (isset($codebase->config->forbidden_functions['echo'])) { + if (isset($codebase->config->forbidden_functions['echo'])) { IssueBuffer::maybeAdd( new ForbiddenCode( 'Use of echo', diff --git a/tests/ForbiddenCodeTest.php b/tests/ForbiddenCodeTest.php index ab72309fb8a..d24c0251973 100644 --- a/tests/ForbiddenCodeTest.php +++ b/tests/ForbiddenCodeTest.php @@ -124,29 +124,6 @@ public function testForbiddenEchoFunctionViaFunctions(): void $this->analyzeFile($file_path, new Context()); } - public function testForbiddenEchoFunctionViaFlag(): void - { - $this->expectExceptionMessage('ForbiddenEcho'); - $this->expectException(CodeException::class); - $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 testAllowedPrintFunction(): void { $this->project_analyzer = $this->getProjectAnalyzerWithConfig( From dceaa117cffd7546c4bf41b1da64c454ff2f27d0 Mon Sep 17 00:00:00 2001 From: orklah Date: Tue, 18 Jan 2022 18:25:18 +0100 Subject: [PATCH 2/3] remove forbidEcho --- config.xsd | 1 - docs/running_psalm/error_levels.md | 1 - docs/running_psalm/issues.md | 1 - src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php | 1 - src/Psalm/Issue/ForbiddenEcho.php | 9 --------- tests/DocumentationTest.php | 3 --- tests/ForbiddenCodeTest.php | 2 +- 7 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 src/Psalm/Issue/ForbiddenEcho.php diff --git a/config.xsd b/config.xsd index 7ff3134e6d7..42ad433c242 100644 --- a/config.xsd +++ b/config.xsd @@ -226,7 +226,6 @@ - diff --git a/docs/running_psalm/error_levels.md b/docs/running_psalm/error_levels.md index 3babb92488a..8cd5942721f 100644 --- a/docs/running_psalm/error_levels.md +++ b/docs/running_psalm/error_levels.md @@ -284,7 +284,6 @@ These issues are treated as errors at level 7 and below. ## Feature-specific errors - - [ForbiddenEcho](issues/ForbiddenEcho.md) - [PossiblyUndefinedIntArrayOffset](issues/PossiblyUndefinedIntArrayOffset.md) - [PossiblyUndefinedStringArrayOffset](issues/PossiblyUndefinedStringArrayOffset.md) - [PossiblyUnusedMethod](issues/PossiblyUnusedMethod.md) diff --git a/docs/running_psalm/issues.md b/docs/running_psalm/issues.md index c471c86f4cb..b392b7fad64 100644 --- a/docs/running_psalm/issues.md +++ b/docs/running_psalm/issues.md @@ -32,7 +32,6 @@ - [FalsableReturnStatement](issues/FalsableReturnStatement.md) - [FalseOperand](issues/FalseOperand.md) - [ForbiddenCode](issues/ForbiddenCode.md) - - [ForbiddenEcho](issues/ForbiddenEcho.md) - [IfThisIsMismatch](issues/IfThisIsMismatch.md) - [ImplementationRequirementViolation](issues/ImplementationRequirementViolation.md) - [ImplementedParamTypeMismatch](issues/ImplementedParamTypeMismatch.md) diff --git a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php index a5177dc4418..441f6a50d18 100644 --- a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php @@ -12,7 +12,6 @@ use Psalm\Internal\Codebase\TaintFlowGraph; use Psalm\Internal\DataFlow\TaintSink; use Psalm\Issue\ForbiddenCode; -use Psalm\Issue\ForbiddenEcho; use Psalm\Issue\ImpureFunctionCall; use Psalm\IssueBuffer; use Psalm\Storage\FunctionLikeParameter; diff --git a/src/Psalm/Issue/ForbiddenEcho.php b/src/Psalm/Issue/ForbiddenEcho.php deleted file mode 100644 index 73a84fe7455..00000000000 --- a/src/Psalm/Issue/ForbiddenEcho.php +++ /dev/null @@ -1,9 +0,0 @@ -analyzeFile($file_path, new Context()); } - public function testForbiddenEchoFunctionViaFunctions(): void + public function testForbiddenCodeFunctionViaFunctions(): void { $this->expectExceptionMessage('ForbiddenCode'); $this->expectException(CodeException::class); From ddf7a0bb369e61284d172116601f59c0e687b393 Mon Sep 17 00:00:00 2001 From: orklah Date: Tue, 18 Jan 2022 18:27:27 +0100 Subject: [PATCH 3/3] remove forbidEcho --- UPGRADING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/UPGRADING.md b/UPGRADING.md index a389e609676..070a7f54607 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -131,6 +131,7 @@ - [BC] Method `Psalm\Type\Union::isEmpty()` was removed - [BC] Property `Psalm\Config::$allow_phpstorm_generics` was removed - [BC] Property `Psalm\Config::$exit_functions` was removed + - [BC] Property `Psalm\Config::$forbid_echo` was removed - [BC] Method `Psalm\Type::getEmpty()` was removed - [BC] Legacy hook interfaces have been removed: - `Psalm\Plugin\Hook\MethodReturnTypeProviderInterface`