Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove forbidEcho #7420

Merged
merged 3 commits into from Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADING.md
Expand Up @@ -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`
Expand Down
8 changes: 0 additions & 8 deletions config.xsd
Expand Up @@ -41,13 +41,6 @@
<xs:attribute name="findUnusedCode" type="xs:boolean" default="false" />
<xs:attribute name="findUnusedVariablesAndParams" type="xs:boolean" default="false" />
<xs:attribute name="findUnusedPsalmSuppress" type="xs:boolean" default="false" />
<xs:attribute name="forbidEcho" type="xs:boolean" default="false">
<xs:annotation>
<xs:documentation xml:lang="en">
Deprecated. Will be replaced by adding echo to forbiddenFunctions in Psalm 5.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="hideExternalErrors" type="xs:boolean" default="false" />
<xs:attribute name="hoistConstants" type="xs:boolean" default="false" />
<xs:attribute name="ignoreInternalFunctionFalseReturn" type="xs:boolean" default="true" />
Expand Down Expand Up @@ -233,7 +226,6 @@
<xs:element name="FalsableReturnStatement" type="IssueHandlerType" minOccurs="0" />
<xs:element name="FalseOperand" type="IssueHandlerType" minOccurs="0" />
<xs:element name="ForbiddenCode" type="IssueHandlerType" minOccurs="0" />
<xs:element name="ForbiddenEcho" type="IssueHandlerType" minOccurs="0" />
<xs:element name="IfThisIsMismatch" type="IssueHandlerType" minOccurs="0" />
<xs:element name="ImplementationRequirementViolation" type="IssueHandlerType" minOccurs="0" />
<xs:element name="ImplementedParamTypeMismatch" type="IssueHandlerType" minOccurs="0" />
Expand Down
1 change: 0 additions & 1 deletion docs/running_psalm/error_levels.md
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion docs/running_psalm/issues.md
Expand Up @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions docs/running_psalm/issues/ForbiddenEcho.md

This file was deleted.

6 changes: 0 additions & 6 deletions src/Psalm/Config.php
Expand Up @@ -424,11 +424,6 @@ class Config
*/
public $forbidden_functions = [];

/**
* @var bool
*/
public $forbid_echo = false;
orklah marked this conversation as resolved.
Show resolved Hide resolved

/**
* @var bool
*/
Expand Down Expand Up @@ -905,7 +900,6 @@ private static function fromXmlAndPaths(
'addParamDefaultToDocblockType' => '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',
Expand Down
13 changes: 1 addition & 12 deletions src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php
Expand Up @@ -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;
Expand Down Expand Up @@ -96,17 +95,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',
Expand Down
9 changes: 0 additions & 9 deletions src/Psalm/Issue/ForbiddenEcho.php

This file was deleted.

3 changes: 0 additions & 3 deletions tests/DocumentationTest.php
Expand Up @@ -277,9 +277,6 @@ public function providerInvalidCodeParse(): array
case 'InvalidStringClass':
continue 2;

case 'ForbiddenEcho':
continue 2;

case 'PluginClass':
continue 2;

Expand Down
25 changes: 1 addition & 24 deletions tests/ForbiddenCodeTest.php
Expand Up @@ -97,7 +97,7 @@ public function testAllowedEchoFunction(): void
$this->analyzeFile($file_path, new Context());
}

public function testForbiddenEchoFunctionViaFunctions(): void
public function testForbiddenCodeFunctionViaFunctions(): void
{
$this->expectExceptionMessage('ForbiddenCode');
$this->expectException(CodeException::class);
Expand All @@ -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),
'<?xml version="1.0"?>
<psalm forbidEcho="true"></psalm>'
)
);

$file_path = getcwd() . '/src/somefile.php';

$this->addFile(
$file_path,
'<?php
echo "hello";'
);

$this->analyzeFile($file_path, new Context());
}

public function testAllowedPrintFunction(): void
{
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
Expand Down