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

Remove Stream Wrapper Functionality #129

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 2 additions & 30 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@
<code>false</code>
<code>false</code>
</FalsableReturnStatement>
<MixedArgument occurrences="4">
<MixedArgument occurrences="3">
<code>$value</code>
<code>$value</code>
<code>$value</code>
Expand All @@ -2063,7 +2063,7 @@
<NullArgument occurrences="1">
<code>$this-&gt;paths</code>
</NullArgument>
<RedundantCastGivenDocblockType occurrences="3">
<RedundantCastGivenDocblockType occurrences="2">
<code>(bool) $flag</code>
<code>(bool) $flag</code>
<code>(string) $defaultSuffix</code>
Expand Down Expand Up @@ -2120,34 +2120,6 @@
<code>plugin</code>
</UndefinedInterfaceMethod>
</file>
<file src="src/Stream.php">
<MissingConstructor occurrences="2">
<code>$data</code>
<code>$stat</code>
</MissingConstructor>
<MissingParamType occurrences="5">
<code>$mode</code>
<code>$offset</code>
<code>$opened_path</code>
<code>$options</code>
<code>$whence</code>
</MissingParamType>
<MixedAssignment occurrences="3">
<code>$this-&gt;pos</code>
<code>$this-&gt;pos</code>
<code>$this-&gt;pos</code>
</MixedAssignment>
<MixedOperand occurrences="3">
<code>$offset</code>
<code>$offset</code>
<code>$offset</code>
</MixedOperand>
<UnevaluatedCode occurrences="3">
<code>break;</code>
<code>break;</code>
<code>break;</code>
</UnevaluatedCode>
</file>
<file src="src/Variables.php">
<ArgumentTypeCoercion occurrences="1">
<code>'ArrayIterator'</code>
Expand Down
61 changes: 1 addition & 60 deletions src/Resolver/TemplatePathStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
use Laminas\Stdlib\SplStack;
use Laminas\View\Exception;
use Laminas\View\Renderer\RendererInterface as Renderer;
use Laminas\View\Stream;
use SplFileInfo;
use Traversable;

use function count;
use function file_exists;
use function get_class;
use function gettype;
use function in_array;
use function ini_get;
use function is_array;
use function is_object;
use function is_string;
Expand All @@ -25,8 +22,6 @@
use function preg_match;
use function rtrim;
use function sprintf;
use function stream_get_wrappers;
use function stream_wrapper_register;
use function strpos;
use function strtolower;

Expand Down Expand Up @@ -69,15 +64,6 @@ class TemplatePathStack implements ResolverInterface
*/
protected $lfiProtectionOn = true;

/**@+
* Flags used to determine if a stream wrapper should be used for enabling short tags
*/

/** @var bool */
protected $useViewStream = false;
/** @var bool */
protected $useStreamWrapper = false;

/**@-*/

/**
Expand All @@ -87,14 +73,6 @@ class TemplatePathStack implements ResolverInterface
*/
public function __construct($options = null)
{
$this->useViewStream = (bool) ini_get('short_open_tag');
if ($this->useViewStream) {
if (! in_array('laminas.view', stream_get_wrappers())) {
/** @psalm-suppress DeprecatedClass */
stream_wrapper_register('laminas.view', Stream::class);
}
}

/** @psalm-var PathStack $paths */
$paths = new SplStack();
$this->paths = $paths;
Expand Down Expand Up @@ -128,10 +106,6 @@ public function setOptions($options)
case 'script_paths':
$this->addPaths($value);
break;
case 'use_stream_wrapper':
/** @psalm-suppress DeprecatedMethod */
$this->setUseStreamWrapper($value);
break;
case 'default_suffix':
$this->setDefaultSuffix($value);
break;
Expand Down Expand Up @@ -283,35 +257,6 @@ public function isLfiProtectionOn()
return $this->lfiProtectionOn;
}

/**
* Set flag indicating if stream wrapper should be used if short_open_tag is off
*
* @deprecated will be removed in version 3
*
* @param bool $flag
* @return TemplatePathStack
*/
public function setUseStreamWrapper($flag)
{
$this->useStreamWrapper = (bool) $flag;
return $this;
}

/**
* Should the stream wrapper be used if short_open_tag is off?
*
* Returns true if the use_stream_wrapper flag is set, and if short_open_tag
* is disabled.
*
* @deprecated will be removed in version 3
*
* @return bool
*/
public function useStreamWrapper()
{
return $this->useViewStream && $this->useStreamWrapper;
}

/**
* Retrieve the filesystem path to a view script
*
Expand Down Expand Up @@ -351,11 +296,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;
}

return $filePath;
}
}
Expand Down
204 changes: 0 additions & 204 deletions src/Stream.php

This file was deleted.

Loading