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 1 commit
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
7 changes: 0 additions & 7 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
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
12 changes: 1 addition & 11 deletions src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php
Expand Up @@ -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',
Expand Down
23 changes: 0 additions & 23 deletions tests/ForbiddenCodeTest.php
Expand Up @@ -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