aboutsummaryrefslogtreecommitdiff
path: root/app/class/Modelrender.php
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2020-04-24 16:36:12 +0200
committerVincent Peugnet <33429034+vincent-peugnet@users.noreply.github.com>2020-04-25 17:44:38 +0200
commit385b3f4adf86606e03941171c136d8f2eb2b35c2 (patch)
tree2231cf04d67a5cae7284364ac5552a321b9a236e /app/class/Modelrender.php
parent03d425bdd9a639446ae72ce6556d753f2f162f83 (diff)
downloadwcms-385b3f4adf86606e03941171c136d8f2eb2b35c2.tar.gz
wcms-385b3f4adf86606e03941171c136d8f2eb2b35c2.zip
fix: most of PHPStan errors
Diffstat (limited to 'app/class/Modelrender.php')
-rw-r--r--app/class/Modelrender.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php
index 553857b..7322955 100644
--- a/app/class/Modelrender.php
+++ b/app/class/Modelrender.php
@@ -3,6 +3,7 @@
namespace Wcms;
use Exception;
+use LogicException;
use Michelf\MarkdownExtra;
class Modelrender extends Modelpage
@@ -56,7 +57,11 @@ class Modelrender extends Modelpage
*/
public function upage(string $id): string
{
- return $this->generate('pageread/', ['page' => $id]);
+ try {
+ return $this->router->generate('pageread/', ['page' => $id]);
+ } catch (Exception $e) {
+ throw new LogicException($e->getMessage(), $e->getCode(), $e);
+ }
}
@@ -128,7 +133,7 @@ class Modelrender extends Modelpage
$matches = $this->match($body, $regex);
// First, analyse the synthax and call the corresponding methods
- if (isset($matches)) {
+ if (!empty($matches)) {
foreach ($matches as $key => $match) {
$element = new Element($this->page->id(), $match);
$element->setcontent($this->getelementcontent($element->sources(), $element->type()));
@@ -534,7 +539,7 @@ class Modelrender extends Modelpage
{
$matches = $this->match($text, 'MEDIA');
- if (isset($matches)) {
+ if (!empty($matches)) {
foreach ($matches as $match) {
$medialist = new Medialist($match);
$medialist->readoptions();
@@ -575,7 +580,7 @@ class Modelrender extends Modelpage
$modelhome = new Modelhome();
- if (isset($matches)) {
+ if (!empty($matches)) {
foreach ($matches as $match) {
$optlist = new Optlist(['render' => $this]);
$optlist->parsehydrate($match['options']);