-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve type inference for public method return types
Also marks the class soft-final in preparation for the next major. Because the `encoding` constructor argument is now marked as `non-empty-string`, defensive type checks now emit a psalm issue which has been added to the baseline Signed-off-by: George Steel <[email protected]>
- Loading branch information
Showing
6 changed files
with
91 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<files psalm-version="5.9.0@8b9ad1eb9e8b7d3101f949291da2b9f7767cd163"/> | ||
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0"> | ||
<file src="src/Escaper.php"> | ||
<TypeDoesNotContainType> | ||
<code><![CDATA[$encoding === '']]></code> | ||
</TypeDoesNotContainType> | ||
</file> | ||
</files> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LaminasTest\Escaper\StaticAnalysis; | ||
|
||
use Laminas\Escaper\Escaper; | ||
|
||
/** @psalm-suppress UnusedClass */ | ||
final class EscaperReturnTypeChecks | ||
{ | ||
public function __construct(private readonly Escaper $escaper) | ||
{ | ||
} | ||
|
||
/** @return non-empty-string */ | ||
public function escapeHtmlReturnsNonEmptyString(): string | ||
{ | ||
return $this->escaper->escapeHtml('Not Empty'); | ||
} | ||
|
||
public function escapeHtmlReturnsEmptyString(): string | ||
{ | ||
return $this->escaper->escapeHtml(''); | ||
} | ||
|
||
/** @return non-empty-string */ | ||
public function escapeJsReturnsNonEmptyString(): string | ||
{ | ||
return $this->escaper->escapeJs('Not Empty'); | ||
} | ||
|
||
public function escapeJsReturnsEmptyString(): string | ||
{ | ||
return $this->escaper->escapeJs(''); | ||
} | ||
|
||
/** @return non-empty-string */ | ||
public function escapeCssReturnsNonEmptyString(): string | ||
{ | ||
return $this->escaper->escapeCss('Not Empty'); | ||
} | ||
|
||
public function escapeCssReturnsEmptyString(): string | ||
{ | ||
return $this->escaper->escapeCss(''); | ||
} | ||
|
||
/** @return non-empty-string */ | ||
public function escapeAttributeReturnsNonEmptyString(): string | ||
{ | ||
return $this->escaper->escapeHtmlAttr('Not Empty'); | ||
} | ||
|
||
public function escapeAttributeReturnsEmptyString(): string | ||
{ | ||
return $this->escaper->escapeHtmlAttr(''); | ||
} | ||
} |