Skip to content

Commit

Permalink
Merge pull request #91 from sasezaki/deprecate_stream
Browse files Browse the repository at this point in the history
Declare `@deprecated` on the stream wrapper functionality (will be removed in `3.0.0`)
  • Loading branch information
Ocramius authored Dec 30, 2021
2 parents f3a3011 + 032ff7e commit b7d9617
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Resolver/TemplatePathStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function setOptions($options)
$this->addPaths($value);
break;
case 'use_stream_wrapper':
/** @psalm-suppress DeprecatedMethod */
$this->setUseStreamWrapper($value);
break;
case 'default_suffix':
Expand Down Expand Up @@ -247,6 +248,8 @@ public function isLfiProtectionOn()
*
* @param bool $flag
* @return TemplatePathStack
*
* @deprecated will be removed in version 3
*/
public function setUseStreamWrapper($flag)
{
Expand All @@ -261,6 +264,8 @@ public function setUseStreamWrapper($flag)
* is disabled.
*
* @return bool
*
* @deprecated will be removed in version 3
*/
public function useStreamWrapper()
{
Expand Down Expand Up @@ -307,6 +312,7 @@ public function resolve($name, Renderer $renderer = null)
break;
}
}
/** @psalm-suppress DeprecatedMethod */
if ($this->useStreamWrapper()) {
// If using a stream wrapper, prepend the spec to the path
$filePath = 'laminas.view://' . $filePath;
Expand Down
2 changes: 2 additions & 0 deletions src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* written by
* Mike Naberezny (@link http://mikenaberezny.com)
* Paul M. Jones (@link http://paul-m-jones.com)
*
* @deprecated will be removed in version 3, only the normal PHP tags (<?php ?> and <?= ?>) should be used
*/
class Stream
{
Expand Down
6 changes: 6 additions & 0 deletions test/Resolver/TemplatePathStackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function testMayDisableLfiProtection(): void

public function testStreamWrapperDisabledByDefault(): void
{
/** @psalm-suppress DeprecatedMethod */
$this->assertFalse($this->stack->useStreamWrapper());
}

Expand All @@ -113,7 +114,9 @@ public function testMayEnableStreamWrapper(): void
if (! $flag) {
$this->markTestSkipped('Short tags are disabled; cannot test');
}
/** @psalm-suppress DeprecatedMethod */
$this->stack->setUseStreamWrapper(true);
/** @psalm-suppress DeprecatedMethod */
$this->assertTrue($this->stack->useStreamWrapper());
}

Expand Down Expand Up @@ -162,6 +165,7 @@ public function testReturnsPathWithStreamProtocolWhenStreamWrapperEnabled(): voi
if (! $flag) {
$this->markTestSkipped('Short tags are disabled; cannot test');
}
/** @psalm-suppress DeprecatedMethod */
$this->stack->setUseStreamWrapper(true)
->addPath($this->baseDir . '/_templates');
$expected = 'laminas.view://' . realpath($this->baseDir . '/_templates/test.phtml');
Expand Down Expand Up @@ -222,6 +226,7 @@ public function testAllowsSettingOptions($options): void
$this->assertFalse($this->stack->isLfiProtectionOn());

$expected = (bool) ini_get('short_open_tag');
/** @psalm-suppress DeprecatedMethod */
$this->assertSame($expected, $this->stack->useStreamWrapper());

$this->assertSame($options['default_suffix'], $this->stack->getDefaultSuffix());
Expand All @@ -241,6 +246,7 @@ public function testAllowsPassingOptionsToConstructor($options): void
$this->assertFalse($stack->isLfiProtectionOn());

$expected = (bool) ini_get('short_open_tag');
/** @psalm-suppress DeprecatedMethod */
$this->assertSame($expected, $stack->useStreamWrapper());

$this->assertEquals(array_reverse($this->paths), $stack->getPaths()->toArray());
Expand Down

0 comments on commit b7d9617

Please sign in to comment.