Skip to content

Commit b9d7880

Browse files
authored
Psalm level 2 (#152)
1 parent 21e2826 commit b9d7880

5 files changed

Lines changed: 15 additions & 7 deletions

File tree

psalm.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0"?>
22
<psalm
3-
errorLevel="4"
4-
resolveFromConfigFile="true"
3+
errorLevel="2"
54
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
65
xmlns="https://getpsalm.org/schema/config"
76
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"

src/BaseView.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ abstract class BaseView implements DynamicContentAwareInterface
7777
* content. You can call {@see beginBlock()} and {@see endBlock()} to capture small fragments of a view.
7878
* They can be later accessed somewhere else through this property.
7979
*/
80-
private array $blocks;
80+
private array $blocks = [];
8181

8282
/**
8383
* @var array The view files currently being rendered. There may be multiple view files being
@@ -146,12 +146,12 @@ public function getBasePath(): string
146146
return $this->basePath;
147147
}
148148

149-
public function getPlaceholderSignature(): string
149+
final public function getPlaceholderSignature(): string
150150
{
151151
return $this->placeholderSignature;
152152
}
153153

154-
public function setPlaceholderSalt(string $salt): void
154+
final public function setPlaceholderSalt(string $salt): void
155155
{
156156
$this->placeholderSignature = dechex(crc32($salt));
157157
}

src/PhpTemplateRenderer.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,27 @@
44

55
namespace Yiisoft\View;
66

7+
use Throwable;
8+
79
class PhpTemplateRenderer implements TemplateRendererInterface
810
{
911
public function render(BaseView $view, string $template, array $params): string
1012
{
11-
$renderer = function () {
13+
$renderer = function (): void {
1214
extract(func_get_arg(1), EXTR_OVERWRITE);
15+
/** @psalm-suppress UnresolvableInclude */
1316
require func_get_arg(0);
1417
};
1518

1619
$obInitialLevel = ob_get_level();
1720
ob_start();
21+
/** @psalm-suppress PossiblyFalseArgument */
1822
PHP_VERSION_ID >= 80000 ? ob_implicit_flush(false) : ob_implicit_flush(0);
1923
try {
24+
/** @psalm-suppress PossiblyInvalidFunctionCall */
2025
$renderer->bindTo($view)($template, $params);
2126
return ob_get_clean();
22-
} catch (\Throwable $e) {
27+
} catch (Throwable $e) {
2328
while (ob_get_level() > $obInitialLevel) {
2429
if (!@ob_end_clean()) {
2530
ob_clean();

src/View.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ final class View extends BaseView
2626
public function beginPage(): void
2727
{
2828
ob_start();
29+
/** @psalm-suppress PossiblyFalseArgument */
2930
PHP_VERSION_ID >= 80000 ? ob_implicit_flush(false) : ob_implicit_flush(0);
3031

3132
$this->eventDispatcher->dispatch(new PageBegin($this));

src/WebView.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public function endBody(): void
182182
public function beginPage(): void
183183
{
184184
ob_start();
185+
/** @psalm-suppress PossiblyFalseArgument */
185186
PHP_VERSION_ID >= 80000 ? ob_implicit_flush(false) : ob_implicit_flush(0);
186187

187188
$this->eventDispatcher->dispatch(new PageBegin($this));
@@ -230,6 +231,7 @@ public function renderAjax(string $view, array $params = []): string
230231
$viewFile = $this->findTemplateFile($view);
231232

232233
ob_start();
234+
/** @psalm-suppress PossiblyFalseArgument */
233235
PHP_VERSION_ID >= 80000 ? ob_implicit_flush(false) : ob_implicit_flush(0);
234236

235237
$this->beginPage();
@@ -252,6 +254,7 @@ public function renderAjax(string $view, array $params = []): string
252254
public function renderAjaxString(string $string): string
253255
{
254256
ob_start();
257+
/** @psalm-suppress PossiblyFalseArgument */
255258
PHP_VERSION_ID >= 80000 ? ob_implicit_flush(false) : ob_implicit_flush(0);
256259

257260
$this->beginPage();

0 commit comments

Comments
 (0)