aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2020-04-28 19:08:49 +0200
committern-peugnet <n.peugnet@free.fr>2020-04-28 19:08:49 +0200
commitd66de69ba57f00079ab8d5e4b9a1d1f73093e76a (patch)
treea65685179e4310912118fff1e39a86621a3eb847
parent30b516bfcf56249c6954bd1aaf4e3c52b18f57fe (diff)
downloadwcms-d66de69ba57f00079ab8d5e4b9a1d1f73093e76a.tar.gz
wcms-d66de69ba57f00079ab8d5e4b9a1d1f73093e76a.zip
tests: phpstan adjustments + 3 phpstan fixes
- force exclude templates and vendor directories @vincent-peugnet: this should stop the phpstan-vscode extension to report errors in templates. - fix errors that were only reported on github because of php 7.3: - Missing @throws JsonException annotation - Regex pattern is invalid: Compilation failed: invalid range in character class at offset 16 in pattern: %(src|href)="([\w-_]+(\/([\w-_])+)*\.[a-z0-9]{1,5})"% the regex expected a range beacause the `-` char was placed in between two others. + `\w` includes `_` - plus one last easy error: PHPDoc tag @param references unknown parameter: $authorcompare
-rw-r--r--app/class/Flywheel/Formatter/JSON.php7
-rw-r--r--app/class/Modelpage.php1
-rw-r--r--app/class/Modelrender.php2
-rw-r--r--phpstan.neon3
4 files changed, 11 insertions, 2 deletions
diff --git a/app/class/Flywheel/Formatter/JSON.php b/app/class/Flywheel/Formatter/JSON.php
index 108c756..8ed8a66 100644
--- a/app/class/Flywheel/Formatter/JSON.php
+++ b/app/class/Flywheel/Formatter/JSON.php
@@ -2,12 +2,19 @@
namespace Wcms\Flywheel\Formatter;
+use JsonException;
+
class JSON implements \JamesMoss\Flywheel\Formatter\FormatInterface
{
public function getFileExtension()
{
return 'json';
}
+
+ /**
+ * @throws JsonException if json_encode fails in PHP7.3
+ * @phpstan-ignore-next-line
+ */
public function encode(array $data)
{
$options = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE : null;
diff --git a/app/class/Modelpage.php b/app/class/Modelpage.php
index 95b6a98..5968248 100644
--- a/app/class/Modelpage.php
+++ b/app/class/Modelpage.php
@@ -308,7 +308,6 @@ class Modelpage extends Modeldb
/**
* @param array $pagelist List of Page
* @param int $secure secure level
- * @param string $authorcompare, can be 'OR' or 'AND', set the author filter method
*
* @return array $array of `string` page id
*/
diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php
index 8f20f83..fa4a6a3 100644
--- a/app/class/Modelrender.php
+++ b/app/class/Modelrender.php
@@ -360,7 +360,7 @@ class Modelrender extends Modelpage
public function media(string $text): string
{
- $regex = '%(src|href)="([\w-_]+(\/([\w-_])+)*\.[a-z0-9]{1,5})"%';
+ $regex = '%(src|href)="([\w\-]+(\/([\w\-])+)*\.[a-z0-9]{1,5})"%';
$text = preg_replace($regex, '$1="' . Model::mediapath() . '$2" target="_blank" class="media"', $text);
if (!is_string($text)) {
//throw new Exception('Rendering error -> media module');
diff --git a/phpstan.neon b/phpstan.neon
index f68256a..c447ba7 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -9,6 +9,9 @@ parameters:
- app/fn
- index.php
- tests
+ excludes_analyse:
+ - app/view/*
+ - vendor/*
exceptionRules:
ignoreDescriptiveUncheckedExceptions: true
# ignore some exceptions and their chlidrens