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

Declare @deprecated on the stream wrapper functionality (will be removed in 3.0.0) #91

Merged
merged 3 commits into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
sasezaki marked this conversation as resolved.
Show resolved Hide resolved
*/
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 @@ -226,6 +230,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 @@ -247,6 +252,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