Passed
Pull Request — master (#91)
by
unknown
13:24
created

View::generatePlaceholderSignatures()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\View;
6
7
use Psr\EventDispatcher\EventDispatcherInterface;
8
use Psr\Log\LoggerInterface;
9
use RuntimeException;
10
use Yiisoft\I18n\Locale;
11
use Yiisoft\View\Event\AfterRender;
12
use Yiisoft\View\Event\BeforeRender;
13
use Yiisoft\View\Event\PageBegin;
14
use Yiisoft\View\Event\PageEnd;
15
use Yiisoft\View\Exception\ViewNotFoundException;
16
17
/**
18
 * View represents a view object in the MVC pattern.
19
 *
20
 * View provides a set of methods (e.g. {@see View::render()}) for rendering purpose.
21
 *
22
 * For more details and usage information on View, see the [guide article on views](guide:structure-views).
23
 */
24
class View implements DynamicContentAwareInterface
25
{
26
    /**
27
     * @var string view path
28
     */
29
    private string $basePath;
30
31
    /**
32
     * @var array a list of named output blocks. The keys are the block names and the values are the corresponding block
33
     * content. You can call {@see beginBlock()} and {@see endBlock()} to capture small fragments of a view.
34
     * They can be later accessed somewhere else through this property.
35
     */
36
    private array $blocks;
37
38
    /**
39
     * @var ViewContextInterface|null the context under which the {@see renderFile()} method is being invoked.
40
     */
41
    private ?ViewContextInterface $context = null;
42
43
    /**
44
     * @var string the default view file extension. This will be appended to view file names if they don't have file
45
     * extensions.
46
     */
47
    private string $defaultExtension = 'php';
48
49
    /**
50
     * @var array custom parameters that are shared among view templates.
51
     */
52
    private array $defaultParameters = [];
53
54
    /**
55
     * @var EventDispatcherInterface $eventDispatcher
56
     */
57
    protected EventDispatcherInterface $eventDispatcher;
58
59
    /**
60
     * @var array a list of available renderers indexed by their corresponding supported file extensions. Each renderer
61
     * may be a view renderer object or the configuration for creating the renderer object. For example, the
62
     * following configuration enables the Twig view renderer:
63
     *
64
     * ```php
65
     * [
66
     *     'twig' => ['__class' => \Yiisoft\Yii\Twig\ViewRenderer::class],
67
     * ]
68
     * ```
69
     *
70
     * If no renderer is available for the given view file, the view file will be treated as a normal PHP and rendered
71
     * via PhpTemplateRenderer.
72
     */
73
    protected array $renderers = [];
74
75
    /**
76
     * @var Theme the theme object.
77
     */
78
    protected Theme $theme;
79
80
    /**
81
     * @var FragmentCache
82
     */
83
    private FragmentCacheInterface $fragmentCache;
84
85
    /**
86
     * @var DynamicContentAwareInterface[] a list of currently active dynamic content class instances.
87
     */
88
    private array $cacheStack = [];
89
90
    /**
91
     * @var array a list of placeholders for embedding dynamic contents.
92
     */
93
    private array $dynamicPlaceholders = [];
94
95
    /**
96
     * @var string
97
     */
98
    private string $language = 'en';
99
100
    /**
101
     * @var LoggerInterface
102
     */
103
    private LoggerInterface $logger;
104
105
    /**
106
     * @var string
107
     */
108
    private string $sourceLanguage = 'en';
109
110
    /**
111
     * @var Locale|null source locale used to find localized view file.
112
     */
113
    private ?Locale $sourceLocale = null;
114
115
    private string $placeholderDynamicSignature;
116
117 18
    private string $placeholderSignature;
118
119 18
    /**
120 18
     * @var array the view files currently being rendered. There may be multiple view files being
121 18
     * rendered at a moment because one view may be rendered within another.
122 18
     */
123 18
    private array $viewFiles = [];
124 18
125
    public function __construct(string $basePath, Theme $theme, EventDispatcherInterface $eventDispatcher, FragmentCacheInterface $fragmentCache, LoggerInterface $logger)
126 18
    {
127
        $this->basePath = $basePath;
128 18
        $this->theme = $theme;
129 18
        $this->eventDispatcher = $eventDispatcher;
130
        $this->fragmentCache = $fragmentCache;
0 ignored issues
show
Documentation Bug introduced by
$fragmentCache is of type Yiisoft\View\FragmentCacheInterface, but the property $fragmentCache was declared to be of type Yiisoft\View\FragmentCache. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
131 5
        $this->logger = $logger;
132
        $this->generatePlaceholderSignatures();
133 5
    }
134
135
    public function generatePlaceholderSignatures(): void
136
    {
137
        $this->placeholderDynamicSignature = \strtr(\base64_encode(\substr(\pack('Q', \rand(0, PHP_INT_MAX)), 0, 6)), '+/=', '012');
138
        $this->placeholderSignature = \dechex(\crc32(__DIR__));
139
    }
140
141
    public function setPlaceholderDynamicSignature(string $sign): void
142
    {
143
        $this->placeholderDynamicSignature = $sign;
144
    }
145
146
    public function setPlaceholderSignature(string $sign): void
147
    {
148
        $this->placeholderSignature = $sign;
149
    }
150
151
    public function getPlaceholderDynamicSignature(): string
152
    {
153
        return $this->placeholderDynamicSignature;
154
    }
155
156
    public function getPlaceholderSignature(): string
157
    {
158
        return $this->placeholderSignature;
159
    }
160
161
    public function getBasePath(): string
162
    {
163
        return $this->basePath;
164
    }
165
166
    public function setRenderers(array $renderers): void
167
    {
168
        $this->renderers = $renderers;
169
    }
170
171
    public function setSourceLanguage(string $language): void
172
    {
173
        $this->sourceLanguage = $language;
174
    }
175
176 2
    public function setLanguage(string $language): void
177
    {
178 2
        $this->language = $language;
179 2
    }
180
181
    public function setContext(ViewContextInterface $context): void
182
    {
183
        $this->context = $context;
184
    }
185
186
    public function getDefaultExtension(): string
187
    {
188
        return $this->defaultExtension;
189
    }
190
191
    public function setDefaultExtension(string $defaultExtension): void
192
    {
193
        $this->defaultExtension = $defaultExtension;
194
    }
195
196
    public function getDefaultParameters(): array
197
    {
198
        return $this->defaultParameters;
199
    }
200
201
    public function setDefaultParameters(array $defaultParameters): void
202
    {
203
        $this->defaultParameters = $defaultParameters;
204
    }
205
206
    /**
207
     * {@see blocks}
208
     *
209
     * @param string $id
210
     * @param string $value
211
     *
212
     * @return void
213
     */
214
    public function setBlocks(string $id, string $value): void
215
    {
216
        $this->blocks[$id] = $value;
217
    }
218
219
    /**
220
     * {@see blocks}
221
     *
222
     * @param string $value
223
     *
224
     * @return string
225
     */
226
    public function getBlock(string $value): string
227
    {
228
        if (isset($this->blocks[$value])) {
229
            return $this->blocks[$value];
230
        }
231
232
        throw new \InvalidArgumentException('Block: ' . $value . ' not found.');
233
    }
234
235
    /**
236
     * Renders a view.
237
     *
238
     * The view to be rendered can be specified in one of the following formats:
239
     *
240 4
     * - [path alias](guide:concept-aliases) (e.g. "@app/views/site/index");
241
     * - absolute path within application (e.g. "//site/index"): the view name starts with double slashes. The actual
242 4
     *   view file will be looked for under the [[Application::viewPath|view path]] of the application.
243
     * - absolute path within current module (e.g. "/site/index"): the view name starts with a single slash. The actual
244 4
     *   view file will be looked for under the [[Module::viewPath|view path]] of the [[Controller::module|current module]].
245
     * - relative view (e.g. "index"): the view name does not start with `@` or `/`. The corresponding view file will be
246
     *   looked for under the {@see ViewContextInterface::getViewPath()} of the view `$context`.
247
     *   If `$context` is not given, it will be looked for under the directory containing the view currently
248
     *   being rendered (i.e., this happens when rendering a view within another view).
249
     *
250
     * @param string $view the view name.
251
     * @param array $parameters the parameters (name-value pairs) that will be extracted and made available in the view
252
     * file.
253
     * @param ViewContextInterface|null $context the context to be assigned to the view and can later be accessed via
254
     * {@see context} in the view. If the context implements {@see ViewContextInterface}, it may also be used to locate
255
     * the view file corresponding to a relative view name.
256
     *
257
     * @return string the rendering result
258
     *
259
     * @throws \RuntimeException if the view cannot be resolved.
260
     * @throws ViewNotFoundException if the view file does not exist.
261 4
     * @throws \Throwable
262
     *
263 4
     * {@see renderFile()}
264
     */
265 4
    public function render(string $view, array $parameters = [], ?ViewContextInterface $context = null): string
266 1
    {
267
        $viewFile = $this->findTemplateFile($view, $context);
268
269 1
        return $this->renderFile($viewFile, $parameters, $context);
270
    }
271 1
272
    /**
273
     * Finds the view file based on the given view name.
274
     *
275
     * @param string $view the view name or the [path alias](guide:concept-aliases) of the view file. Please refer to
276 4
     * {@see render()} on how to specify this parameter.
277 1
     * @param ViewContextInterface|null $context the context to be assigned to the view and can later be accessed via
278
     * {@see context} in the view. If the context implements {@see ViewContextInterface}, it may also be used to locate the
279
     * view file corresponding to a relative view name.
280 3
     *
281
     * @throws \RuntimeException if a relative view name is given while there is no active context to determine the
282 3
     * corresponding view file.
283
     *
284
     * @return string the view file path. Note that the file may not exist.
285
     */
286 3
    protected function findTemplateFile(string $view, ?ViewContextInterface $context = null): string
287
    {
288
        if (\strncmp($view, '//', 2) === 0) {
289
            // path relative to basePath e.g. "//layouts/main"
290
            $file = $this->basePath . '/' . \ltrim($view, '/');
291
        } elseif ($context instanceof ViewContextInterface) {
292
            // path provided by context
293
            $file = $context->getViewPath() . '/' . $view;
294
        } elseif (($currentViewFile = $this->getRequestedViewFile()) !== false) {
295
            // path relative to currently rendered view
296
            $file = \dirname($currentViewFile) . '/' . $view;
0 ignored issues
show
Bug introduced by
It seems like $currentViewFile can also be of type true; however, parameter $path of dirname() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

296
            $file = \dirname(/** @scrutinizer ignore-type */ $currentViewFile) . '/' . $view;
Loading history...
297
        } else {
298
            throw new \RuntimeException("Unable to resolve view file for view '$view': no active view context.");
299
        }
300
301
        if (\pathinfo($file, PATHINFO_EXTENSION) !== '') {
302
            return $file;
303
        }
304
305
        $path = $file . '.' . $this->defaultExtension;
306
307
        if ($this->defaultExtension !== 'php' && !\is_file($path)) {
308
            $path = $file . '.php';
309
        }
310 8
311
        return $path;
312 8
    }
313
314
    /**
315 8
     * Renders a view file.
316
     *
317 8
     * If {@see theme} is enabled (not null), it will try to render the themed version of the view file as long as it
318 8
     * is available.
319
     *
320
     * If {@see renderers} is enabled (not null), the method will use it to render the view file. Otherwise,
321 8
     * it will simply include the view file as a normal PHP file, capture its output and
322 8
     * return it as a string.
323
     *
324
     * @param string $viewFile the view file. This can be either an absolute file path or an alias of it.
325
     * @param array $parameters the parameters (name-value pairs) that will be extracted and made available in the view
326
     * file.
327 8
     * @param ViewContextInterface|null $context the context that the view should use for rendering the view. If null,
328 8
     * existing {@see context} will be used.
329
     *
330
     * @return string the rendering result
331 8
     * @throws \Throwable
332 8
     *
333 8
     * @throws ViewNotFoundException if the view file does not exist
334 8
     */
335
    public function renderFile(string $viewFile, array $parameters = [], ?ViewContextInterface $context = null): string
336
    {
337 8
        $parameters = \array_merge($this->defaultParameters, $parameters);
338 8
339 8
        // TODO: these two match now
340 8
        $requestedFile = $viewFile;
341 8
342
        if (!empty($this->theme)) {
343 8
            $viewFile = $this->theme->applyTo($viewFile);
344
        }
345
346 8
        if (\is_file($viewFile)) {
347 8
            $viewFile = $this->localize($viewFile);
348
        } else {
349 8
            throw new ViewNotFoundException("The view file does not exist: $viewFile");
350
        }
351
352
        $oldContext = $this->context;
353
        if ($context !== null) {
354
            $this->context = $context;
355
        }
356
        $output = '';
357
        $this->viewFiles[] = [
358
            'resolved' => $viewFile,
359
            'requested' => $requestedFile,
360
        ];
361
362
        if ($this->beforeRender($viewFile, $parameters)) {
363
            $this->logger->debug("Rendering view file: $viewFile");
364
            $ext = \pathinfo($viewFile, PATHINFO_EXTENSION);
365
            $renderer = $this->renderers[$ext] ?? new PhpTemplateRenderer();
366
            $output = $renderer->render($this, $viewFile, $parameters);
367
368
            $output = $this->afterRender($viewFile, $parameters, $output);
369
        }
370 9
371
        \array_pop($this->viewFiles);
372 9
        $this->context = $oldContext;
373 9
374
        return $output;
375 9
    }
376 9
377
    /**
378 1
     * Returns the localized version of a specified file.
379 1
     *
380 1
     * The searching is based on the specified language code. In particular, a file with the same name will be looked
381
     * for under the subdirectory whose name is the same as the language code. For example, given the file
382
     * "path/to/view.php" and language code "zh-CN", the localized file will be looked for as path/to/zh-CN/view.php".
383
     * If the file is not found, it will try a fallback with just a language code that is "zh" i.e. "path/to/zh/view.php".
384
     * If it is not found as well the original file will be returned.
385
     *
386
     * If the target and the source language codes are the same, the original file will be returned.
387
     *
388
     * @param string $file the original file
389
     * @param string|null $language the target language that the file should be localized to.
390
     * @param string|null $sourceLanguage the language that the original file is in.
391
     *
392
     * @return string the matching localized file, or the original file if the localized version is not found.
393
     * If the target and the source language codes are the same, the original file will be returned.
394
     */
395 4
    public function localize(string $file, ?string $language = null, ?string $sourceLanguage = null): string
396
    {
397 4
        $language = $language ?? $this->language;
398
        $sourceLanguage = $sourceLanguage ?? $this->sourceLanguage;
399
400
        if ($language === $sourceLanguage) {
401
            return $file;
402
        }
403 1
        $desiredFile = \dirname($file) . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . \basename($file);
404
        if (\is_file($desiredFile)) {
405 1
            return $desiredFile;
406
        }
407
408
        $language = \substr($language, 0, 2);
409
        if ($language === $sourceLanguage) {
410
            return $file;
411
        }
412
        $desiredFile = \dirname($file) . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . \basename($file);
413
414
        return \is_file($desiredFile) ? $desiredFile : $file;
415
    }
416
417
    /**
418
     * @return string|bool the view file currently being rendered. False if no view file is being rendered.
419 8
     */
420
    public function getViewFile()
421 8
    {
422 8
        return empty($this->viewFiles) ? false : \end($this->viewFiles)['resolved'];
423
    }
424 8
425
    /**
426
     * @return string|bool the requested view currently being rendered. False if no view file is being rendered.
427
     */
428
    protected function getRequestedViewFile()
429
    {
430
        return empty($this->viewFiles) ? false : \end($this->viewFiles)['requested'];
431
    }
432
433
    /**
434
     * This method is invoked right before {@see renderFile()} renders a view file.
435
     *
436
     * The default implementation will trigger the {@see BeforeRender()} event. If you override this method, make sure
437
     * you call the parent implementation first.
438 8
     *
439
     * @param string $viewFile the view file to be rendered.
440 8
     * @param array $parameters the parameter array passed to the {@see render()} method.
441 8
     *
442
     * @return bool whether to continue rendering the view file.
443 8
     */
444
    public function beforeRender(string $viewFile, array $parameters): bool
445
    {
446
        $event = new BeforeRender($viewFile, $parameters);
447
        $event = $this->eventDispatcher->dispatch($event);
448
449
        return !$event->isPropagationStopped();
450
    }
451
452
    /**
453
     * This method is invoked right after {@see renderFile()} renders a view file.
454
     *
455
     * The default implementation will trigger the {@see AfterRender} event. If you override this method, make sure you
456
     * call the parent implementation first.
457
     *
458
     * @param string $viewFile the view file being rendered.
459
     * @param array $parameters the parameter array passed to the {@see render()} method.
460
     * @param string $output the rendering result of the view file. Updates to this parameter
461
     * will be passed back and returned by {@see renderFile()}.
462
     */
463
    public function afterRender(string $viewFile, array $parameters, &$output): string
464
    {
465
        $event = new AfterRender($viewFile, $parameters, $output);
466
        $event = $this->eventDispatcher->dispatch($event);
467
468
        return $event->getResult();
469
    }
470
471
    /**
472
     * Renders dynamic content returned by the given PHP statements.
473
     *
474
     * This method is mainly used together with content caching (fragment caching and page caching) when some portions
475
     * of the content (called *dynamic content*) should not be cached. The dynamic content must be returned by some PHP
476
     * statements. You can optionally pass additional parameters that will be available as variables in the PHP
477
     * statement:.
478
     *
479
     * ```php
480
     * <?= $this->renderDynamic('return foo($myVar);', [
481
     *     'myVar' => $model->getMyComplexVar(),
482
     * ]) ?>
483
     * ```
484
     *
485
     * @param string $statements the PHP statements for generating the dynamic content.
486
     * @param array $parameters the parameters (name-value pairs) that will be extracted and made
487
     * available in the $statement context. The parameters will be stored in the cache and be reused
488
     * each time $statement is executed. You should make sure, that these are safely serializable.
489
     *
490
     * @return string the placeholder of the dynamic content, or the dynamic content if there is no active content
491
     *                cache currently.
492
     */
493
    public function renderDynamic(string $statements, array $parameters = []): string
494
    {
495
        if (!empty($parameters)) {
496
            $statements = 'extract(unserialize(\'' . \str_replace(['\\', '\''], ['\\\\', '\\\''], \serialize($parameters)) . '\'));' . $statements;
497
        }
498
499
        if (!empty($this->cacheStack)) {
500
            $n = \count($this->dynamicPlaceholders);
501
            $placeholder = "<![CDATA[YII-DYNAMIC-$n-{$this->getPlaceholderDynamicSignature()}]]>";
502
            $this->addDynamicPlaceholder($placeholder, $statements);
503
504
            return $placeholder;
505
        }
506
507
        return $this->evaluateDynamicContent($statements);
508
    }
509
510
    /**
511
     * Get source locale.
512
     *
513
     * @return Locale
514
     */
515
    public function getSourceLocale(): Locale
516
    {
517
        if ($this->sourceLocale === null) {
518
            $this->sourceLocale = new Locale('en-US');
519
        }
520
521
        return $this->sourceLocale;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->sourceLocale could return the type null which is incompatible with the type-hinted return Yiisoft\I18n\Locale. Consider adding an additional type-check to rule them out.
Loading history...
522
    }
523
524
    /**
525
     * Set source locale.
526
     *
527
     * @param string $locale
528
     * @return self
529
     */
530
    public function setSourceLocale(string $locale): self
531
    {
532
        $this->sourceLocale = new Locale($locale);
533
534
        return $this;
535
    }
536
537
    public function getDynamicPlaceholders(): array
538
    {
539
        return $this->dynamicPlaceholders;
540
    }
541
542
    public function setDynamicPlaceholders(array $placeholders): void
543
    {
544
        $this->dynamicPlaceholders = $placeholders;
545
    }
546
547
    public function addDynamicPlaceholder(string $name, string $statements): void
548
    {
549
        foreach ($this->cacheStack as $cache) {
550
            $cache->addDynamicPlaceholder($name, $statements);
551
        }
552
553
        $this->dynamicPlaceholders[$name] = $statements;
554
    }
555
556
    /**
557
     * Evaluates the given PHP statements.
558
     *
559
     * This method is mainly used internally to implement dynamic content feature.
560
     *
561
     * @param string $statements the PHP statements to be evaluated.
562
     *
563
     * @return mixed the return value of the PHP statements.
564
     */
565
    public function evaluateDynamicContent(string $statements)
566
    {
567
        return eval($statements);
0 ignored issues
show
introduced by
The use of eval() is discouraged.
Loading history...
568
    }
569
570
    /**
571
     * Returns a list of currently active dynamic content class instances.
572
     *
573
     * @return DynamicContentAwareInterface[] class instances supporting dynamic contents.
574
     */
575
    public function getDynamicContents(): array
576
    {
577
        return $this->cacheStack;
578
    }
579
580
    /**
581
     * Adds a class instance supporting dynamic contents to the end of a list of currently active dynamic content class
582
     * instances.
583
     *
584 4
     * @param DynamicContentAwareInterface $instance class instance supporting dynamic contents.
585
     *
586 4
     * @return void
587 4
     */
588
    public function pushDynamicContent(DynamicContentAwareInterface $instance): void
589 4
    {
590 4
        $this->cacheStack[] = $instance;
591
    }
592
593
    /**
594
     * Removes a last class instance supporting dynamic contents from a list of currently active dynamic content class
595
     * instances.
596
     *
597
     * @return void
598
     */
599
    public function popDynamicContent(DynamicContentAwareInterface $instance = null): void
600
    {
601
        $popInstance = \array_pop($this->cacheStack);
602
        if ($instance !== null && $instance !== $popInstance) {
603 1
            throw new RuntimeException('Poped the element is not an expected element.');
604
        }
605
    }
606
607
    /**
608
     * Marks the beginning of a page.
609
     *
610
     * @return void
611
     */
612
    public function beginPage(): void
613
    {
614
        \ob_start();
615
        \ob_implicit_flush(0);
616
        $this->eventDispatcher->dispatch(new PageBegin($this->getViewFile()));
0 ignored issues
show
Bug introduced by
It seems like $this->getViewFile() can also be of type boolean; however, parameter $file of Yiisoft\View\Event\PageBegin::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

616
        $this->eventDispatcher->dispatch(new PageBegin(/** @scrutinizer ignore-type */ $this->getViewFile()));
Loading history...
617
    }
618
619
    /**
620
     * Marks the ending of a page.
621
     *
622
     * @return void
623
     */
624
    public function endPage(): void
625
    {
626
        $this->eventDispatcher->dispatch(new PageEnd($this->getViewFile()));
0 ignored issues
show
Bug introduced by
It seems like $this->getViewFile() can also be of type boolean; however, parameter $file of Yiisoft\View\Event\PageEnd::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

626
        $this->eventDispatcher->dispatch(new PageEnd(/** @scrutinizer ignore-type */ $this->getViewFile()));
Loading history...
627
        \ob_end_flush();
628
    }
629
630
    public function beginCache(string $id, array $params = [], array $vars = []): ?FragmentCache
631
    {
632
        $fc = $this->fragmentCache->beginCache($this, $id, $params, $vars);
633
        if ($fc->getStatus() === FragmentCacheInterface::STATUS_IN_CACHE) {
634
            $fc->endCache();
635
            return null;
636
        }
637
        return $fc;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $fc returns the type Yiisoft\View\FragmentCacheInterface which includes types incompatible with the type-hinted return Yiisoft\View\FragmentCache|null.
Loading history...
638
    }
639
}
640