Skip to content

Commit

Permalink
Dev: Psalm fixes for TemplateConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Mar 1, 2021
1 parent 6249acc commit 081fb3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions application/models/TemplateConfig.php
Expand Up @@ -59,7 +59,7 @@ class TemplateConfig extends CActiveRecord
*/
public $oMotherTemplate;

/** @var array $oOptions The template options */
/** @var object $oOptions The template options */
public $oOptions;
public $oOptionAttributes;

Expand Down Expand Up @@ -348,7 +348,7 @@ protected function getFilePath($sFile, $oTemplate)
* Get the depends package
* @uses self::@package
* @param TemplateConfiguration $oTemplate
* @return string[]
* @return stdClass[]
*/
protected function getDependsPackages($oTemplate)
{
Expand Down
18 changes: 11 additions & 7 deletions application/models/TemplateConfiguration.php
Expand Up @@ -1125,9 +1125,8 @@ protected function getOfiles($oTemplate, $sField)
if ($oFiles === null) {
App()->setFlashMessage(
sprintf(
gT('Error: Malformed JSON - field %s must be either a JSON array or the string "inherit". Found "%s".'),
$sField,
$oFiles
gT('Error: Malformed JSON - field %s must be either a JSON array or the string "inherit". Found "null".'),
$sField
),
'error'
);
Expand Down Expand Up @@ -1164,7 +1163,7 @@ protected function setMotherTemplates()
$sMotherTemplateName = $this->template->extends;
$instance = TemplateConfiguration::getInstanceFromTemplateName($sMotherTemplateName);
$instance->template->checkTemplate();
$this->oMotherTemplate = $instance->prepareTemplateRendering($sMotherTemplateName, null);
$this->oMotherTemplate = $instance->prepareTemplateRendering($sMotherTemplateName, '');
}
}

Expand Down Expand Up @@ -1241,6 +1240,7 @@ protected function setThisTemplate()

/**
* @todo document me
* @return void
*/
private function setCssFramework()
{
Expand All @@ -1250,18 +1250,22 @@ private function setCssFramework()
$this->cssFramework->css = json_decode($this->cssframework_css);
$this->cssFramework->js = json_decode($this->cssframework_js);
} else {
$this->cssFramework = '';
$this->cssFramework = new \stdClass();
$this->cssFramework->name = '';
$this->cssFramework->css = '';
$this->cssFramework->js = '';
}
}

/**
* @todo document me
* @return void
*/
protected function setOptions()
{
$this->oOptions = array();
$this->oOptions = new stdClass();
if (!empty($this->options)) {
$this->oOptions = json_decode($this->options);
$this->oOptions = json_decode($this->options, true);
}
// unset "comment" property which is auto generated from HTML comments in xml file
unset($this->oOptions->comment);
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Expand Up @@ -11,6 +11,7 @@
<directory name="application/datavalueobjects" />
<directory name="application/models/services" />
<file name="application/models/TemplateConfig.php" />
<file name="application/models/TemplateConfiguration.php" />
<ignoreFiles>
<directory name="third_party" />
<directory name="framework" />
Expand Down

0 comments on commit 081fb3b

Please sign in to comment.