diff --git a/README.md b/README.md
index d4eb109dd..3803c8e51 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,22 @@
[![Build Status](https://github.com/laminas/laminas-view/workflows/Continuous%20Integration/badge.svg)](https://github.com/laminas/laminas-view/actions?query=workflow%3A"Continuous+Integration")
+> ## π·πΊ Π ΡΡΡΠΊΠΈΠΌ Π³ΡΠ°ΠΆΠ΄Π°Π½Π°ΠΌ
+>
+> ΠΡ, ΡΡΠ°ΡΡΠ½ΠΈΠΊΠΈ Laminas, ΡΠΎΠ΄ΠΈΠ»ΠΈΡΡ ΠΈ ΠΆΠΈΠ²Π΅ΠΌ Π² ΡΠ°Π·Π½ΡΡ
ΡΡΡΠ°Π½Π°Ρ
. Π£ ΠΌΠ½ΠΎΠ³ΠΈΡ
ΠΈΠ· Π½Π°Ρ Π΅ΡΡΡ Π΄ΡΡΠ·ΡΡ, ΡΠΎΠ΄ΡΡΠ²Π΅Π½Π½ΠΈΠΊΠΈ ΠΈ ΠΊΠΎΠ»Π»Π΅Π³ΠΈ ΠΊΠ°ΠΊ Π² Π ΠΎΡΡΠΈΠΈ, ΡΠ°ΠΊ ΠΈ Π² Π£ΠΊΡΠ°ΠΈΠ½Π΅. ΠΠ΅ΠΊΠΎΡΠΎΡΡΠ΅ ΠΈΠ· Π½Π°Ρ ΡΠΎΠ΄ΠΈΠ»ΠΈΡΡ Π² Π ΠΎΡΡΠΈΠΈ. ΠΠ΅ΠΊΠΎΡΠΎΡΡΠ΅ ΠΈΠ· Π½Π°Ρ ΠΆΠΈΠ²ΡΡ Π² Π ΠΎΡΡΠΈΠΈ. Π£ Π½Π΅ΠΊΠΎΡΠΎΡΡΡ
Π±Π°Π±ΡΡΠΊΠΈ ΠΈ Π΄Π΅Π΄ΡΡΠΊΠΈ ΡΡΠ°ΠΆΠ°Π»ΠΈΡΡ Ρ ΡΠ°ΡΠΈΡΡΠ°ΠΌΠΈ Π²ΠΎ ΠΡΠΎΡΠΎΠΉ ΠΌΠΈΡΠΎΠ²ΠΎΠΉ Π²ΠΎΠΉΠ½Π΅. ΠΠ΄Π΅ΡΡ Π½ΠΈΠΊΡΠΎ Π½Π΅ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ ΡΠ°ΡΠΈΠ·ΠΌ.
+>
+> Π£ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΈΠ· Π½Π°Ρ Π΅ΡΡΡ ΡΠΊΡΠ°ΠΈΠ½ΡΠΊΠ°Ρ ΡΠΎΠ΄ΡΡΠ²Π΅Π½Π½ΠΈΡΠ°, ΠΊΠΎΡΠΎΡΠ°Ρ ΡΠΏΠ°ΡΠ»Π°ΡΡ ΠΈΠ· Π΄ΠΎΠΌΠ° Π²ΠΌΠ΅ΡΡΠ΅ Ρ ΡΡΠ½ΠΎΠΌ. ΠΠΎΠ΅Π·Π΄ Π·Π°Π΄Π΅ΡΠΆΠ°Π»ΡΡ ΠΈΠ·-Π·Π° Π±ΠΎΠΌΠ±Π΅ΠΆΠΊΠΈ Π½Π° Π΄ΠΎΡΠΎΠ³Π΅ Π²ΠΏΠ΅ΡΠ΅Π΄ΠΈ. Π£ Π½Π°Ρ Π΅ΡΡΡ Π΄ΡΡΠ·ΡΡ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΡΡΡΡΡΡΡ Π² Π±ΠΎΠΌΠ±ΠΎΡΠ±Π΅ΠΆΠΈΡΠ°Ρ
. ΠΡ Ρ ΡΡΠ΅Π²ΠΎΠ³ΠΎΠΉ ΠΆΠ΄Π΅ΠΌ Π²Π΅ΡΡΠΎΡΠΊΠΈ ΠΎΡ Π½ΠΈΡ
ΠΏΠΎΡΠ»Π΅ Π²ΠΎΠ·Π΄ΡΡΠ½ΡΡ
Π½Π°Π»Π΅ΡΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ Π±Π΅ΡΠΏΠΎΡΡΠ΄ΠΎΡΠ½ΠΎ Π½Π°Π½ΠΎΡΡΡ ΡΠ΄Π°ΡΡ ΠΈ ΠΏΠΎΠΏΠ°Π΄Π°ΡΡ ΠΏΠΎ Π±ΠΎΠ»ΡΠ½ΠΈΡΠ°ΠΌ, ΡΠΊΠΎΠ»Π°ΠΌ, Π΄Π΅ΡΡΠΊΠΈΠΌ ΡΠ°Π΄Π°ΠΌ ΠΈ Π΄ΠΎΠΌΠ°ΠΌ. ΠΡ Π½Π΅ Π±Π΅ΡΠ΅ΠΌ ΡΡΠΎ ΠΈΠ· ΠΊΠ°ΠΊΠΈΡ
-Π»ΠΈΠ±ΠΎ Π‘ΠΠ. ΠΡ Π½Π°Π±Π»ΡΠ΄Π°Π΅ΠΌ ΡΡΠΎ Π½Π°ΠΏΡΡΠΌΡΡ.
+>
+> ΠΡ Π΄ΠΎΠ²Π΅ΡΡΠ΅ΡΠ΅ Π½Π°ΠΌ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ, ΡΡΠΎΠ± ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π½Π°ΡΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ, ΠΈ ΠΌΡ ΠΏΡΠΎΡΠΈΠΌ Π²Π°Ρ Π΄ΠΎΠ²Π΅ΡΠΈΡΡΡΡ Π½Π°ΠΌ Π²Π½ΠΎΠ²Ρ. ΠΡ Π½ΡΠΆΠ΄Π°Π΅ΠΌΡΡ Π² ΠΏΠΎΠΌΠΎΡΠΈ. ΠΡΡ
ΠΎΠ΄ΠΈΡΠ΅ ΠΈ ΠΏΡΠΎΡΠ΅ΡΡΡΠΉΡΠ΅ ΠΏΡΠΎΡΠΈΠ² ΡΡΠΎΠΉ Π±Π΅ΡΠΏΠΎΠ»Π΅Π·Π½ΠΎΠΉ Π²ΠΎΠΉΠ½Ρ. ΠΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ ΠΊΡΠΎΠ²ΠΎΠΏΡΠΎΠ»ΠΈΡΠΈΠ΅. Π‘ΠΊΠ°ΠΆΠΈΡΠ΅ "ΠΠ΅Ρ Π²ΠΎΠΉΠ½Π΅!"
+>
+> ## πΊπΈ To Citizens of Russia
+>
+> We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.
+>
+> One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.
+>
+> You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"
+
laminas-view provides the βViewβ layer of the Laminas MVC system. It is a
multi-tiered system allowing a variety of mechanisms for extension,
substitution, and more.
diff --git a/composer.json b/composer.json
index a0c578c6c..b646bff3a 100644
--- a/composer.json
+++ b/composer.json
@@ -21,7 +21,8 @@
"php": "8.1.99"
},
"allow-plugins": {
- "dealerdirect/phpcodesniffer-composer-installer": true
+ "dealerdirect/phpcodesniffer-composer-installer": true,
+ "composer/package-versions-deprecated": true
}
},
"require": {
@@ -46,7 +47,6 @@
"laminas/laminas-modulemanager": "^2.14",
"laminas/laminas-mvc": "^3.6.1",
"laminas/laminas-mvc-i18n": "^1.7",
- "laminas/laminas-mvc-plugin-flashmessenger": "^1.9",
"laminas/laminas-navigation": "^2.18.1",
"laminas/laminas-paginator": "^2.17",
"laminas/laminas-permissions-acl": "^2.15",
diff --git a/composer.lock b/composer.lock
index 74c75ded1..01d04bac4 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "d8c4880e9375fc4df0bb44fdb9436bf2",
+ "content-hash": "6f4f1dcd9aabd89a90c6f0ad6d25cc20",
"packages": [
{
"name": "laminas/laminas-escaper",
@@ -1972,75 +1972,6 @@
],
"time": "2022-12-02T15:45:50+00:00"
},
- {
- "name": "laminas/laminas-mvc-plugin-flashmessenger",
- "version": "1.9.0",
- "source": {
- "type": "git",
- "url": "https://github.com/laminas/laminas-mvc-plugin-flashmessenger.git",
- "reference": "dc73bb6b56a0d74f9fdc0d24ec55a5f8c87c4cfa"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-mvc-plugin-flashmessenger/zipball/dc73bb6b56a0d74f9fdc0d24ec55a5f8c87c4cfa",
- "reference": "dc73bb6b56a0d74f9fdc0d24ec55a5f8c87c4cfa",
- "shasum": ""
- },
- "require": {
- "laminas/laminas-mvc": "^3.3",
- "laminas/laminas-session": "^2.12.0",
- "laminas/laminas-stdlib": "^3.6.4",
- "laminas/laminas-view": "^2.13.1",
- "php": "~8.0.0 || ~8.1.0 || ~8.2.0"
- },
- "conflict": {
- "laminas/laminas-mvc": "<3.0.0",
- "zendframework/zend-mvc-plugin-flashmessenger": "*"
- },
- "require-dev": {
- "laminas/laminas-coding-standard": "~2.4.0",
- "laminas/laminas-i18n": "^2.19.0",
- "phpunit/phpunit": "^9.5.25",
- "psalm/plugin-phpunit": "^0.17.0",
- "vimeo/psalm": "^4.29.0"
- },
- "type": "library",
- "extra": {
- "laminas": {
- "component": "Laminas\\Mvc\\Plugin\\FlashMessenger"
- }
- },
- "autoload": {
- "psr-4": {
- "Laminas\\Mvc\\Plugin\\FlashMessenger\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "description": "Plugin for creating and exposing flash messages via laminas-mvc controllers",
- "homepage": "https://laminas.dev",
- "keywords": [
- "laminas",
- "mvc"
- ],
- "support": {
- "chat": "https://laminas.dev/chat",
- "docs": "https://docs.laminas.dev/laminas-mvc-plugin-flashmessenger/",
- "forum": "https://discourse.laminas.dev",
- "issues": "https://github.com/laminas/laminas-mvc-plugin-flashmessenger/issues",
- "rss": "https://github.com/laminas/laminas-mvc-plugin-flashmessenger/releases.atom",
- "source": "https://github.com/laminas/laminas-mvc-plugin-flashmessenger"
- },
- "funding": [
- {
- "url": "https://funding.communitybridge.org/projects/laminas-project",
- "type": "community_bridge"
- }
- ],
- "time": "2022-10-22T12:47:30+00:00"
- },
{
"name": "laminas/laminas-navigation",
"version": "2.18.1",
@@ -2336,87 +2267,6 @@
],
"time": "2022-12-29T14:47:23+00:00"
},
- {
- "name": "laminas/laminas-session",
- "version": "2.16.0",
- "source": {
- "type": "git",
- "url": "https://github.com/laminas/laminas-session.git",
- "reference": "9c845a0361625d5775cad6f043716196201ad41f"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-session/zipball/9c845a0361625d5775cad6f043716196201ad41f",
- "reference": "9c845a0361625d5775cad6f043716196201ad41f",
- "shasum": ""
- },
- "require": {
- "laminas/laminas-eventmanager": "^3.5",
- "laminas/laminas-servicemanager": "^3.15.1",
- "laminas/laminas-stdlib": "^3.10.1",
- "php": "~8.0.0 || ~8.1.0 || ~8.2.0"
- },
- "conflict": {
- "zendframework/zend-session": "*"
- },
- "require-dev": {
- "laminas/laminas-cache": "^3.8",
- "laminas/laminas-cache-storage-adapter-memory": "^2.2",
- "laminas/laminas-coding-standard": "~2.4.0",
- "laminas/laminas-db": "^2.15",
- "laminas/laminas-http": "^2.17.1",
- "laminas/laminas-validator": "^2.28",
- "mongodb/mongodb": "~1.13.0",
- "phpunit/phpunit": "^9.5.26",
- "psalm/plugin-phpunit": "^0.18.0",
- "vimeo/psalm": "^5.0"
- },
- "suggest": {
- "laminas/laminas-cache": "Laminas\\Cache component",
- "laminas/laminas-db": "Laminas\\Db component",
- "laminas/laminas-http": "Laminas\\Http component",
- "laminas/laminas-servicemanager": "Laminas\\ServiceManager component",
- "laminas/laminas-validator": "Laminas\\Validator component",
- "mongodb/mongodb": "If you want to use the MongoDB session save handler"
- },
- "type": "library",
- "extra": {
- "laminas": {
- "component": "Laminas\\Session",
- "config-provider": "Laminas\\Session\\ConfigProvider"
- }
- },
- "autoload": {
- "psr-4": {
- "Laminas\\Session\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "description": "Object-oriented interface to PHP sessions and storage",
- "homepage": "https://laminas.dev",
- "keywords": [
- "laminas",
- "session"
- ],
- "support": {
- "chat": "https://laminas.dev/chat",
- "docs": "https://docs.laminas.dev/laminas-session/",
- "forum": "https://discourse.laminas.dev",
- "issues": "https://github.com/laminas/laminas-session/issues",
- "rss": "https://github.com/laminas/laminas-session/releases.atom",
- "source": "https://github.com/laminas/laminas-session"
- },
- "funding": [
- {
- "url": "https://funding.communitybridge.org/projects/laminas-project",
- "type": "community_bridge"
- }
- ],
- "time": "2022-12-04T11:15:36+00:00"
- },
{
"name": "laminas/laminas-uri",
"version": "2.10.0",
diff --git a/docs/book/helpers/flash-messenger.md b/docs/book/helpers/flash-messenger.md
deleted file mode 100644
index 95a21fb99..000000000
--- a/docs/book/helpers/flash-messenger.md
+++ /dev/null
@@ -1,146 +0,0 @@
-# FlashMessenger
-
-The `FlashMessenger` helper is used to render the messages of the
-[FlashMessenger MVC plugin](https://docs.laminas.dev/laminas-mvc-plugin-flashmessenger/).
-
-## Basic Usage
-
-When only using the default `namespace` for the `FlashMessenger`, you can do the
-following:
-
-```php
-// Usable in any of your .phtml files
-echo $this->flashMessenger()->render();
-```
-
-The first argument of the `render()` function is the `namespace`. If no
-`namespace` is defined, the default
-`Laminas\Mvc\Controller\Plugin\FlashMessenger::NAMESPACE_DEFAULT` will be used,
-which translates to `default`.
-
-```php
-// Usable in any of your .phtml files
-echo $this->flashMessenger()->render('error');
-
-// Alternatively use one of the pre-defined namespaces
-// (aka: use Laminas\Mvc\Controller\Plugin\FlashMessenger;)
-echo $this->flashMessenger()->render(FlashMessenger::NAMESPACE_SUCCESS);
-```
-
-## CSS Layout
-
-The `FlashMessenger` default rendering adds a CSS class to the generated HTML,
-that matches the defined `namespace` that should be rendered. While it may work
-well for the default cases, every so often you may want to add specific CSS
-classes to the HTML output. This can be done while making use of the second
-parameter of the `render()` function.
-
-```php
-// Usable in any of your .phtml files
-echo $this->flashMessenger()->render('error', ['alert', 'alert-danger']);
-```
-
-The output of this example, using the default HTML rendering settings, would
-look like this:
-
-```html
-
- Some FlashMessenger Content
- You, the developer, are AWESOME!
-
-```
-
-## HTML Layout
-
-Aside from modifying the rendered CSS classes of the `FlashMessenger`, you are
-furthermore able to modify the generated HTML as a whole to create even more
-distinct visuals for your flash messages. The default output format is defined
-within the source code of the `FlashMessenger` view helper itself.
-
-```php
-// Laminas/View/Helper/FlashMessenger.php#L41-L43
-protected $messageCloseString = '';
-protected $messageOpenFormat = '';
-protected $messageSeparatorString = ' ';
-```
-
-These defaults exactly match what we're trying to do. The placeholder `%s` will
-be filled with the CSS classes output.
-
-To change this, all we need to do is call the respective setter methods of these
-variables and give them new strings; for example:
-
-```php
-// In any of your .phtml files:
-echo $this->flashMessenger()
- ->setMessageOpenFormat('')
- ->setMessageSeparatorString('
')
- ->setMessageCloseString('
')
- ->render('success');
-```
-
-The above code sample then would then generate the following output:
-
-```html
-
-
Some FlashMessenger Content
-
You, who's reading the docs, are AWESOME!
-
-```
-
-## Sample Modification for Twitter Bootstrap 3
-
-Taking all the above knowledge into account, we can create a nice, highly usable
-and user-friendly rendering strategy using the
-[Bootstrap front-end framework](http://getbootstrap.com/) version 3 layouts:
-
-```php
-// In any of your .phtml files:
-$flash = $this->flashMessenger();
-$flash->setMessageOpenFormat('
-
- ×
-
-
')
- ->setMessageSeparatorString(' ')
- ->setMessageCloseString(' ');
-
-echo $flash->render('error', ['alert', 'alert-dismissible', 'alert-danger']);
-echo $flash->render('info', ['alert', 'alert-dismissible', 'alert-info']);
-echo $flash->render('default', ['alert', 'alert-dismissible', 'alert-warning']);
-echo $flash->render('success', ['alert', 'alert-dismissible', 'alert-success']);
-```
-
-The output of the above example would create dismissable `FlashMessages` with
-the following HTML markup. The example only covers one type of `FlashMessenger`
-output; if you would have several `FlashMessages` available in each of the
-rendered `namespaces`, then you would receive the same output multiple times
-only having different CSS classes applied.
-
-```html
-
-
Γ
-
- Some FlashMessenger Content
- You, who's reading the docs, are AWESOME!
-
-
-```
-
-## Alternative Configuration of the ViewHelper Layout
-
-`Laminas\View\Helper\Service\FlashMessengerFactory` checks the application
-configuration, making it possible to set up the `FlashMessenger` strings through
-your `module.config.php`, too. The next example will set up the output to be
-identical with the above Twitter Bootstrap 3 Example
-
-```php
-'view_helper_config' => [
- 'flashmessenger' => [
- 'message_open_format' => '× ',
- 'message_close_string' => ' ',
- 'message_separator_string' => ' ',
- ],
-],
-```
diff --git a/docs/book/helpers/html-object.md b/docs/book/helpers/html-object.md
index 276a4a076..ba1ecfa18 100644
--- a/docs/book/helpers/html-object.md
+++ b/docs/book/helpers/html-object.md
@@ -2,12 +2,10 @@
The [HTML `` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object) is used for embedding external media in web pages. The object view helpers take care of embedding media with minimum effort.
-There are four initial Object helpers:
+There are two initial Object helpers:
- `htmlObject()` Generates markup for embedding a custom Object.
- `htmlPage()` Generates markup for embedding other (X)HTML pages.
-- `htmlFlash()` Generates markup for embedding Flash files. _**Deprecated**_
-- `htmlQuicktime()` Generates markup for embedding QuickTime files. _**Deprecated**_
All of these helpers share a similar interface. For this reason, this
documentation will only contain examples of two of these helpers.
diff --git a/docs/book/helpers/intro.md b/docs/book/helpers/intro.md
index c8ad11eb4..3ecc17dae 100644
--- a/docs/book/helpers/intro.md
+++ b/docs/book/helpers/intro.md
@@ -60,7 +60,6 @@ for, and rendering, the various HTML `` tags, such as `HeadTitle`,
- [BasePath](base-path.md)
- [Cycle](cycle.md)
- [Doctype](doctype.md)
-- [FlashMessenger](flash-messenger.md)
- [Gravatar](gravatar.md) _(Deprecated)_
- [GravatarImage](gravatar-image.md)
- [HeadLink](head-link.md)
@@ -110,6 +109,12 @@ for, and rendering, the various HTML `` tags, such as `HeadTitle`,
> [Paginator Usage](https://docs.laminas.dev/laminas-paginator/usage/#rendering-pages-with-view-scripts)
> documentation.
+> ### FlashMessenger helper
+>
+> View helper related to **Flash Messenger** is documented in the
+> [FLash Messenger View Helper](https://docs.laminas.dev/laminas-mvc-plugin-flashmessenger/view-helper/)
+> documentation.
+
> ### Custom Helpers
>
> For documentation on writing **custom view helpers** see the
diff --git a/docs/book/helpers/json.md b/docs/book/helpers/json.md
index 4a4056a02..655a9f788 100644
--- a/docs/book/helpers/json.md
+++ b/docs/book/helpers/json.md
@@ -19,29 +19,3 @@ determine how to handle the content.
```php
= $this->json($this->data) ?>
```
-
-> WARNING: **Deprecated**
->
-> ### Enabling encoding using Laminas\Json\Expr
->
-> **This feature of the Json view helper has been deprecated in version 2.16 and will be removed in version 3.0.**
->
-> The JSON helper accepts an array of options that will be passed to `Laminas\Json\Json::encode()` and
-> used internally to encode data.
-> `Laminas\Json\Json::encode` allows the encoding of native JSON expressions using `Laminas\Json\Expr`
-> objects. This option is disabled by default. To enable this option, pass a boolean `true` to the
-> `enableJsonExprFinder` key of the options array:
->
-> ```php
-> = $this->json($this->data, ['enableJsonExprFinder' => true]) ?>
-> ``
->
-> The JSON helper accepts an array of options that will be passed to `Laminas\Json\Json::encode()` and
-> used internally to encode data.
-> `Laminas\Json\Json::encode` allows the encoding of native JSON expressions using `Laminas\Json\Expr`
-> objects. This option is disabled by default. To enable this option, pass a boolean `true` to the
-> `enableJsonExprFinder` key of the options array:
->
-> ```php
-> = $this->json($this->data, ['enableJsonExprFinder' => true]) ?>
-> ```
diff --git a/mkdocs.yml b/mkdocs.yml
index 2f7336948..f2ffae6e5 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -14,7 +14,6 @@ nav:
- Cycle: helpers/cycle.md
- Doctype: helpers/doctype.md
- Escape: helpers/escape.md
- - FlashMessenger: helpers/flash-messenger.md
- Gravatar: helpers/gravatar.md
- HeadLink: helpers/head-link.md
- HeadMeta: helpers/head-meta.md
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 5f350fdfa..54e709c03 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -146,46 +146,6 @@
$value[$k]
-
-
- pluginFlashMessenger]]>
-
-
- $item
-
-
- $escapeHtmlHelper
- $pluginFlashMessenger
-
-
- $item
- $messagesToPrint
-
-
- $classes
- $classes
-
-
- $messagesToPrint[]
- $messagesToPrint[]
-
-
- $classes
- $classes
- $messagesToPrint[]
- $messagesToPrint[]
- escapeHtmlHelper]]>
-
-
- (bool) $autoEscape
- (string) $messageCloseString
- (string) $messageOpenFormat
- (string) $messageSeparatorString
-
-
- escapeHtmlHelper]]>
-
-
$flag === null
@@ -416,26 +376,6 @@
is_string($content)
-
-
- $htmlObject
-
-
- $htmlObject($data, self::TYPE, $attribs, $params, $content)
-
-
- string
-
-
- $htmlObject($data, self::TYPE, $attribs, $params, $content)
-
-
- plugin
-
-
- plugin
-
-
is_array($content)
@@ -468,26 +408,6 @@
plugin
-
-
- $htmlObject
-
-
- $htmlObject($data, self::TYPE, $attribs, $params, $content)
-
-
- string
-
-
- $htmlObject($data, self::TYPE, $attribs, $params, $content)
-
-
- plugin
-
-
- plugin
-
-
$value
@@ -505,17 +425,6 @@
(bool) $useNamespaces
-
-
- $response
-
-
- null
-
-
- response instanceof Response]]>
-
-
plugin
@@ -1089,7 +998,6 @@
(string) $key
(string) $key
(string) $key
- (string) $name
containerClass($value)]]>
@@ -1149,9 +1057,6 @@
-
- null === static::$instance
-
containerClass($value)]]>
@@ -1174,9 +1079,6 @@
(string) $key
(string) $key
-
- new static()
-
@@ -1256,11 +1158,6 @@
-
-
- $cName
-
-
@@ -1273,50 +1170,7 @@
$config
-
-
- FlashMessenger
- FlashMessenger
- new FlashMessenger()
-
-
- FlashMessengerFactory
-
-
-
-
-
- $flashMessenger
-
-
-
-
-
-
-
-
-
- $config
- $configHelper
- $controllerPluginManager
- $flashMessenger
-
-
- get
-
-
- $container
-
-
- $requestedName
-
-
-
- $this
- $this
- $this
-
(bool) $enabled
@@ -1403,17 +1257,6 @@
clearVariables
-
-
- int
-
-
- options['errorLevel']]]>
-
-
- $captureTo
-
-
type]]>
@@ -1497,29 +1340,6 @@
is_object($variables)
-
-
- $values
-
-
- $child
-
-
- $child
- $setting
- $value
-
-
- $setting
- getFilterChain()->filter($values['result'])]]>
-
-
- $model
-
-
- $values
-
-
@@ -1535,9 +1355,6 @@
-
- void
-
$jsonpCallback
@@ -1796,34 +1613,6 @@
plugin
-
-
- $data
- $stat
-
-
- $mode
- $offset
- $opened_path
- $options
- $whence
-
-
- pos]]>
- pos]]>
- pos]]>
-
-
- $offset
- $offset
- $offset
-
-
- break;
- break;
- break;
-
-
Variables
@@ -1979,75 +1768,6 @@
$test
-
-
- $plugin
- $plugin
- mvcPluginClass]]>
-
-
- FlashMessenger
- [
- 'config' => $config,
- ],
- 'factories' => [
- 'ControllerPluginManager' => fn(ContainerInterface $services) => new PluginManager($services, [
- 'invokables' => [
- 'flashmessenger' => $this->mvcPluginClass,
- ],
- ]),
- 'ViewHelperManager' => static fn(ContainerInterface $services)
- => new HelperPluginManager($services),
- ],
- ])]]>
- new FlashMessenger()
- new FlashMessenger()
- new FlashMessenger()
- new FlashMessenger()
- new FlashMessenger()
- new FlashMessenger()
-
-
- $displayInfo
- $displayInfo
- $displayInfo
- $displayInfo
- $helper
- $helper
- $helper
- $helper
- $helperPluginManager
- $helperPluginManager
- $helperPluginManager
- $helperPluginManager
-
-
- get
- get
- get
- get
- render
- render
- renderCurrent
- renderCurrent
-
-
- hasCurrentErrorMessages
- hasCurrentInfoMessages
- hasCurrentMessages
- hasCurrentSuccessMessages
- hasErrorMessages
- hasInfoMessages
- hasMessages
- hasSuccessMessages
- hasWarningMessages
- render
- render
- renderCurrent
- renderCurrent
-
-
$value
@@ -2145,11 +1865,6 @@
offsetSetName
-
-
- HtmlFlash
-
-
$escape($value)
diff --git a/src/Helper/AbstractHtmlElement.php b/src/Helper/AbstractHtmlElement.php
index e14a39ef0..cfa18d2bc 100644
--- a/src/Helper/AbstractHtmlElement.php
+++ b/src/Helper/AbstractHtmlElement.php
@@ -11,17 +11,8 @@
use function substr;
use function trim;
-use const PHP_EOL;
-
abstract class AbstractHtmlElement extends AbstractHelper
{
- /**
- * EOL character
- *
- * @deprecated just use PHP_EOL
- */
- public const EOL = PHP_EOL;
-
/**
* The tag closing bracket
*
diff --git a/src/Helper/Asset.php b/src/Helper/Asset.php
index 34deac7a0..86471f7fc 100644
--- a/src/Helper/Asset.php
+++ b/src/Helper/Asset.php
@@ -11,15 +11,11 @@
/**
* View helper plugin to fetch asset from resource map.
- *
- * @final
*/
-class Asset extends AbstractHelper
+final class Asset
{
- use DeprecatedAbstractHelperHierarchyTrait;
-
/** @var array */
- protected $resourceMap = [];
+ private array $resourceMap;
/**
* @param array $resourceMap
@@ -34,7 +30,7 @@ public function __construct(array $resourceMap = [])
* @return non-empty-string
* @throws Exception\InvalidArgumentException
*/
- public function __invoke($asset)
+ public function __invoke(string $asset): string
{
if (! array_key_exists($asset, $this->resourceMap)) {
throw new Exception\InvalidArgumentException(sprintf(
@@ -45,29 +41,4 @@ public function __invoke($asset)
return $this->resourceMap[$asset];
}
-
- /**
- * @deprecated since 2.20.0, this method will be removed in version 3.0.0 of this component.
- * The Resource map should be provided to the constructor from version 3.0
- *
- * @param array $resourceMap
- * @return $this
- */
- public function setResourceMap(array $resourceMap)
- {
- $this->resourceMap = $resourceMap;
-
- return $this;
- }
-
- /**
- * @deprecated since 2.20.0, this method will be removed in version 3.0.0 of this component.
- * Runtime retrieval of the resource map from the view will be removed without replacement.
- *
- * @return array
- */
- public function getResourceMap()
- {
- return $this->resourceMap;
- }
}
diff --git a/src/Helper/FlashMessenger.php b/src/Helper/FlashMessenger.php
deleted file mode 100644
index 73d83f89a..000000000
--- a/src/Helper/FlashMessenger.php
+++ /dev/null
@@ -1,353 +0,0 @@
- 'info',
- 'error' => 'error',
- 'success' => 'success',
- 'default' => 'default',
- 'warning' => 'warning',
- ];
-
- /**
- * Templates for the open/close/separators for message tags
- *
- * @var string
- */
- protected $messageCloseString = ' ';
- /** @var string */
- protected $messageOpenFormat = '';
- /** @var string */
- protected $messageSeparatorString = ' ';
-
- /**
- * Flag whether to escape messages
- *
- * @var bool
- */
- protected $autoEscape = true;
-
- /**
- * Html escape helper
- *
- * @var EscapeHtml
- */
- protected $escapeHtmlHelper;
-
- /**
- * Flash messenger plugin
- *
- * @var PluginFlashMessenger
- */
- protected $pluginFlashMessenger;
-
- /**
- * Returns the flash messenger plugin controller
- *
- * @param string|null $namespace
- * @return array|static
- */
- public function __invoke($namespace = null)
- {
- if (null === $namespace) {
- return $this;
- }
- $flashMessenger = $this->getPluginFlashMessenger();
-
- return $flashMessenger->getMessagesFromNamespace($namespace);
- }
-
- /**
- * Proxy the flash messenger plugin controller
- *
- * @param string $method
- * @param array $argv
- * @return mixed
- */
- public function __call($method, $argv)
- {
- $flashMessenger = $this->getPluginFlashMessenger();
- return call_user_func_array([$flashMessenger, $method], $argv);
- }
-
- /**
- * Render Messages
- *
- * @param string $namespace
- * @param array $classes
- * @param null|bool $autoEscape
- * @return string
- */
- public function render($namespace = 'default', array $classes = [], $autoEscape = null)
- {
- $flashMessenger = $this->getPluginFlashMessenger();
- $messages = $flashMessenger->getMessagesFromNamespace($namespace);
- return $this->renderMessages($namespace, $messages, $classes, $autoEscape);
- }
-
- /**
- * Render Current Messages
- *
- * @param string $namespace
- * @param array $classes
- * @param bool|null $autoEscape
- * @return string
- */
- public function renderCurrent($namespace = 'default', array $classes = [], $autoEscape = null)
- {
- $flashMessenger = $this->getPluginFlashMessenger();
- $messages = $flashMessenger->getCurrentMessagesFromNamespace($namespace);
- return $this->renderMessages($namespace, $messages, $classes, $autoEscape);
- }
-
- /**
- * Render Messages
- *
- * @param string $namespace
- * @param array $messages
- * @param array $classes
- * @param bool|null $autoEscape
- * @return string
- */
- protected function renderMessages(
- $namespace = 'default',
- array $messages = [],
- array $classes = [],
- $autoEscape = null
- ) {
- if (empty($messages)) {
- return '';
- }
-
- // Prepare classes for opening tag
- if (empty($classes)) {
- if (isset($this->classMessages[$namespace])) {
- $classes = $this->classMessages[$namespace];
- } else {
- $classes = $this->classMessages['default'];
- }
- $classes = [$classes];
- }
-
- if (null === $autoEscape) {
- $autoEscape = $this->getAutoEscape();
- }
-
- // Flatten message array
- $escapeHtml = $this->getEscapeHtmlHelper();
- $messagesToPrint = [];
- $translator = $this->getTranslator();
- $translatorTextDomain = $this->getTranslatorTextDomain();
- array_walk_recursive(
- $messages,
- function ($item) use (&$messagesToPrint, $escapeHtml, $autoEscape, $translator, $translatorTextDomain) {
- if ($translator !== null) {
- $item = $translator->translate(
- $item,
- $translatorTextDomain
- );
- }
-
- if ($autoEscape) {
- $messagesToPrint[] = $escapeHtml($item);
- return;
- }
-
- $messagesToPrint[] = $item;
- }
- );
-
- if (empty($messagesToPrint)) {
- return '';
- }
-
- // Generate markup
- $markup = sprintf($this->getMessageOpenFormat(), ' class="' . implode(' ', $classes) . '"');
- $markup .= implode(
- sprintf($this->getMessageSeparatorString(), ' class="' . implode(' ', $classes) . '"'),
- $messagesToPrint
- );
- $markup .= $this->getMessageCloseString();
- return $markup;
- }
-
- /**
- * Set whether or not auto escaping should be used
- *
- * @param bool $autoEscape
- * @return self
- */
- public function setAutoEscape($autoEscape = true)
- {
- $this->autoEscape = (bool) $autoEscape;
- return $this;
- }
-
- /**
- * Return whether auto escaping is enabled or disabled
- *
- * @return bool
- */
- public function getAutoEscape()
- {
- return $this->autoEscape;
- }
-
- /**
- * Set the string used to close message representation
- *
- * @param string $messageCloseString
- * @return FlashMessenger
- */
- public function setMessageCloseString($messageCloseString)
- {
- $this->messageCloseString = (string) $messageCloseString;
- return $this;
- }
-
- /**
- * Get the string used to close message representation
- *
- * @return string
- */
- public function getMessageCloseString()
- {
- return $this->messageCloseString;
- }
-
- /**
- * Set the formatted string used to open message representation
- *
- * @param string $messageOpenFormat
- * @return FlashMessenger
- */
- public function setMessageOpenFormat($messageOpenFormat)
- {
- $this->messageOpenFormat = (string) $messageOpenFormat;
- return $this;
- }
-
- /**
- * Get the formatted string used to open message representation
- *
- * @return string
- */
- public function getMessageOpenFormat()
- {
- return $this->messageOpenFormat;
- }
-
- /**
- * Set the string used to separate messages
- *
- * @param string $messageSeparatorString
- * @return FlashMessenger
- */
- public function setMessageSeparatorString($messageSeparatorString)
- {
- $this->messageSeparatorString = (string) $messageSeparatorString;
- return $this;
- }
-
- /**
- * Get the string used to separate messages
- *
- * @return string
- */
- public function getMessageSeparatorString()
- {
- return $this->messageSeparatorString;
- }
-
- /**
- * Set the flash messenger plugin
- *
- * @param PluginFlashMessenger $pluginFlashMessenger
- * @return FlashMessenger
- * @throws InvalidArgumentException For an invalid $pluginFlashMessenger.
- * @psalm-suppress RedundantConditionGivenDocblockType, DocblockTypeContradiction
- */
- public function setPluginFlashMessenger($pluginFlashMessenger)
- {
- if (! $pluginFlashMessenger instanceof PluginFlashMessenger) {
- throw new InvalidArgumentException(sprintf(
- '%s expects a %s instance; received %s',
- __METHOD__,
- PluginFlashMessenger::class,
- is_object($pluginFlashMessenger) ? $pluginFlashMessenger::class : gettype($pluginFlashMessenger)
- ));
- }
-
- $this->pluginFlashMessenger = $pluginFlashMessenger;
- return $this;
- }
-
- /**
- * Get the flash messenger plugin
- *
- * @return PluginFlashMessenger
- */
- public function getPluginFlashMessenger()
- {
- if (null === $this->pluginFlashMessenger) {
- $this->setPluginFlashMessenger(new PluginFlashMessenger());
- }
-
- return $this->pluginFlashMessenger;
- }
-
- /**
- * Retrieve the escapeHtml helper
- *
- * @return EscapeHtml
- */
- protected function getEscapeHtmlHelper()
- {
- if ($this->escapeHtmlHelper) {
- return $this->escapeHtmlHelper;
- }
-
- if (null !== $this->view && method_exists($this->view, 'plugin')) {
- $this->escapeHtmlHelper = $this->view->plugin('escapehtml');
- }
-
- if (! $this->escapeHtmlHelper instanceof EscapeHtml) {
- $this->escapeHtmlHelper = new EscapeHtml();
- }
-
- return $this->escapeHtmlHelper;
- }
-}
diff --git a/src/Helper/Gravatar.php b/src/Helper/Gravatar.php
index f06dedfce..fde428fc0 100644
--- a/src/Helper/Gravatar.php
+++ b/src/Helper/Gravatar.php
@@ -12,13 +12,10 @@
use function sprintf;
use function str_replace;
use function strtolower;
-use function trigger_error;
use function trim;
use function ucwords;
use function urlencode;
-use const E_USER_DEPRECATED;
-
/**
* Helper for retrieving avatars from gravatar.com
*
@@ -198,26 +195,6 @@ public function setAttributes(array $attributes)
return $this;
}
- /**
- * Set attribs for image tag
- *
- * @deprecated Please use Laminas\View\Helper\Gravatar::setAttributes
- *
- * @param array $attribs
- * @return Gravatar
- */
- public function setAttribs(array $attribs)
- {
- trigger_error(sprintf(
- '%s is deprecated; please use %s::setAttributes',
- __METHOD__,
- self::class
- ), E_USER_DEPRECATED);
-
- $this->setAttributes($attribs);
- return $this;
- }
-
/**
* Get attributes of image
*
@@ -233,29 +210,6 @@ public function getAttributes()
return $this->attributes;
}
- /**
- * Get attribs of image
- *
- * Warning!
- * If you set src attrib, you get it, but this value will be overwritten in
- * protected method setSrcAttribForImg(). And finally your get other src
- * value!
- *
- * @deprecated Please use Laminas\View\Helper\Gravatar::getAttributes
- *
- * @return array
- */
- public function getAttribs()
- {
- trigger_error(sprintf(
- '%s is deprecated; please use %s::getAttributes',
- __METHOD__,
- self::class
- ), E_USER_DEPRECATED);
-
- return $this->getAttributes();
- }
-
/**
* Set default img
*
diff --git a/src/Helper/HtmlFlash.php b/src/Helper/HtmlFlash.php
deleted file mode 100644
index 0354a28b6..000000000
--- a/src/Helper/HtmlFlash.php
+++ /dev/null
@@ -1,33 +0,0 @@
- $data, 'quality' => 'high'], $params);
-
- $htmlObject = $this->getView()->plugin('htmlObject');
- return $htmlObject($data, self::TYPE, $attribs, $params, $content);
- }
-}
diff --git a/src/Helper/HtmlQuicktime.php b/src/Helper/HtmlQuicktime.php
deleted file mode 100644
index b33aa8d2c..000000000
--- a/src/Helper/HtmlQuicktime.php
+++ /dev/null
@@ -1,54 +0,0 @@
- self::ATTRIB_CLASSID, 'codebase' => self::ATTRIB_CODEBASE];
-
- /**
- * Output a quicktime movie object tag
- *
- * @param string $data The quicktime file
- * @param array $attribs Attribs for the object tag
- * @param array $params Params for in the object tag
- * @param string $content Alternative content
- * @return string
- */
- public function __invoke($data, array $attribs = [], array $params = [], $content = null)
- {
- // Attrs
- $attribs = array_merge($this->attribs, $attribs);
-
- // Params
- $params = array_merge(['src' => $data], $params);
-
- $htmlObject = $this->getView()->plugin('htmlObject');
- return $htmlObject($data, self::TYPE, $attribs, $params, $content);
- }
-}
diff --git a/src/Helper/Identity.php b/src/Helper/Identity.php
index fde997743..6a5ed5150 100644
--- a/src/Helper/Identity.php
+++ b/src/Helper/Identity.php
@@ -10,12 +10,9 @@
/**
* View helper plugin to fetch the authenticated identity.
*/
-class Identity extends AbstractHelper
+final class Identity
{
- use DeprecatedAbstractHelperHierarchyTrait;
-
- /** @var AuthenticationServiceInterface|null */
- protected $authenticationService;
+ private ?AuthenticationServiceInterface $authenticationService;
public function __construct(?AuthenticationServiceInterface $authenticationService = null)
{
@@ -28,6 +25,7 @@ public function __construct(?AuthenticationServiceInterface $authenticationServi
* If none available, returns null.
*
* @return mixed|null
+ * @throws RuntimeException If the helper was not configured with an Authentication Service.
*/
public function __invoke()
{
@@ -40,32 +38,4 @@ public function __invoke()
? $service->getIdentity()
: null;
}
-
- /**
- * Set AuthenticationService instance
- *
- * @deprecated since >= 2.20.0. The authentication service should be provided to the constructor. This method will
- * be removed in version 3.0 of this component
- *
- * @return $this
- */
- public function setAuthenticationService(AuthenticationServiceInterface $authenticationService)
- {
- $this->authenticationService = $authenticationService;
-
- return $this;
- }
-
- /**
- * Get AuthenticationService instance
- *
- * @deprecated since >= 2.20.0. The authentication service should be provided to the constructor. This method will
- * be removed in version 3.0 of this component
- *
- * @return null|object
- */
- public function getAuthenticationService()
- {
- return $this->authenticationService;
- }
}
diff --git a/src/Helper/Json.php b/src/Helper/Json.php
index e54a66fe8..542119922 100644
--- a/src/Helper/Json.php
+++ b/src/Helper/Json.php
@@ -5,11 +5,11 @@
namespace Laminas\View\Helper;
use Laminas\Http\Response;
-use Laminas\Json\Json as JsonFormatter;
-use function trigger_error;
+use function json_encode;
-use const E_USER_DEPRECATED;
+use const JSON_PRETTY_PRINT;
+use const JSON_THROW_ON_ERROR;
/**
* Helper for simplifying JSON responses
@@ -24,7 +24,7 @@ class Json extends AbstractHelper
/**
* @deprecated since >= 2.20.0
*
- * @var Response
+ * @var Response|null
*/
protected $response;
@@ -32,19 +32,12 @@ class Json extends AbstractHelper
* Encode data as JSON and set response header
*
* @param mixed $data
- * @param array $jsonOptions Options to pass to JsonFormatter::encode()
- * @return string|void
+ * @param array{prettyPrint?: bool} $jsonOptions Options to pass to JsonFormatter::encode()
+ * @return string
*/
public function __invoke($data, array $jsonOptions = [])
{
- if (isset($jsonOptions['enableJsonExprFinder']) && $jsonOptions['enableJsonExprFinder'] === true) {
- trigger_error(
- 'Json Expression functionality is deprecated and will be removed in laminas-view 3.0',
- E_USER_DEPRECATED
- );
- }
-
- $data = JsonFormatter::encode($data, null, $jsonOptions);
+ $data = json_encode($data, $this->optionsToFlags($jsonOptions));
if ($this->response instanceof Response) {
$headers = $this->response->getHeaders();
@@ -54,6 +47,16 @@ public function __invoke($data, array $jsonOptions = [])
return $data;
}
+ /** @param array{prettyPrint?: bool} $options */
+ private function optionsToFlags(array $options = []): int
+ {
+ $prettyPrint = $options['prettyPrint'] ?? false;
+ $flags = JSON_THROW_ON_ERROR;
+ $flags |= $prettyPrint ? 0 : JSON_PRETTY_PRINT;
+
+ return $flags;
+ }
+
/**
* Set the response object
*
diff --git a/src/Helper/Navigation/PluginManager.php b/src/Helper/Navigation/PluginManager.php
index a4f4a2a6c..d24c3d8ea 100644
--- a/src/Helper/Navigation/PluginManager.php
+++ b/src/Helper/Navigation/PluginManager.php
@@ -35,18 +35,6 @@ class PluginManager extends HelperPluginManager
'links' => Links::class,
'menu' => Menu::class,
'sitemap' => Sitemap::class,
-
- // Legacy Zend Framework aliases
- 'Zend\View\Helper\Navigation\Breadcrumbs' => Breadcrumbs::class,
- 'Zend\View\Helper\Navigation\Links' => Links::class, // phpcs:ignore
- 'Zend\View\Helper\Navigation\Menu' => Menu::class,
- 'Zend\View\Helper\Navigation\Sitemap' => Sitemap::class,
-
- // v2 normalized FQCNs
- 'zendviewhelpernavigationbreadcrumbs' => Breadcrumbs::class,
- 'zendviewhelpernavigationlinks' => Links::class,
- 'zendviewhelpernavigationmenu' => Menu::class,
- 'zendviewhelpernavigationsitemap' => Sitemap::class,
];
/**
diff --git a/src/Helper/Placeholder.php b/src/Helper/Placeholder.php
index a747668c8..4adec763f 100644
--- a/src/Helper/Placeholder.php
+++ b/src/Helper/Placeholder.php
@@ -37,14 +37,15 @@ class Placeholder extends AbstractHelper
*
* @param string $name
* @throws InvalidArgumentException
- * @return AbstractContainer
+ * @return AbstractContainer|self
+ * @psalm-template T of string|null
+ * @psalm-param T $name
+ * @psalm-return (T is null ? self : AbstractContainer)
*/
public function __invoke($name = null)
{
if ($name === null) {
- throw new InvalidArgumentException(
- 'Placeholder: missing argument. $name is required by placeholder($name)'
- );
+ return $this;
}
return $this->getContainer((string) $name);
diff --git a/src/Helper/Placeholder/Registry.php b/src/Helper/Placeholder/Registry.php
index 4180fdacb..cbd7cc303 100644
--- a/src/Helper/Placeholder/Registry.php
+++ b/src/Helper/Placeholder/Registry.php
@@ -12,9 +12,6 @@
use function class_parents;
use function in_array;
use function sprintf;
-use function trigger_error;
-
-use const E_USER_DEPRECATED;
/**
* Registry for placeholder containers
@@ -45,34 +42,6 @@ class Registry
*/
protected $items = [];
- /**
- * Retrieve or create registry instance
- *
- * @return Registry
- */
- public static function getRegistry()
- {
- trigger_error('Placeholder view helpers should no longer use a singleton registry', E_USER_DEPRECATED);
- if (null === static::$instance) {
- static::$instance = new static();
- }
-
- return static::$instance;
- }
-
- /**
- * Unset the singleton
- *
- * Primarily useful for testing purposes; sets {@link $instance} to null.
- *
- * @return void
- */
- public static function unsetRegistry()
- {
- trigger_error('Placeholder view helpers should no longer use a singleton registry', E_USER_DEPRECATED);
- static::$instance = null;
- }
-
/**
* Set the container for an item in the registry
*
diff --git a/src/Helper/Service/AssetFactory.php b/src/Helper/Service/AssetFactory.php
index aecd3eb7a..99658c8a1 100644
--- a/src/Helper/Service/AssetFactory.php
+++ b/src/Helper/Service/AssetFactory.php
@@ -4,11 +4,9 @@
namespace Laminas\View\Helper\Service;
-use Interop\Container\ContainerInterface; // phpcs:ignore
-use Laminas\ServiceManager\FactoryInterface;
-use Laminas\ServiceManager\ServiceLocatorInterface;
-use Laminas\View\Exception;
+use Laminas\View\Exception\RuntimeException;
use Laminas\View\Helper\Asset;
+use Psr\Container\ContainerInterface;
use Traversable;
use function gettype;
@@ -16,19 +14,12 @@
use function iterator_to_array;
use function sprintf;
-/**
- * @final
- * @psalm-suppress DeprecatedInterface Compatibility with Service Manager 2 should be removed in version 3.0.
- */
-class AssetFactory implements FactoryInterface
+final class AssetFactory
{
/**
- * @param string $name
- * @param null|array $options
- * @return Asset
- * @throws Exception\RuntimeException
+ * @throws RuntimeException
*/
- public function __invoke(ContainerInterface $container, $name, ?array $options = null)
+ public function __invoke(ContainerInterface $container): Asset
{
/** @psalm-var mixed $config */
$config = $container->get('config');
@@ -44,21 +35,6 @@ public function __invoke(ContainerInterface $container, $name, ?array $options =
return new Asset($resourceMap);
}
- /**
- * Create service
- *
- * @deprecated since 2.20.0, this method will be removed in version 3.0.0 of this component.
- * Compatibility with the 2.x series of Laminas\ServiceManager is no longer supported.
- *
- * @param string|null $rName
- * @param string|null $cName
- * @return Asset
- */
- public function createService(ServiceLocatorInterface $serviceLocator, $rName = null, $cName = null)
- {
- return $this($serviceLocator, $cName);
- }
-
/**
* @param array $array
* @return array
@@ -67,7 +43,7 @@ private function assertArray(string $key, array $array): array
{
$value = $array[$key] ?? [];
if (! is_array($value)) {
- throw new Exception\RuntimeException(sprintf(
+ throw new RuntimeException(sprintf(
'Invalid resource map configuration. '
. 'Expected the key "%s" to contain an array value but received "%s"',
$key,
diff --git a/src/Helper/Service/FlashMessengerFactory.php b/src/Helper/Service/FlashMessengerFactory.php
deleted file mode 100644
index 2ca9b88e4..000000000
--- a/src/Helper/Service/FlashMessengerFactory.php
+++ /dev/null
@@ -1,57 +0,0 @@
-get('ControllerPluginManager');
- $flashMessenger = $controllerPluginManager->get('flashmessenger');
-
- $helper->setPluginFlashMessenger($flashMessenger);
-
- $config = $container->get('config');
- if (isset($config['view_helper_config']['flashmessenger'])) {
- $configHelper = $config['view_helper_config']['flashmessenger'];
- if (isset($configHelper['message_open_format'])) {
- $helper->setMessageOpenFormat($configHelper['message_open_format']);
- }
- if (isset($configHelper['message_separator_string'])) {
- $helper->setMessageSeparatorString($configHelper['message_separator_string']);
- }
- if (isset($configHelper['message_close_string'])) {
- $helper->setMessageCloseString($configHelper['message_close_string']);
- }
- }
-
- return $helper;
- }
-
- /**
- * Create service (v2)
- *
- * @param string $normalizedName
- * @param string $requestedName
- * @return FlashMessenger
- */
- public function createService(ServiceLocatorInterface $container, $normalizedName = null, $requestedName = null)
- {
- return $this($container, $requestedName);
- }
-}
diff --git a/src/Helper/Service/IdentityFactory.php b/src/Helper/Service/IdentityFactory.php
index f45645423..6962fbae4 100644
--- a/src/Helper/Service/IdentityFactory.php
+++ b/src/Helper/Service/IdentityFactory.php
@@ -4,62 +4,34 @@
namespace Laminas\View\Helper\Service;
-use Interop\Container\ContainerInterface; // phpcs:ignore
use Laminas\Authentication\AuthenticationService;
use Laminas\Authentication\AuthenticationServiceInterface;
-use Laminas\ServiceManager\FactoryInterface;
-use Laminas\ServiceManager\ServiceLocatorInterface;
use Laminas\View\Helper\Identity;
+use Psr\Container\ContainerInterface;
-/**
- * @psalm-suppress DeprecatedInterface
- */
-class IdentityFactory implements FactoryInterface
+use function assert;
+
+final class IdentityFactory
{
- /**
- * @param string|null $name
- * @param array|null $options
- * @return Identity
- */
- public function __invoke(ContainerInterface $container, $name, ?array $options = null)
+ public function __invoke(ContainerInterface $container): Identity
{
return new Identity($this->discoverAuthenticationService($container));
}
- /**
- * Create service
- *
- * @param string|null $rName
- * @param string|null $cName
- * @return Identity
- */
- public function createService(ServiceLocatorInterface $serviceLocator, $rName = null, $cName = null)
- {
- return $this($serviceLocator, $cName);
- }
-
private function discoverAuthenticationService(ContainerInterface $container): ?AuthenticationServiceInterface
{
- // phpcs:disable WebimpressCodingStandard.Formatting.StringClassReference
- $search = [
- AuthenticationService::class,
- AuthenticationServiceInterface::class,
- 'Zend\Authentication\AuthenticationService',
- 'Zend\Authentication\AuthenticationServiceInterface',
- ];
- // phpcs:enable
+ if ($container->has(AuthenticationService::class)) {
+ $service1 = $container->get(AuthenticationService::class);
+ assert($service1 instanceof AuthenticationServiceInterface);
- foreach ($search as $id) {
- if (! $container->has($id)) {
- continue;
- }
+ return $service1;
+ }
- $service = $container->get($id);
- if (! $service instanceof AuthenticationServiceInterface) {
- continue;
- }
+ if ($container->has(AuthenticationServiceInterface::class)) {
+ $service2 = $container->get(AuthenticationServiceInterface::class);
+ assert($service2 instanceof AuthenticationServiceInterface);
- return $service;
+ return $service2;
}
return null;
diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php
index 607b2f546..3d9b09469 100644
--- a/src/HelperPluginManager.php
+++ b/src/HelperPluginManager.php
@@ -73,9 +73,6 @@ class HelperPluginManager extends AbstractPluginManager
'escapeUrl' => Helper\EscapeUrl::class,
'EscapeUrl' => Helper\EscapeUrl::class,
'escapeurl' => Helper\EscapeUrl::class,
- 'flashmessenger' => Helper\FlashMessenger::class,
- 'flashMessenger' => Helper\FlashMessenger::class,
- 'FlashMessenger' => Helper\FlashMessenger::class,
'Gravatar' => Helper\Gravatar::class,
'gravatar' => Helper\Gravatar::class,
'gravatarImage' => Helper\GravatarImage::class,
@@ -97,9 +94,6 @@ class HelperPluginManager extends AbstractPluginManager
'htmlattributes' => Helper\HtmlAttributes::class,
'htmlAttributes' => Helper\HtmlAttributes::class,
'HtmlAttributes' => Helper\HtmlAttributes::class,
- 'htmlflash' => Helper\HtmlFlash::class,
- 'htmlFlash' => Helper\HtmlFlash::class,
- 'HtmlFlash' => Helper\HtmlFlash::class,
'htmllist' => Helper\HtmlList::class,
'htmlList' => Helper\HtmlList::class,
'HtmlList' => Helper\HtmlList::class,
@@ -109,9 +103,6 @@ class HelperPluginManager extends AbstractPluginManager
'htmlpage' => Helper\HtmlPage::class,
'htmlPage' => Helper\HtmlPage::class,
'HtmlPage' => Helper\HtmlPage::class,
- 'htmlquicktime' => Helper\HtmlQuicktime::class,
- 'htmlQuicktime' => Helper\HtmlQuicktime::class,
- 'HtmlQuicktime' => Helper\HtmlQuicktime::class,
'htmltag' => Helper\HtmlTag::class,
'htmlTag' => Helper\HtmlTag::class,
'HtmlTag' => Helper\HtmlTag::class,
@@ -150,88 +141,6 @@ class HelperPluginManager extends AbstractPluginManager
'viewmodel' => Helper\ViewModel::class,
'viewModel' => Helper\ViewModel::class,
'ViewModel' => Helper\ViewModel::class,
-
- /**
- * Legacy Zend Framework aliases
- *
- * @psalm-suppress DeprecatedClass
- * @codingStandardsIgnoreStart
- **/
- 'Zend\View\Helper\Asset' => Helper\Asset::class,
- 'Zend\View\Helper\FlashMessenger' => Helper\FlashMessenger::class,
- 'Zend\View\Helper\Identity' => Helper\Identity::class,
- 'Zend\View\Helper\BasePath' => Helper\BasePath::class,
- 'Zend\View\Helper\Cycle' => Helper\Cycle::class,
- 'Zend\View\Helper\DeclareVars' => Helper\DeclareVars::class,
- 'Zend\View\Helper\Doctype' => Helper\Doctype::class,
- 'Zend\View\Helper\EscapeHtml' => Helper\EscapeHtml::class,
- 'Zend\View\Helper\EscapeHtmlAttr' => Helper\EscapeHtmlAttr::class,
- 'Zend\View\Helper\EscapeJs' => Helper\EscapeJs::class,
- 'Zend\View\Helper\EscapeCss' => Helper\EscapeCss::class,
- 'Zend\View\Helper\EscapeUrl' => Helper\EscapeUrl::class,
- 'Zend\View\Helper\Gravatar' => Helper\Gravatar::class,
- 'Zend\View\Helper\HtmlTag' => Helper\HtmlTag::class,
- 'Zend\View\Helper\HeadLink' => Helper\HeadLink::class,
- 'Zend\View\Helper\HeadMeta' => Helper\HeadMeta::class,
- 'Zend\View\Helper\HeadScript' => Helper\HeadScript::class,
- 'Zend\View\Helper\HeadStyle' => Helper\HeadStyle::class,
- 'Zend\View\Helper\HeadTitle' => Helper\HeadTitle::class,
- 'Zend\View\Helper\HtmlFlash' => Helper\HtmlFlash::class,
- 'Zend\View\Helper\HtmlList' => Helper\HtmlList::class,
- 'Zend\View\Helper\HtmlObject' => Helper\HtmlObject::class,
- 'Zend\View\Helper\HtmlPage' => Helper\HtmlPage::class,
- 'Zend\View\Helper\HtmlQuicktime' => Helper\HtmlQuicktime::class,
- 'Zend\View\Helper\InlineScript' => Helper\InlineScript::class,
- 'Zend\View\Helper\Json' => Helper\Json::class,
- 'Zend\View\Helper\Layout' => Helper\Layout::class,
- 'Zend\View\Helper\PaginationControl' => Helper\PaginationControl::class,
- 'Zend\View\Helper\PartialLoop' => Helper\PartialLoop::class,
- 'Zend\View\Helper\Partial' => Helper\Partial::class,
- 'Zend\View\Helper\Placeholder' => Helper\Placeholder::class,
- 'Zend\View\Helper\RenderChildModel' => Helper\RenderChildModel::class,
- 'Zend\View\Helper\RenderToPlaceholder' => Helper\RenderToPlaceholder::class,
- 'Zend\View\Helper\ServerUrl' => Helper\ServerUrl::class,
- 'Zend\View\Helper\Url' => Helper\Url::class,
- 'Zend\View\Helper\ViewModel' => Helper\ViewModel::class,
- // @codingStandardsIgnoreEnd
-
- // v2 normalized FQCNs
- 'zendviewhelperasset' => Helper\Asset::class,
- 'zendviewhelperflashmessenger' => Helper\FlashMessenger::class,
- 'zendviewhelperidentity' => Helper\Identity::class,
- 'zendviewhelperbasepath' => Helper\BasePath::class,
- 'zendviewhelpercycle' => Helper\Cycle::class,
- 'zendviewhelperdeclarevars' => Helper\DeclareVars::class,
- 'zendviewhelperdoctype' => Helper\Doctype::class,
- 'zendviewhelperescapehtml' => Helper\EscapeHtml::class,
- 'zendviewhelperescapehtmlattr' => Helper\EscapeHtmlAttr::class,
- 'zendviewhelperescapejs' => Helper\EscapeJs::class,
- 'zendviewhelperescapecss' => Helper\EscapeCss::class,
- 'zendviewhelperescapeurl' => Helper\EscapeUrl::class,
- 'zendviewhelpergravatar' => Helper\Gravatar::class,
- 'zendviewhelperhtmltag' => Helper\HtmlTag::class,
- 'zendviewhelperheadlink' => Helper\HeadLink::class,
- 'zendviewhelperheadmeta' => Helper\HeadMeta::class,
- 'zendviewhelperheadscript' => Helper\HeadScript::class,
- 'zendviewhelperheadstyle' => Helper\HeadStyle::class,
- 'zendviewhelperheadtitle' => Helper\HeadTitle::class,
- 'zendviewhelperhtmlflash' => Helper\HtmlFlash::class,
- 'zendviewhelperhtmllist' => Helper\HtmlList::class,
- 'zendviewhelperhtmlobject' => Helper\HtmlObject::class,
- 'zendviewhelperhtmlpage' => Helper\HtmlPage::class,
- 'zendviewhelperhtmlquicktime' => Helper\HtmlQuicktime::class,
- 'zendviewhelperinlinescript' => Helper\InlineScript::class,
- 'zendviewhelperjson' => Helper\Json::class,
- 'zendviewhelperlayout' => Helper\Layout::class,
- 'zendviewhelperpaginationcontrol' => Helper\PaginationControl::class,
- 'zendviewhelperpartialloop' => Helper\PartialLoop::class,
- 'zendviewhelperpartial' => Helper\Partial::class,
- 'zendviewhelperplaceholder' => Helper\Placeholder::class,
- 'zendviewhelperrenderchildmodel' => Helper\RenderChildModel::class,
- 'zendviewhelperrendertoplaceholder' => Helper\RenderToPlaceholder::class,
- 'zendviewhelperserverurl' => Helper\ServerUrl::class,
- 'zendviewhelperurl' => Helper\Url::class,
- 'zendviewhelperviewmodel' => Helper\ViewModel::class,
];
/**
@@ -249,7 +158,6 @@ class HelperPluginManager extends AbstractPluginManager
protected $factories = [
Helper\Asset::class => Helper\Service\AssetFactory::class,
Helper\HtmlAttributes::class => Helper\Service\HtmlAttributesFactory::class,
- Helper\FlashMessenger::class => Helper\Service\FlashMessengerFactory::class,
Helper\Identity::class => Helper\Service\IdentityFactory::class,
Helper\BasePath::class => Helper\Service\BasePathFactory::class,
Helper\Cycle::class => InvokableFactory::class,
@@ -269,11 +177,9 @@ class HelperPluginManager extends AbstractPluginManager
Helper\HeadScript::class => InvokableFactory::class,
Helper\HeadStyle::class => InvokableFactory::class,
Helper\HeadTitle::class => InvokableFactory::class,
- Helper\HtmlFlash::class => InvokableFactory::class,
Helper\HtmlList::class => InvokableFactory::class,
Helper\HtmlObject::class => InvokableFactory::class,
Helper\HtmlPage::class => InvokableFactory::class,
- Helper\HtmlQuicktime::class => InvokableFactory::class,
Helper\InlineScript::class => InvokableFactory::class,
Helper\Json::class => InvokableFactory::class,
Helper\Layout::class => InvokableFactory::class,
@@ -290,7 +196,6 @@ class HelperPluginManager extends AbstractPluginManager
// v2 canonical FQCNs
'laminasviewhelperasset' => Helper\Service\AssetFactory::class,
'laminasviewhelperattributes' => InvokableFactory::class,
- 'laminasviewhelperflashmessenger' => Helper\Service\FlashMessengerFactory::class,
'laminasviewhelperidentity' => Helper\Service\IdentityFactory::class,
'laminasviewhelperbasepath' => InvokableFactory::class,
'laminasviewhelpercycle' => InvokableFactory::class,
@@ -308,11 +213,9 @@ class HelperPluginManager extends AbstractPluginManager
'laminasviewhelperheadscript' => InvokableFactory::class,
'laminasviewhelperheadstyle' => InvokableFactory::class,
'laminasviewhelperheadtitle' => InvokableFactory::class,
- 'laminasviewhelperhtmlflash' => InvokableFactory::class,
'laminasviewhelperhtmllist' => InvokableFactory::class,
'laminasviewhelperhtmlobject' => InvokableFactory::class,
'laminasviewhelperhtmlpage' => InvokableFactory::class,
- 'laminasviewhelperhtmlquicktime' => InvokableFactory::class,
'laminasviewhelperinlinescript' => InvokableFactory::class,
'laminasviewhelperjson' => InvokableFactory::class,
'laminasviewhelperlayout' => InvokableFactory::class,
diff --git a/src/Model/ConsoleModel.php b/src/Model/ConsoleModel.php
deleted file mode 100644
index 4edfc1b09..000000000
--- a/src/Model/ConsoleModel.php
+++ /dev/null
@@ -1,73 +0,0 @@
-options['errorLevel'] = $errorLevel;
- return $this;
- }
-
- /**
- * @return int
- */
- public function getErrorLevel()
- {
- if (array_key_exists('errorLevel', $this->options)) {
- return $this->options['errorLevel'];
- }
- }
-
- /**
- * Set result text.
- *
- * @param string $text
- * @return ConsoleModel
- */
- public function setResult($text)
- {
- $this->setVariable(self::RESULT, $text);
- return $this;
- }
-
- /**
- * Get result text.
- *
- * @return mixed
- */
- public function getResult()
- {
- return $this->getVariable(self::RESULT);
- }
-}
diff --git a/src/Model/JsonModel.php b/src/Model/JsonModel.php
index 186942003..365a8e770 100644
--- a/src/Model/JsonModel.php
+++ b/src/Model/JsonModel.php
@@ -4,10 +4,16 @@
namespace Laminas\View\Model;
-use Laminas\Json\Json;
+use JsonException;
use Laminas\Stdlib\ArrayUtils;
+use Laminas\View\Exception\DomainException;
use Traversable;
+use function json_encode;
+
+use const JSON_PRETTY_PRINT;
+use const JSON_THROW_ON_ERROR;
+
class JsonModel extends ViewModel
{
/**
@@ -56,13 +62,21 @@ public function serialize()
$variables = ArrayUtils::iteratorToArray($variables);
}
- $options = [
- 'prettyPrint' => $this->getOption('prettyPrint'),
- ];
+ $options = (bool) $this->getOption('prettyPrint', false) ? JSON_PRETTY_PRINT : 0;
if (null !== $this->jsonpCallback) {
- return $this->jsonpCallback . '(' . Json::encode($variables, false, $options) . ');';
+ return $this->jsonpCallback . '(' . $this->jsonEncode($variables, $options) . ');';
+ }
+ return $this->jsonEncode($variables, $options);
+ }
+
+ /** @param mixed $data */
+ private function jsonEncode($data, int $options): string
+ {
+ try {
+ return json_encode($data, $options | JSON_THROW_ON_ERROR);
+ } catch (JsonException $e) {
+ throw new DomainException('Failed to encode Json', $e->getCode(), $e);
}
- return Json::encode($variables, false, $options);
}
}
diff --git a/src/Renderer/ConsoleRenderer.php b/src/Renderer/ConsoleRenderer.php
deleted file mode 100644
index da4eb946b..000000000
--- a/src/Renderer/ConsoleRenderer.php
+++ /dev/null
@@ -1,145 +0,0 @@
-init();
- }
-
- /** @return $this */
- public function setResolver(ResolverInterface $resolver)
- {
- return $this;
- }
-
- /**
- * Return the template engine object
- *
- * Returns the object instance, as it is its own template engine
- *
- * @return ConsoleRenderer
- */
- public function getEngine()
- {
- return $this;
- }
-
- /**
- * Allow custom object initialization when extending ConsoleRenderer
- *
- * Triggered by {@link __construct() the constructor} as its final action.
- *
- * @return void
- */
- public function init()
- {
- }
-
- /**
- * Set filter chain
- *
- * @return ConsoleRenderer
- */
- public function setFilterChain(FilterChain $filters)
- {
- $this->__filterChain = $filters;
- return $this;
- }
-
- /**
- * Retrieve filter chain for post-filtering script content
- *
- * @return FilterChain
- */
- public function getFilterChain()
- {
- if (null === $this->__filterChain) {
- $this->__filterChain = new FilterChain();
- }
- return $this->__filterChain;
- }
-
- /**
- * Recursively processes all ViewModels and returns output.
- *
- * @param string|ModelInterface $model A ViewModel instance.
- * @param null|array|Traversable $values Values to use when rendering. If none
- * provided, uses those in the composed
- * variables container.
- * @return string Console output.
- */
- public function render($model, $values = null)
- {
- if (! $model instanceof ModelInterface) {
- return '';
- }
-
- $result = '';
- $options = $model->getOptions();
- foreach ($options as $setting => $value) {
- $method = 'set' . $setting;
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- unset($method, $setting, $value);
- }
- unset($options);
-
- $values = $model->getVariables();
-
- if (isset($values['result'])) {
- // filter and append the result
- $result .= $this->getFilterChain()->filter($values['result']);
- }
-
- if ($model->hasChildren()) {
- // recursively render all children
- foreach ($model->getChildren() as $child) {
- $result .= $this->render($child, $values);
- }
- }
-
- return $result;
- }
-
- /**
- * @see \Laminas\View\Renderer\TreeRendererInterface
- *
- * @return bool
- */
- public function canRenderTrees()
- {
- return true;
- }
-}
diff --git a/src/Renderer/JsonRenderer.php b/src/Renderer/JsonRenderer.php
index ecc9b115f..a55bd4767 100644
--- a/src/Renderer/JsonRenderer.php
+++ b/src/Renderer/JsonRenderer.php
@@ -5,8 +5,8 @@
namespace Laminas\View\Renderer;
use ArrayAccess;
+use JsonException;
use JsonSerializable;
-use Laminas\Json\Json;
use Laminas\Stdlib\ArrayUtils;
use Laminas\View\Exception;
use Laminas\View\Model\JsonModel;
@@ -18,8 +18,11 @@
use function array_replace_recursive;
use function get_object_vars;
use function is_object;
+use function json_encode;
use function sprintf;
+use const JSON_THROW_ON_ERROR;
+
/**
* JSON renderer
*/
@@ -60,11 +63,13 @@ public function getEngine()
* Set the resolver used to map a template name to a resource the renderer may consume.
*
* @todo Determine use case for resolvers when rendering JSON
- * @return void
+ * @return self
*/
public function setResolver(Resolver $resolver)
{
$this->resolver = $resolver;
+
+ return $this;
}
/**
@@ -131,28 +136,27 @@ public function render($nameOrModel, $values = null)
if ($nameOrModel instanceof JsonModel) {
$children = $this->recurseModel($nameOrModel, false);
$this->injectChildren($nameOrModel, $children);
- $values = $nameOrModel->serialize();
+ $output = $nameOrModel->serialize();
} else {
- $values = $this->recurseModel($nameOrModel);
- $values = Json::encode($values);
+ $output = $this->recurseModel($nameOrModel);
+ $output = $this->jsonEncode($output);
}
if ($this->hasJsonpCallback()) {
- $values = $this->jsonpCallback . '(' . $values . ');';
+ $output = $this->jsonpCallback . '(' . $output . ');';
}
- return $values;
+ return $output;
}
// use case 2: $nameOrModel is populated, $values is not
// Serialize $nameOrModel
if (null === $values) {
if (! is_object($nameOrModel) || $nameOrModel instanceof JsonSerializable) {
- $return = Json::encode($nameOrModel);
+ $return = $this->jsonEncode($nameOrModel);
} elseif ($nameOrModel instanceof Traversable) {
- $nameOrModel = ArrayUtils::iteratorToArray($nameOrModel);
- $return = Json::encode($nameOrModel);
+ $return = $this->jsonEncode(ArrayUtils::iteratorToArray($nameOrModel));
} else {
- $return = Json::encode(get_object_vars($nameOrModel));
+ $return = $this->jsonEncode(get_object_vars($nameOrModel));
}
if ($this->hasJsonpCallback()) {
@@ -237,4 +241,14 @@ protected function injectChildren(Model $model, array $children): void
$model->setVariable($child, $value);
}
}
+
+ /** @param mixed $data */
+ private function jsonEncode($data): string
+ {
+ try {
+ return json_encode($data, JSON_THROW_ON_ERROR);
+ } catch (JsonException $e) {
+ throw new Exception\DomainException('Json encoding failed', $e->getCode(), $e);
+ }
+ }
}
diff --git a/src/Renderer/PhpRenderer.php b/src/Renderer/PhpRenderer.php
index b328b9a75..336a0d586 100644
--- a/src/Renderer/PhpRenderer.php
+++ b/src/Renderer/PhpRenderer.php
@@ -55,7 +55,6 @@
* @method mixed escapeHtmlAttr($value, $recurse = \Laminas\View\Helper\Escaper\AbstractHelper::RECURSE_NONE)
* @method mixed escapeJs($value, $recurse = \Laminas\View\Helper\Escaper\AbstractHelper::RECURSE_NONE)
* @method mixed escapeUrl($value, $recurse = \Laminas\View\Helper\Escaper\AbstractHelper::RECURSE_NONE)
- * @method \Laminas\View\Helper\FlashMessenger flashMessenger($namespace = null)
* @method \Laminas\View\Helper\Gravatar gravatar($email = "", $options = array(), $attribs = array())
* @method \Laminas\View\Helper\HeadLink headLink(array $attributes = null, $placement = \Laminas\View\Helper\Placeholder\Container\AbstractContainer::APPEND)
* @method \Laminas\View\Helper\HeadMeta headMeta($content = null, $keyValue = null, $keyType = 'name', $modifiers = array(), $placement = \Laminas\View\Helper\Placeholder\Container\AbstractContainer::APPEND)
@@ -63,11 +62,9 @@
* @method \Laminas\View\Helper\HeadStyle headStyle($content = null, $placement = 'APPEND', $attributes = array())
* @method \Laminas\View\Helper\HeadTitle headTitle($title = null, $setType = null)
* @method \Laminas\View\HtmlAttributesSet htmlAttributes(iterable $attributes = [])
- * @method string htmlFlash($data, array $attribs = array(), array $params = array(), $content = null)
* @method string htmlList(array $items, $ordered = false, $attribs = false, $escape = true)
* @method string htmlObject($data = null, $type = null, array $attribs = array(), array $params = array(), $content = null)
* @method string htmlPage($data, array $attribs = array(), array $params = array(), $content = null)
- * @method string htmlQuicktime($data, array $attribs = array(), array $params = array(), $content = null)
* @method mixed|null identity()
* @method \Laminas\View\Helper\InlineScript inlineScript($mode = \Laminas\View\Helper\HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
* @method string|void json($data, array $jsonOptions = array())
diff --git a/src/Resolver/TemplatePathStack.php b/src/Resolver/TemplatePathStack.php
index 8d07726e0..a3b58ead2 100644
--- a/src/Resolver/TemplatePathStack.php
+++ b/src/Resolver/TemplatePathStack.php
@@ -7,15 +7,12 @@
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 gettype;
-use function in_array;
-use function ini_get;
use function is_array;
use function is_object;
use function is_string;
@@ -24,8 +21,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;
@@ -68,15 +63,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;
-
/**@-*/
/**
@@ -86,14 +72,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;
@@ -127,10 +105,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;
@@ -282,35 +256,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
*
@@ -350,11 +295,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;
}
}
diff --git a/src/Stream.php b/src/Stream.php
deleted file mode 100644
index b0829c232..000000000
--- a/src/Stream.php
+++ /dev/null
@@ -1,204 +0,0 @@
- and = ?>) should be used
- */
-class Stream
-{
- /**
- * Current stream position.
- *
- * @var int
- */
- protected $pos = 0;
-
- /**
- * Data for streaming.
- *
- * @var string
- */
- protected $data;
-
- /**
- * Stream stats.
- *
- * @var array
- */
- protected $stat;
-
- /**
- * Opens the script file and converts markup.
- *
- * @param string $path
- * @param $mode
- * @param $options
- * @param $opened_path
- * @return bool
- */
- // @codingStandardsIgnoreStart
- public function stream_open($path, $mode, $options, &$opened_path)
- {
- // @codingStandardsIgnoreEnd
- // get the view script source
- $path = str_replace('laminas.view://', '', $path);
- $this->data = file_get_contents($path);
-
- /**
- * If reading the file failed, update our local stat store
- * to reflect the real stat of the file, then return on failure
- */
- if ($this->data === false) {
- $this->stat = stat($path);
- return false;
- }
-
- /**
- * Convert = ?> to long-form and to
- */
- $this->data = preg_replace('/\<\?\=/', "data);
- $this->data = preg_replace('/<\?(?!xml|php)/s', 'data);
-
- /**
- * file_get_contents() won't update PHP's stat cache, so we grab a stat
- * of the file to prevent additional reads should the script be
- * requested again, which will make include() happy.
- */
- $this->stat = stat($path);
-
- return true;
- }
-
- /**
- * Included so that __FILE__ returns the appropriate info
- *
- * @return array
- */
- // @codingStandardsIgnoreStart
- public function url_stat()
- {
- // @codingStandardsIgnoreEnd
- return $this->stat;
- }
-
- /**
- * Reads from the stream.
- *
- * @param int $count
- * @return string
- */
- // @codingStandardsIgnoreStart
- public function stream_read($count)
- {
- // @codingStandardsIgnoreEnd
- $ret = substr($this->data, $this->pos, $count);
- $this->pos += strlen($ret);
- return $ret;
- }
-
- /**
- * Tells the current position in the stream.
- *
- * @return int
- */
- // @codingStandardsIgnoreStart
- public function stream_tell()
- {
- // @codingStandardsIgnoreEnd
- return $this->pos;
- }
-
- /**
- * Tells if we are at the end of the stream.
- *
- * @return bool
- */
- // @codingStandardsIgnoreStart
- public function stream_eof()
- {
- // @codingStandardsIgnoreEnd
- return $this->pos >= strlen($this->data);
- }
-
- /**
- * Stream statistics.
- *
- * @return array
- */
- // @codingStandardsIgnoreStart
- public function stream_stat()
- {
- // @codingStandardsIgnoreEnd
- return $this->stat;
- }
-
- /**
- * Seek to a specific point in the stream.
- *
- * @param $offset
- * @param $whence
- * @return bool
- */
- // @codingStandardsIgnoreStart
- public function stream_seek($offset, $whence)
- {
- // @codingStandardsIgnoreEnd
- switch ($whence) {
- case SEEK_SET:
- if ($offset < strlen($this->data) && $offset >= 0) {
- $this->pos = $offset;
- return true;
- } else {
- return false;
- }
- break;
-
- case SEEK_CUR:
- if ($offset >= 0) {
- $this->pos += $offset;
- return true;
- } else {
- return false;
- }
- break;
-
- case SEEK_END:
- if (strlen($this->data) + $offset >= 0) {
- $this->pos = strlen($this->data) + $offset;
- return true;
- } else {
- return false;
- }
- break;
-
- default:
- return false;
- }
- }
-}
diff --git a/test/Helper/FlashMessengerTest.php b/test/Helper/FlashMessengerTest.php
deleted file mode 100644
index 453a957a3..000000000
--- a/test/Helper/FlashMessengerTest.php
+++ /dev/null
@@ -1,536 +0,0 @@
-mvcPluginClass = V3PluginFlashMessenger::class;
- /** @psalm-suppress DeprecatedClass */
- $this->helper = new FlashMessenger();
- $this->plugin = $this->helper->getPluginFlashMessenger();
- }
-
- public function seedMessages(): void
- {
- /** @psalm-suppress DeprecatedClass */
- $helper = new FlashMessenger();
- $helper->addMessage('foo');
- $helper->addMessage('bar');
- $helper->addInfoMessage('bar-info');
- $helper->addSuccessMessage('bar-success');
- $helper->addWarningMessage('bar-warning');
- $helper->addErrorMessage('bar-error');
- unset($helper);
- }
-
- public function seedCurrentMessages(): void
- {
- /** @psalm-suppress DeprecatedClass */
- $helper = new FlashMessenger();
- $helper->addMessage('foo');
- $helper->addMessage('bar');
- $helper->addInfoMessage('bar-info');
- $helper->addSuccessMessage('bar-success');
- $helper->addErrorMessage('bar-error');
- }
-
- public function createServiceManager(array $config = []): ServiceManager
- {
- $config = new Config([
- 'services' => [
- 'config' => $config,
- ],
- 'factories' => [
- 'ControllerPluginManager' => fn(ContainerInterface $services) => new PluginManager($services, [
- 'invokables' => [
- 'flashmessenger' => $this->mvcPluginClass,
- ],
- ]),
- 'ViewHelperManager' => static fn(ContainerInterface $services)
- => new HelperPluginManager($services),
- ],
- ]);
- $sm = new ServiceManager();
- $config->configureServiceManager($sm);
- return $sm;
- }
-
- public function testCanAssertPluginClass(): void
- {
- $this->assertEquals($this->mvcPluginClass, get_class($this->plugin));
- $this->assertEquals($this->mvcPluginClass, get_class($this->helper->getPluginFlashMessenger()));
- $this->assertSame($this->plugin, $this->helper->getPluginFlashMessenger());
- }
-
- public function testCanRetrieveMessages(): void
- {
- $helper = $this->helper;
-
- $this->assertFalse($helper()->hasMessages());
- $this->assertFalse($helper()->hasInfoMessages());
- $this->assertFalse($helper()->hasSuccessMessages());
- $this->assertFalse($helper()->hasWarningMessages());
- $this->assertFalse($helper()->hasErrorMessages());
-
- $this->seedMessages();
-
- $this->assertNotEmpty($helper('default'));
- $this->assertNotEmpty($helper('info'));
- $this->assertNotEmpty($helper('success'));
- $this->assertNotEmpty($helper('warning'));
- $this->assertNotEmpty($helper('error'));
-
- $this->assertTrue($this->plugin->hasMessages());
- $this->assertTrue($this->plugin->hasInfoMessages());
- $this->assertTrue($this->plugin->hasSuccessMessages());
- $this->assertTrue($this->plugin->hasWarningMessages());
- $this->assertTrue($this->plugin->hasErrorMessages());
- }
-
- public function testCanRetrieveCurrentMessages(): void
- {
- $helper = $this->helper;
-
- $this->assertFalse($helper()->hasCurrentMessages());
- $this->assertFalse($helper()->hasCurrentInfoMessages());
- $this->assertFalse($helper()->hasCurrentSuccessMessages());
- $this->assertFalse($helper()->hasCurrentErrorMessages());
-
- $this->seedCurrentMessages();
-
- $this->assertNotEmpty($helper('default'));
- $this->assertNotEmpty($helper('info'));
- $this->assertNotEmpty($helper('success'));
- $this->assertNotEmpty($helper('error'));
-
- $this->assertFalse($this->plugin->hasCurrentMessages());
- $this->assertFalse($this->plugin->hasCurrentInfoMessages());
- $this->assertFalse($this->plugin->hasCurrentSuccessMessages());
- $this->assertFalse($this->plugin->hasCurrentErrorMessages());
- }
-
- public function testCanProxyAndRetrieveMessagesFromPluginController(): void
- {
- $this->assertFalse($this->helper->hasMessages());
- $this->assertFalse($this->helper->hasInfoMessages());
- $this->assertFalse($this->helper->hasSuccessMessages());
- $this->assertFalse($this->helper->hasWarningMessages());
- $this->assertFalse($this->helper->hasErrorMessages());
-
- $this->seedMessages();
-
- $this->assertTrue($this->helper->hasMessages());
- $this->assertTrue($this->helper->hasInfoMessages());
- $this->assertTrue($this->helper->hasSuccessMessages());
- $this->assertTrue($this->helper->hasWarningMessages());
- $this->assertTrue($this->helper->hasErrorMessages());
- }
-
- public function testCanProxyAndRetrieveCurrentMessagesFromPluginController(): void
- {
- $this->assertFalse($this->helper->hasCurrentMessages());
- $this->assertFalse($this->helper->hasCurrentInfoMessages());
- $this->assertFalse($this->helper->hasCurrentSuccessMessages());
- $this->assertFalse($this->helper->hasCurrentErrorMessages());
-
- $this->seedCurrentMessages();
-
- $this->assertTrue($this->helper->hasCurrentMessages());
- $this->assertTrue($this->helper->hasCurrentInfoMessages());
- $this->assertTrue($this->helper->hasCurrentSuccessMessages());
- $this->assertTrue($this->helper->hasCurrentErrorMessages());
- }
-
- public function testCanDisplayListOfMessages(): void
- {
- $plugin = $this->createMock($this->mvcPluginClass);
- $plugin->expects(self::once())
- ->method('getMessagesFromNamespace')
- ->with('info')
- ->willReturn(['bar-info']);
-
- $plugin->expects(self::once())
- ->method('addInfoMessage')
- ->with('bar-info');
-
- $this->helper->setPluginFlashMessenger($plugin);
-
- $helper = new FlashMessenger();
- $helper->setPluginFlashMessenger($plugin);
- $helper->addInfoMessage('bar-info');
- unset($helper);
-
- $displayInfoAssertion = '';
- $displayInfo = $this->helper->render('info');
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- /**
- * @runInSeparateProcess
- * @preserveGlobalState disabled
- */
- public function testCanDisplayListOfCurrentMessages(): void
- {
- $displayInfoAssertion = '';
- $displayInfo = $this->helper->renderCurrent('info');
- $this->assertEquals($displayInfoAssertion, $displayInfo);
-
- $this->seedCurrentMessages();
-
- $displayInfoAssertion = '';
- $displayInfo = $this->helper->renderCurrent('info');
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfMessagesByDefaultParameters(): void
- {
- $helper = $this->helper;
- $this->seedMessages();
-
- $displayInfoAssertion = '';
- $displayInfo = $helper()->render();
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfMessagesByDefaultCurrentParameters(): void
- {
- $helper = $this->helper;
- $this->seedCurrentMessages();
-
- $displayInfoAssertion = '';
- $displayInfo = $helper()->renderCurrent();
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfMessagesByInvoke(): void
- {
- $helper = $this->helper;
- $this->seedMessages();
-
- $displayInfoAssertion = '';
- $displayInfo = $helper()->render('info');
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfCurrentMessagesByInvoke(): void
- {
- $helper = $this->helper;
- $this->seedCurrentMessages();
-
- $displayInfoAssertion = '';
- $displayInfo = $helper()->renderCurrent('info');
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfMessagesCustomised(): void
- {
- $this->seedMessages();
-
- $displayInfoAssertion = '';
- $displayInfo = $this->helper
- ->setMessageOpenFormat('')
- ->setMessageSeparatorString('
')
- ->setMessageCloseString('
')
- ->render('info', ['foo-baz', 'foo-bar']);
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfCurrentMessagesCustomised(): void
- {
- $this->seedCurrentMessages();
-
- $displayInfoAssertion = '';
- $displayInfo = $this->helper
- ->setMessageOpenFormat('')
- ->setMessageSeparatorString('
')
- ->setMessageCloseString('
')
- ->renderCurrent('info', ['foo-baz', 'foo-bar']);
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfMessagesCustomisedSeparator(): void
- {
- $this->seedMessages();
-
- $displayInfoAssertion = '';
- $displayInfo = $this->helper
- ->setMessageOpenFormat('')
- ->setMessageSeparatorString('
')
- ->setMessageCloseString('
')
- ->render('default', ['foo-baz', 'foo-bar']);
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfCurrentMessagesCustomisedSeparator(): void
- {
- $this->seedCurrentMessages();
-
- $displayInfoAssertion = '';
- $displayInfo = $this->helper
- ->setMessageOpenFormat('')
- ->setMessageSeparatorString('
')
- ->setMessageCloseString('
')
- ->renderCurrent('default', ['foo-baz', 'foo-bar']);
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfMessagesCustomisedByConfig(): void
- {
- $this->seedMessages();
-
- $config = [
- 'view_helper_config' => [
- 'flashmessenger' => [
- 'message_open_format' => '',
- 'message_separator_string' => ' ',
- 'message_close_string' => ' ',
- ],
- ],
- ];
-
- $services = $this->createServiceManager($config);
- $helperPluginManager = $services->get('ViewHelperManager');
- $helper = $helperPluginManager->get('flashmessenger');
-
- $displayInfoAssertion = '';
- $displayInfo = $helper->render('info');
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfCurrentMessagesCustomisedByConfig(): void
- {
- $this->seedCurrentMessages();
- $config = [
- 'view_helper_config' => [
- 'flashmessenger' => [
- 'message_open_format' => '',
- 'message_separator_string' => ' ',
- 'message_close_string' => ' ',
- ],
- ],
- ];
- $services = $this->createServiceManager($config);
- $helperPluginManager = $services->get('ViewHelperManager');
- $helper = $helperPluginManager->get('flashmessenger');
-
- $displayInfoAssertion = '';
- $displayInfo = $helper->renderCurrent('info');
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfMessagesCustomisedByConfigSeparator(): void
- {
- $this->seedMessages();
-
- $config = [
- 'view_helper_config' => [
- 'flashmessenger' => [
- 'message_open_format' => '',
- 'message_separator_string' => ' ',
- 'message_close_string' => ' ',
- ],
- ],
- ];
- $services = $this->createServiceManager($config);
- $helperPluginManager = $services->get('ViewHelperManager');
- $helper = $helperPluginManager->get('flashmessenger');
-
- // @codingStandardsIgnoreStart
- $displayInfoAssertion = '';
- // @codingStandardsIgnoreEnd
- $displayInfo = $helper->render('default', ['foo-baz', 'foo-bar']);
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanDisplayListOfCurrentMessagesCustomisedByConfigSeparator(): void
- {
- $this->seedCurrentMessages();
-
- $config = [
- 'view_helper_config' => [
- 'flashmessenger' => [
- 'message_open_format' => '',
- 'message_separator_string' => ' ',
- 'message_close_string' => ' ',
- ],
- ],
- ];
- $services = $this->createServiceManager($config);
- $helperPluginManager = $services->get('ViewHelperManager');
- $helper = $helperPluginManager->get('flashmessenger');
-
- // @codingStandardsIgnoreStart
- $displayInfoAssertion = '';
- // @codingStandardsIgnoreEnd
- $displayInfo = $helper->renderCurrent('default', ['foo-baz', 'foo-bar']);
- $this->assertEquals($displayInfoAssertion, $displayInfo);
- }
-
- public function testCanTranslateMessages(): void
- {
- $mockTranslator = $this->createMock(Translator::class);
- $mockTranslator->expects(self::once())
- ->method('translate')
- ->with('bar-info', 'default')
- ->willReturn('translated message');
-
- $this->helper->setTranslator($mockTranslator);
- $this->assertTrue($this->helper->hasTranslator());
-
- $this->seedMessages();
-
- $displayAssertion = '';
- $display = $this->helper->render('info');
- $this->assertEquals($displayAssertion, $display);
- }
-
- public function testCanTranslateCurrentMessages(): void
- {
- $mockTranslator = $this->createMock(Translator::class);
- $mockTranslator->expects(self::once())
- ->method('translate')
- ->with('bar-info', 'default')
- ->willReturn('translated message');
-
- $this->helper->setTranslator($mockTranslator);
- $this->assertTrue($this->helper->hasTranslator());
-
- $this->seedCurrentMessages();
-
- $displayAssertion = '';
- $display = $this->helper->renderCurrent('info');
- $this->assertEquals($displayAssertion, $display);
- }
-
- public function testAutoEscapeDefaultsToTrue(): void
- {
- $this->assertTrue($this->helper->getAutoEscape());
- }
-
- public function testCanSetAutoEscape(): void
- {
- $this->helper->setAutoEscape(false);
- $this->assertFalse($this->helper->getAutoEscape());
-
- $this->helper->setAutoEscape(true);
- $this->assertTrue($this->helper->getAutoEscape());
- }
-
- public function testMessageIsEscapedByDefault(): void
- {
- $helper = new FlashMessenger();
- $helper->addMessage('Foo bar');
- unset($helper);
-
- $displayAssertion = '';
- $display = $this->helper->render('default');
- $this->assertSame($displayAssertion, $display);
- }
-
- public function testMessageIsNotEscapedWhenAutoEscapeIsFalse(): void
- {
- $helper = new FlashMessenger();
- $helper->addMessage('Foo bar');
- unset($helper);
-
- $displayAssertion = '';
- $display = $this->helper->setAutoEscape(false)
- ->render('default');
- $this->assertSame($displayAssertion, $display);
- }
-
- public function testCanSetAutoEscapeOnRender(): void
- {
- $helper = new FlashMessenger();
- $helper->addMessage('Foo bar');
- unset($helper);
-
- $displayAssertion = '';
- $display = $this->helper->render('default', [], false);
- $this->assertSame($displayAssertion, $display);
- }
-
- public function testRenderUsesCurrentAutoEscapeByDefault(): void
- {
- $helper = new FlashMessenger();
- $helper->addMessage('Foo bar');
- unset($helper);
-
- $this->helper->setAutoEscape(false);
- $displayAssertion = '';
- $display = $this->helper->render('default');
- $this->assertSame($displayAssertion, $display);
-
- $helper = new FlashMessenger();
- $helper->addMessage('Foo bar');
- unset($helper);
-
- $this->helper->setAutoEscape(true);
- $displayAssertion = '';
- $display = $this->helper->render('default');
- $this->assertSame($displayAssertion, $display);
- }
-
- public function testCurrentMessageIsEscapedByDefault(): void
- {
- $this->helper->addMessage('Foo bar');
-
- $displayAssertion = '';
- $display = $this->helper->renderCurrent('default');
- $this->assertSame($displayAssertion, $display);
- }
-
- public function testCurrentMessageIsNotEscapedWhenAutoEscapeIsFalse(): void
- {
- $this->helper->addMessage('Foo bar');
-
- $displayAssertion = '';
- $display = $this->helper->setAutoEscape(false)
- ->renderCurrent('default');
- $this->assertSame($displayAssertion, $display);
- }
-
- public function testCanSetAutoEscapeOnRenderCurrent(): void
- {
- $this->helper->addMessage('Foo bar');
-
- $displayAssertion = '';
- $display = $this->helper->renderCurrent('default', [], false);
- $this->assertSame($displayAssertion, $display);
- }
-
- public function testRenderCurrentUsesCurrentAutoEscapeByDefault(): void
- {
- $this->helper->addMessage('Foo bar');
-
- $this->helper->setAutoEscape(false);
- $displayAssertion = '';
- $display = $this->helper->renderCurrent('default');
- $this->assertSame($displayAssertion, $display);
-
- $this->helper->setAutoEscape(true);
- $displayAssertion = '';
- $display = $this->helper->renderCurrent('default');
- $this->assertSame($displayAssertion, $display);
- }
-}
diff --git a/test/Helper/GravatarTest.php b/test/Helper/GravatarTest.php
index 6e912614c..2a6a9421d 100644
--- a/test/Helper/GravatarTest.php
+++ b/test/Helper/GravatarTest.php
@@ -8,16 +8,11 @@
use Laminas\View\Helper\Gravatar;
use Laminas\View\Renderer\PhpRenderer as View;
use PHPUnit\Framework\TestCase;
-use ReflectionMethod;
use function method_exists;
-use function restore_error_handler;
-use function set_error_handler;
use function strtoupper;
use function urlencode;
-use const E_USER_DEPRECATED;
-
/** @psalm-suppress DeprecatedClass */
class GravatarTest extends TestCase
{
@@ -275,50 +270,4 @@ public function testEmailIsProperlyNormalized(): void
$this->helper->__invoke('Example@Example.com ')->getEmail()
);
}
-
- public function testSetAttribsIsDeprecated(): void
- {
- set_error_handler(function ($code, $error) {
- throw new Exception\RuntimeException($error, $code);
- }, E_USER_DEPRECATED);
- try {
- $this->helper->setAttribs([]);
- $this->fail('An exception was not thrown');
- } catch (Exception\RuntimeException $e) {
- self::assertStringContainsString('setAttribs is deprecated', $e->getMessage());
- } finally {
- restore_error_handler();
- }
- }
-
- public function testSetAttribsDocCommentHasDeprecated(): void
- {
- $method = new ReflectionMethod($this->helper, 'setAttribs');
- $comment = $method->getDocComment();
-
- $this->assertStringContainsString('@deprecated', $comment);
- }
-
- public function testGetAttribsIsDeprecated(): void
- {
- set_error_handler(function ($code, $error) {
- throw new Exception\RuntimeException($error, $code);
- }, E_USER_DEPRECATED);
- try {
- $this->helper->getAttribs();
- $this->fail('An exception was not thrown');
- } catch (Exception\RuntimeException $e) {
- self::assertStringContainsString('getAttribs is deprecated', $e->getMessage());
- } finally {
- restore_error_handler();
- }
- }
-
- public function testGetAttribsDocCommentHasDeprecated(): void
- {
- $method = new ReflectionMethod($this->helper, 'getAttribs');
- $comment = $method->getDocComment();
-
- $this->assertStringContainsString('@deprecated', $comment);
- }
}
diff --git a/test/Helper/HtmlFlashTest.php b/test/Helper/HtmlFlashTest.php
deleted file mode 100644
index 67f3d7a6d..000000000
--- a/test/Helper/HtmlFlashTest.php
+++ /dev/null
@@ -1,42 +0,0 @@
-view = new View();
- /** @psalm-suppress DeprecatedClass */
- $this->helper = new HtmlFlash();
- $this->helper->setView($this->view);
- }
-
- public function testMakeHtmlFlash(): void
- {
- $htmlFlash = $this->helper->__invoke('/path/to/flash.swf');
-
- // @codingStandardsIgnoreStart
- $objectStartElement = '';
- // @codingStandardsIgnoreEnd
-
- $this->assertStringContainsString($objectStartElement, $htmlFlash);
- $this->assertStringContainsString(' ', $htmlFlash);
- }
-}
diff --git a/test/Helper/HtmlQuicktimeTest.php b/test/Helper/HtmlQuicktimeTest.php
deleted file mode 100644
index f99559d90..000000000
--- a/test/Helper/HtmlQuicktimeTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-view = new View();
- /** @psalm-suppress DeprecatedClass */
- $this->helper = new HtmlQuicktime();
- $this->helper->setView($this->view);
- }
-
- public function testMakeHtmlQuicktime(): void
- {
- $htmlQuicktime = $this->helper->__invoke('/path/to/quicktime.mov');
-
- $objectStartElement = '';
-
- $this->assertStringContainsString($objectStartElement, $htmlQuicktime);
- $this->assertStringContainsString(' ', $htmlQuicktime);
- }
-}
diff --git a/test/Helper/JsonTest.php b/test/Helper/JsonTest.php
index 99f4f7e94..b829abf73 100644
--- a/test/Helper/JsonTest.php
+++ b/test/Helper/JsonTest.php
@@ -6,15 +6,12 @@
use Laminas\Http\Header\HeaderInterface;
use Laminas\Http\Response;
-use Laminas\Json\Json as JsonFormatter;
-use Laminas\View\Exception\RuntimeException;
use Laminas\View\Helper\Json as JsonHelper;
use PHPUnit\Framework\TestCase;
-use function restore_error_handler;
-use function set_error_handler;
+use function json_encode;
-use const E_USER_DEPRECATED;
+use const JSON_THROW_ON_ERROR;
class JsonTest extends TestCase
{
@@ -32,7 +29,7 @@ protected function setUp(): void
$this->helper->setResponse($this->response);
}
- public function verifyJsonHeader(): void
+ private function verifyJsonHeader(): void
{
$headers = $this->response->getHeaders();
$this->assertTrue($headers->has('Content-Type'));
@@ -49,29 +46,11 @@ public function testJsonHelperSetsResponseHeader(): void
public function testJsonHelperReturnsJsonEncodedString(): void
{
- $data = $this->helper->__invoke('foobar');
- $this->assertIsString($data);
- $this->assertEquals('foobar', JsonFormatter::decode($data));
- }
-
- public function testThatADeprecationErrorIsTriggeredWhenExpressionFinderOptionIsUsed(): void
- {
- set_error_handler(function ($code, $error) {
- throw new RuntimeException($error, $code);
- }, E_USER_DEPRECATED);
- try {
- $this->helper->__invoke(['foo'], ['enableJsonExprFinder' => true]);
- $this->fail('An exception was not thrown');
- } catch (RuntimeException $e) {
- self::assertStringContainsString('Json Expression functionality is deprecated', $e->getMessage());
- } finally {
- restore_error_handler();
- }
- }
-
- public function testThatADeprecationErrorIsNotTriggeredWhenExpressionFinderOptionIsNotUsed(): void
- {
- $this->expectNotToPerformAssertions();
- $this->helper->__invoke(['foo'], ['enableJsonExprFinder' => 'anything other than true']);
+ $input = [
+ 'dory' => 'blue',
+ 'nemo' => 'orange',
+ ];
+ $expect = json_encode($input, JSON_THROW_ON_ERROR);
+ self::assertJsonStringEqualsJsonString($expect, ($this->helper)($input));
}
}
diff --git a/test/Helper/PlaceholderTest.php b/test/Helper/PlaceholderTest.php
index 8295b5533..ff5b98ffd 100644
--- a/test/Helper/PlaceholderTest.php
+++ b/test/Helper/PlaceholderTest.php
@@ -4,15 +4,14 @@
namespace LaminasTest\View\Helper;
-use Laminas\View\Helper;
+use Laminas\View\Helper\Placeholder;
use Laminas\View\Helper\Placeholder\Container\AbstractContainer;
use Laminas\View\Renderer\PhpRenderer as View;
use PHPUnit\Framework\TestCase;
class PlaceholderTest extends TestCase
{
- /** @var Helper\Placeholder */
- public $placeholder;
+ public Placeholder $placeholder;
/**
* Sets up the fixture, for example, open a network connection.
@@ -20,7 +19,7 @@ class PlaceholderTest extends TestCase
*/
protected function setUp(): void
{
- $this->placeholder = new Helper\Placeholder();
+ $this->placeholder = new Placeholder();
}
public function testSetView(): void
@@ -30,12 +29,26 @@ public function testSetView(): void
$this->assertSame($view, $this->placeholder->getView());
}
+ public function testContainerExists(): void
+ {
+ $this->placeholder->__invoke('foo');
+ $containerExists = $this->placeholder->__invoke()->containerExists('foo');
+
+ $this->assertTrue($containerExists);
+ }
+
public function testPlaceholderRetrievesContainer(): void
{
$container = $this->placeholder->__invoke('foo');
$this->assertInstanceOf(AbstractContainer::class, $container);
}
+ public function testPlaceholderRetrievesItself(): void
+ {
+ $container = $this->placeholder->__invoke();
+ $this->assertSame($container, $this->placeholder);
+ }
+
public function testPlaceholderRetrievesSameContainerOnSubsequentCalls(): void
{
$container1 = $this->placeholder->__invoke('foo');
@@ -67,4 +80,12 @@ public function testClearContainersRemovesAllContainers(): void
$this->assertFalse($this->placeholder->containerExists('foo'));
$this->assertFalse($this->placeholder->containerExists('bar'));
}
+
+ public function testGetContainerRetrievesTheCorrectContainer(): void
+ {
+ $container1 = $this->placeholder->__invoke('foo');
+ $container2 = $this->placeholder->__invoke()->getContainer('foo');
+
+ $this->assertSame($container1, $container2);
+ }
}
diff --git a/test/Helper/Service/AssetFactoryTest.php b/test/Helper/Service/AssetFactoryTest.php
index 807d0c19d..307e2d81f 100644
--- a/test/Helper/Service/AssetFactoryTest.php
+++ b/test/Helper/Service/AssetFactoryTest.php
@@ -4,62 +4,25 @@
namespace LaminasTest\View\Helper\Service;
-use Laminas\ServiceManager\ServiceManager;
-use Laminas\View\Exception;
+use Laminas\View\Exception\RuntimeException;
use Laminas\View\Helper\Asset;
use Laminas\View\Helper\Service\AssetFactory;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
+use Psr\Container\ContainerInterface;
class AssetFactoryTest extends TestCase
{
- /**
- * @deprecated for removal in 3.0
- */
- public function testAssetFactoryCreateServiceCreatesAssetInstance(): void
- {
- $services = $this->getServices();
-
- $assetFactory = new AssetFactory();
- $asset = $assetFactory->createService($services);
-
- $this->assertInstanceOf(Asset::class, $asset);
- }
-
public function testAssetFactoryInvokableCreatesAssetInstance(): void
{
$services = $this->getServices();
$assetFactory = new AssetFactory();
- $asset = $assetFactory($services, '');
+ $asset = $assetFactory($services);
$this->assertInstanceOf(Asset::class, $asset);
}
- /**
- * @deprecated for removal in 3.0
- */
- public function testValidConfiguration(): void
- {
- $config = [
- 'view_helper_config' => [
- 'asset' => [
- 'resource_map' => [
- 'css/style.css' => 'css/style-3a97ff4ee3.css',
- 'js/vendor.js' => 'js/vendor-a507086eba.js',
- ],
- ],
- ],
- ];
-
- $services = $this->getServices($config);
- $assetFactory = new AssetFactory();
-
- $asset = $assetFactory($services, '');
-
- $this->assertEquals($config['view_helper_config']['asset']['resource_map'], $asset->getResourceMap());
- }
-
public function testThatAnExceptionWillBeThrownWhenTheResourceMapIsSetToANonArray(): void
{
$container = $this->getServices([
@@ -70,12 +33,12 @@ public function testThatAnExceptionWillBeThrownWhenTheResourceMapIsSetToANonArra
],
]);
- $this->expectException(Exception\RuntimeException::class);
+ $this->expectException(RuntimeException::class);
$this->expectExceptionMessage(
'Invalid resource map configuration. Expected the key '
. '"resource_map" to contain an array value but received "string"'
);
- (new AssetFactory())($container, '');
+ (new AssetFactory())($container);
}
/**
@@ -128,14 +91,14 @@ public static function validConfigProvider(): array
public function testThatAnExceptionWillNotBeThrownWhenGivenUnsetOrEmptyArrayConfiguration(array $config): void
{
$container = $this->getServices($config);
- (new AssetFactory())($container, 'foo');
+ (new AssetFactory())($container);
self::assertTrue(true);
}
/** @param array $config */
- private function getServices(array $config = []): ServiceManager
+ private function getServices(array $config = []): ContainerInterface
{
- $services = $this->createMock(ServiceManager::class);
+ $services = $this->createMock(ContainerInterface::class);
$services->expects(self::once())
->method('get')
->with('config')
diff --git a/test/Helper/Service/IdentityFactoryTest.php b/test/Helper/Service/IdentityFactoryTest.php
index 400d31d5a..27c782ea0 100644
--- a/test/Helper/Service/IdentityFactoryTest.php
+++ b/test/Helper/Service/IdentityFactoryTest.php
@@ -4,66 +4,94 @@
namespace LaminasTest\View\Helper\Service;
+use Interop\Container\ContainerInterface; // phpcs:ignore
use Laminas\Authentication\AuthenticationService;
use Laminas\Authentication\AuthenticationServiceInterface;
-use Laminas\ServiceManager\ServiceManager;
+use Laminas\View\Exception\RuntimeException;
use Laminas\View\Helper\Identity;
use Laminas\View\Helper\Service\IdentityFactory;
-use LaminasTest\View\Helper\TestAsset\AuthenticationServiceStub;
-use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class IdentityFactoryTest extends TestCase
{
- public function testThatAHelperCanBeCreatedWhenThereAreNoAuthenticationServicesFound(): void
+ /** @var MockObject&ContainerInterface */
+ private ContainerInterface $services;
+
+ protected function setUp(): void
{
- $container = $this->createMock(ServiceManager::class);
- $container->expects(self::exactly(4))
+ $this->services = $this->createMock(ContainerInterface::class);
+ }
+
+ public function testFactoryReturnsEmptyIdentityIfNoAuthenticationServicePresent(): void
+ {
+ $this->services->expects(self::exactly(2))
->method('has')
- ->willReturn(false);
+ ->with(self::callback(static function (string $serviceName): bool {
+ self::assertTrue(
+ $serviceName === AuthenticationService::class
+ ||
+ $serviceName === AuthenticationServiceInterface::class
+ );
- $container->expects(self::never())->method('get');
+ return true;
+ }))->willReturn(false);
$factory = new IdentityFactory();
- $helper = $factory($container, null);
- self::assertInstanceOf(Identity::class, $helper);
- }
- /** @return array */
- public static function serviceNameProvider(): array
- {
- // phpcs:disable WebimpressCodingStandard.Formatting.StringClassReference
- return [
- [AuthenticationService::class],
- [AuthenticationServiceInterface::class],
- ['Zend\Authentication\AuthenticationService'],
- ['Zend\Authentication\AuthenticationServiceInterface'],
- ];
- // phpcs:enable
+ $plugin = $factory($this->services);
+
+ $this->assertInstanceOf(Identity::class, $plugin);
+ $this->expectException(RuntimeException::class);
+ $plugin();
}
- private function authService(?string $id): AuthenticationServiceStub
+ public function testFactoryReturnsIdentityWithConfiguredAuthenticationServiceWhenPresent(): void
{
- return new AuthenticationServiceStub($id);
+ $authService = $this->createMock(AuthenticationServiceInterface::class);
+ $authService->expects(self::once())
+ ->method('hasIdentity')
+ ->willReturn(false);
+
+ $this->services->expects(self::once())
+ ->method('has')
+ ->with(AuthenticationService::class)
+ ->willReturn(true);
+
+ $this->services->expects(self::once())
+ ->method('get')
+ ->with(AuthenticationService::class)
+ ->willReturn($authService);
+
+ $factory = new IdentityFactory();
+
+ $plugin = $factory($this->services);
+
+ $this->assertInstanceOf(Identity::class, $plugin);
+ $this->assertNull($plugin());
}
- #[DataProvider('serviceNameProvider')]
- public function testThatAFoundAuthenticationServiceWillBeUsed(string $serviceId): void
+ public function testFactoryReturnsIdentityWithConfiguredAuthenticationServiceInterfaceWhenPresent(): void
{
- $service = $this->authService('james bond');
+ $authService = $this->createMock(AuthenticationServiceInterface::class);
+ $authService->expects(self::once())
+ ->method('hasIdentity')
+ ->willReturn(false);
- $container = $this->createMock(ServiceManager::class);
- $container->expects(self::atLeast(1))
+ $this->services->expects(self::exactly(2))
->method('has')
- ->willReturnCallback(static fn (string $argument): bool => $argument === $serviceId);
+ ->willReturnOnConsecutiveCalls(false, true);
- $container->expects(self::once())
+ $this->services->expects(self::once())
->method('get')
- ->with($serviceId)
- ->willReturn($service);
+ ->with(AuthenticationServiceInterface::class)
+ ->willReturn($authService);
$factory = new IdentityFactory();
- $helper = $factory($container, null);
- self::assertEquals('james bond', $helper());
+
+ $plugin = $factory($this->services);
+
+ $this->assertInstanceOf(Identity::class, $plugin);
+ $this->assertNull($plugin());
}
}
diff --git a/test/HelperPluginManagerCompatibilityTest.php b/test/HelperPluginManagerCompatibilityTest.php
index c2ae2b425..41917aefa 100644
--- a/test/HelperPluginManagerCompatibilityTest.php
+++ b/test/HelperPluginManagerCompatibilityTest.php
@@ -6,7 +6,6 @@
use Generator;
use Laminas\Mvc\Controller\PluginManager as ControllerPluginManager;
-use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger;
use Laminas\ServiceManager\Config;
use Laminas\ServiceManager\ServiceManager;
use Laminas\ServiceManager\Test\CommonPluginManagerTrait;
@@ -30,9 +29,7 @@ protected static function getPluginManager(): HelperPluginManager
if (class_exists(ControllerPluginManager::class)) {
// @codingStandardsIgnoreLine
$factories['ControllerPluginManager'] = static fn(ContainerInterface $services): ControllerPluginManager => new ControllerPluginManager($services, [
- 'invokables' => [
- 'flashmessenger' => FlashMessenger::class,
- ],
+ 'invokables' => [],
]);
}
@@ -64,11 +61,6 @@ public static function aliasProvider(): Generator
foreach ($aliases as $alias => $target) {
self::assertIsString($target);
- // Skipping conditionally since it depends on laminas-mvc
- if (! class_exists(ControllerPluginManager::class) && strpos($target, '\\FlashMessenger')) {
- continue;
- }
-
// Skipping conditionally since it depends on laminas-mvc
if (! class_exists(ControllerPluginManager::class) && strpos($target, '\\Url')) {
continue;
diff --git a/test/Model/ConsoleModelTest.php b/test/Model/ConsoleModelTest.php
deleted file mode 100644
index 0d38876f4..000000000
--- a/test/Model/ConsoleModelTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-assertInstanceOf(ModelInterface::class, $model);
- }
-
- /**
- * @see https://github.com/zendframework/zend-view/issues/152
- */
- public function testSetErrorLevelImplementsFluentInterface(): void
- {
- /** @psalm-suppress DeprecatedClass */
- $model = new ConsoleModel();
- $actual = $model->setErrorLevel(0);
- $this->assertSame($model, $actual);
- }
-}
diff --git a/test/Model/JsonModelTest.php b/test/Model/JsonModelTest.php
index 4319b799a..41b7e64ef 100644
--- a/test/Model/JsonModelTest.php
+++ b/test/Model/JsonModelTest.php
@@ -4,11 +4,17 @@
namespace LaminasTest\View\Model;
-use Laminas\Json\Json;
+use Laminas\View\Exception\DomainException;
use Laminas\View\Model\JsonModel;
use Laminas\View\Variables;
use PHPUnit\Framework\TestCase;
+use function json_encode;
+use function sprintf;
+
+use const JSON_PRETTY_PRINT;
+use const JSON_THROW_ON_ERROR;
+
class JsonModelTest extends TestCase
{
public function testAllowsEmptyConstructor(): void
@@ -23,7 +29,7 @@ public function testCanSerializeVariablesToJson(): void
$array = ['foo' => 'bar'];
$model = new JsonModel($array);
$this->assertEquals($array, $model->getVariables());
- $this->assertEquals(Json::encode($array), $model->serialize());
+ $this->assertJsonStringEqualsJsonString(json_encode($array, JSON_THROW_ON_ERROR), $model->serialize());
}
public function testCanSerializeWithJsonpCallback(): void
@@ -31,12 +37,16 @@ public function testCanSerializeWithJsonpCallback(): void
$array = ['foo' => 'bar'];
$model = new JsonModel($array);
$model->setJsonpCallback('callback');
- $this->assertEquals('callback(' . Json::encode($array) . ');', $model->serialize());
+ $expect = sprintf(
+ 'callback(%s);',
+ json_encode($array, JSON_THROW_ON_ERROR)
+ );
+ $this->assertEquals($expect, $model->serialize());
}
public function testPrettyPrint(): void
{
- $array = [
+ $array = [
'simple' => 'simple test string',
'stringwithjsonchars' => '\"[1,2]',
'complex' => [
@@ -44,7 +54,18 @@ public function testPrettyPrint(): void
'far' => 'boo',
],
];
- $model = new JsonModel($array, ['prettyPrint' => true]);
- $this->assertEquals(Json::encode($array, false, ['prettyPrint' => true]), $model->serialize());
+ $model = new JsonModel($array, ['prettyPrint' => true]);
+ $expect = json_encode($array, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
+ $this->assertEquals($expect, $model->serialize());
+ }
+
+ public function testThatAnExceptionIsThrownIfItIsNotPossibleToEncodeThePayload(): void
+ {
+ $malformedUtf8 = [
+ 'string' => "\x92",
+ ];
+ $this->expectException(DomainException::class);
+ $this->expectExceptionMessage('Failed to encode Json');
+ (new JsonModel($malformedUtf8))->serialize();
}
}
diff --git a/test/Resolver/TemplatePathStackTest.php b/test/Resolver/TemplatePathStackTest.php
index 636366e26..9d2a407ae 100644
--- a/test/Resolver/TemplatePathStackTest.php
+++ b/test/Resolver/TemplatePathStackTest.php
@@ -13,7 +13,6 @@
use function array_reverse;
use function array_unshift;
-use function ini_get;
use function realpath;
use const DIRECTORY_SEPARATOR;
@@ -103,24 +102,6 @@ public function testMayDisableLfiProtection(): void
$this->assertFalse($this->stack->isLfiProtectionOn());
}
- public function testStreamWrapperDisabledByDefault(): void
- {
- /** @psalm-suppress DeprecatedMethod */
- $this->assertFalse($this->stack->useStreamWrapper());
- }
-
- public function testMayEnableStreamWrapper(): void
- {
- $flag = (bool) ini_get('short_open_tag');
- 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());
- }
-
public function testDoesNotAllowParentDirectoryTraversalByDefault(): void
{
$this->stack->addPath($this->baseDir . '/_templates');
@@ -160,20 +141,6 @@ public function testReturnsFullPathNameWhenAbleToResolveScriptPath(): void
$this->assertEquals($expected, $test);
}
- public function testReturnsPathWithStreamProtocolWhenStreamWrapperEnabled(): void
- {
- $flag = (bool) ini_get('short_open_tag');
- 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');
- $test = $this->stack->resolve('test.phtml');
- $this->assertEquals($expected, $test);
- }
-
/**
* @psalm-return array
*/
@@ -202,9 +169,8 @@ public function testSettingOptionsWithInvalidArgumentRaisesException(mixed $opti
public static function validOptions(): array
{
$options = [
- 'lfi_protection' => false,
- 'use_stream_wrapper' => true,
- 'default_suffix' => 'php',
+ 'lfi_protection' => false,
+ 'default_suffix' => 'php',
];
return [
[$options],
@@ -222,10 +188,6 @@ public function testAllowsSettingOptions($options): void
$this->stack->setOptions($options);
$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());
$this->assertEquals(array_reverse($this->paths), $this->stack->getPaths()->toArray());
@@ -241,10 +203,6 @@ public function testAllowsPassingOptionsToConstructor($options): void
$stack = new TemplatePathStack($options);
$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());
}