Fix scrutinizer hints
This commit is contained in:
parent
b5633e93c7
commit
8215808282
@ -15,7 +15,7 @@ class BaseConfig extends ArrayObject
|
|||||||
foreach ($newValues as $key => $value) {
|
foreach ($newValues as $key => $value) {
|
||||||
// If the key doesn't exist yet,
|
// If the key doesn't exist yet,
|
||||||
// we can simply set it.
|
// we can simply set it.
|
||||||
if (!array_key_exists($key, $this)) {
|
if (!array_key_exists($key, /** @scrutinizer ignore-type */ $this)) {
|
||||||
$this[$key] = $value;
|
$this[$key] = $value;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ class BaseConfig extends ArrayObject
|
|||||||
|
|
||||||
public function hasValue($key)
|
public function hasValue($key)
|
||||||
{
|
{
|
||||||
return array_key_exists($key, $this);
|
return array_key_exists($key, /** @scrutinizer ignore-type */ $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValue($key)
|
public function getValue($key)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php namespace Todaymade\Daux;
|
<?php namespace Todaymade\Daux;
|
||||||
|
|
||||||
use Todaymade\Daux\Tree\Content;
|
use Todaymade\Daux\Tree\Content;
|
||||||
|
use Todaymade\Daux\Tree\Entry;
|
||||||
use Todaymade\Daux\Format\HTML\Config as HTMLConfig;
|
use Todaymade\Daux\Format\HTML\Config as HTMLConfig;
|
||||||
use Todaymade\Daux\Format\HTML\Theme as Theme;
|
use Todaymade\Daux\Format\HTML\Theme as Theme;
|
||||||
use Todaymade\Daux\Format\Confluence\Config as ConfluenceConfig;
|
use Todaymade\Daux\Format\Confluence\Config as ConfluenceConfig;
|
||||||
@ -95,7 +96,7 @@ class Config extends BaseConfig
|
|||||||
// As the global configuration is always present, we
|
// As the global configuration is always present, we
|
||||||
// need to test for the existence of the legacy value
|
// need to test for the existence of the legacy value
|
||||||
// first. Then use the current value.
|
// first. Then use the current value.
|
||||||
if (array_key_exists('live', $this) && array_key_exists('inherit_index', $this['live'])) {
|
if ($this->hasValue('live') && array_key_exists('inherit_index', $this['live'])) {
|
||||||
return $this['live']['inherit_index'];
|
return $this['live']['inherit_index'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +165,7 @@ class Config extends BaseConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setImage($value) {
|
public function setImage($value) {
|
||||||
return $this->setValue('image', $value);
|
$this->setValue('image', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocalBase() {
|
public function getLocalBase() {
|
||||||
@ -201,7 +202,7 @@ class Config extends BaseConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setEntryPage($value) {
|
public function setEntryPage($value) {
|
||||||
return $this->setValue('entry_page', $value);
|
$this->setValue('entry_page', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasRequest(): bool {
|
public function hasRequest(): bool {
|
||||||
@ -213,7 +214,7 @@ class Config extends BaseConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setRequest($value) {
|
public function setRequest($value) {
|
||||||
return $this->setValue('request', $value);
|
$this->setValue('request', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIndex() {
|
public function getIndex() {
|
||||||
@ -221,7 +222,7 @@ class Config extends BaseConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setIndex($value) {
|
public function setIndex($value) {
|
||||||
return $this->setValue('index', $value);
|
$this->setValue('index', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasProcessorInstance() {
|
public function hasProcessorInstance() {
|
||||||
@ -233,7 +234,7 @@ class Config extends BaseConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setProcessorInstance($value) {
|
public function setProcessorInstance($value) {
|
||||||
return $this->setValue('processor_instance', $value);
|
$this->setValue('processor_instance', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIgnore() {
|
public function getIgnore() {
|
||||||
|
@ -13,11 +13,11 @@ class ConfigBuilder
|
|||||||
$this->config['local_base'] = dirname(__DIR__);
|
$this->config['local_base'] = dirname(__DIR__);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function fromFile($file): Config {
|
public static function fromFile($file): Config {
|
||||||
return unserialize(file_get_contents($file));
|
return unserialize(file_get_contents($file));
|
||||||
}
|
}
|
||||||
|
|
||||||
static function withMode($mode = Daux::STATIC_MODE): ConfigBuilder {
|
public static function withMode($mode = Daux::STATIC_MODE): ConfigBuilder {
|
||||||
$builder = new ConfigBuilder($mode);
|
$builder = new ConfigBuilder($mode);
|
||||||
$builder->loadBaseConfiguration();
|
$builder->loadBaseConfiguration();
|
||||||
return $builder;
|
return $builder;
|
||||||
@ -101,7 +101,7 @@ class ConfigBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function build(): Config {
|
public function build(): Config {
|
||||||
$this->initializeConfiguration();
|
$this->initializeConfiguration();
|
||||||
|
|
||||||
return $this->config;
|
return $this->config;
|
||||||
@ -257,7 +257,7 @@ class ConfigBuilder
|
|||||||
/**
|
/**
|
||||||
* @param string|null $path
|
* @param string|null $path
|
||||||
* @param string $basedir
|
* @param string $basedir
|
||||||
* @param "dir"|"file" $type
|
* @param string $type
|
||||||
* @return false|null|string
|
* @return false|null|string
|
||||||
*/
|
*/
|
||||||
private function findLocation($path, $basedir, $type) {
|
private function findLocation($path, $basedir, $type) {
|
||||||
|
@ -61,7 +61,7 @@ class DauxCommand extends SymfonyCommand
|
|||||||
{
|
{
|
||||||
$class = $daux->getProcessorClass();
|
$class = $daux->getProcessorClass();
|
||||||
if (!empty($class)) {
|
if (!empty($class)) {
|
||||||
$daux->setProcessor(new $class($daux, $output, $width));
|
$daux->setProcessor(new $class($daux, $daux->getOutput(), $width));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,12 @@ class Serve extends DauxCommand
|
|||||||
|
|
||||||
// Write the current configuration to a file to read it from the other serving side
|
// Write the current configuration to a file to read it from the other serving side
|
||||||
$file = tmpfile();
|
$file = tmpfile();
|
||||||
|
|
||||||
|
if (!$file) {
|
||||||
|
$output->writeln("<fg=red>Failed to create temporary file for configuration</fg=red>");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
$path = stream_get_meta_data($file)['uri'];
|
$path = stream_get_meta_data($file)['uri'];
|
||||||
fwrite($file, serialize($daux->getConfig()));
|
fwrite($file, serialize($daux->getConfig()));
|
||||||
|
|
||||||
|
@ -5,62 +5,62 @@ use Todaymade\Daux\BaseConfig;
|
|||||||
class Config extends BaseConfig
|
class Config extends BaseConfig
|
||||||
{
|
{
|
||||||
public function shouldAutoDeleteOrphanedPages() {
|
public function shouldAutoDeleteOrphanedPages() {
|
||||||
if (array_key_exists('delete', $this)) {
|
if ($this->hasValue('delete')) {
|
||||||
return $this['delete'];
|
return $this->getValue('delete');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUpdateThreshold() {
|
public function getUpdateThreshold() {
|
||||||
return array_key_exists('update_threshold', $this) ? $this['update_threshold'] : 2;
|
return $this->hasValue('update_threshold') ? $this->getValue('update_threshold') : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrefix() {
|
public function getPrefix() {
|
||||||
return $this['prefix'];
|
return $this->getValue('prefix');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBaseUrl() {
|
public function getBaseUrl() {
|
||||||
return $this['base_url'];
|
return $this->getValue('base_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser() {
|
public function getUser() {
|
||||||
return $this['user'];
|
return $this->getValue('user');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPassword() {
|
public function getPassword() {
|
||||||
return $this['pass'];
|
return $this->getValue('pass');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSpaceId() {
|
public function getSpaceId() {
|
||||||
return $this['space_id'];
|
return $this->getValue('space_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasAncestorId() {
|
public function hasAncestorId() {
|
||||||
return array_key_exists('ancestor_id', $this);
|
return $this->hasValue('ancestor_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAncestorId() {
|
public function getAncestorId() {
|
||||||
return $this['ancestor_id'];
|
return $this->getValue('ancestor_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAncestorId($value) {
|
public function setAncestorId($value) {
|
||||||
$this['ancestor_id'] = $value;
|
$this->setValue('ancestor_id', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasRootId() {
|
public function hasRootId() {
|
||||||
return array_key_exists('root_id', $this);
|
return $this->hasValue('root_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRootId() {
|
public function getRootId() {
|
||||||
return $this['root_id'];
|
return $this->getValue('root_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasHeader() {
|
public function hasHeader() {
|
||||||
return array_key_exists('header', $this);
|
return $this->hasValue('header');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeader() {
|
public function getHeader() {
|
||||||
return $this['header'];
|
return $this->getValue('header');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ use League\CommonMark\ElementRendererInterface;
|
|||||||
use League\CommonMark\HtmlElement;
|
use League\CommonMark\HtmlElement;
|
||||||
use League\CommonMark\Inline\Element\AbstractInline;
|
use League\CommonMark\Inline\Element\AbstractInline;
|
||||||
use League\CommonMark\Inline\Element\Image;
|
use League\CommonMark\Inline\Element\Image;
|
||||||
|
use League\CommonMark\Inline\Renderer\InlineRendererInterface;
|
||||||
use League\CommonMark\Util\ConfigurationAwareInterface;
|
use League\CommonMark\Util\ConfigurationAwareInterface;
|
||||||
use League\CommonMark\Util\ConfigurationInterface;
|
use League\CommonMark\Util\ConfigurationInterface;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config as GlobalConfig;
|
||||||
use Todaymade\Daux\Console\RunAction;
|
use Todaymade\Daux\Console\RunAction;
|
||||||
use Todaymade\Daux\Daux;
|
use Todaymade\Daux\Daux;
|
||||||
use Todaymade\Daux\Tree\Content;
|
use Todaymade\Daux\Tree\Content;
|
||||||
@ -40,7 +40,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
|||||||
$mandatory = ['space_id', 'base_url', 'user', 'pass', 'prefix'];
|
$mandatory = ['space_id', 'base_url', 'user', 'pass', 'prefix'];
|
||||||
$errors = [];
|
$errors = [];
|
||||||
foreach ($mandatory as $key) {
|
foreach ($mandatory as $key) {
|
||||||
if (!array_key_exists($key, $confluence)) {
|
if (!$confluence->hasValue($key)) {
|
||||||
$errors[] = $key;
|
$errors[] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
|||||||
$publisher->publish($tree);
|
$publisher->publish($tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateRecursive(Directory $tree, Config $config, $base_url = '')
|
private function generateRecursive(Directory $tree, GlobalConfig $config, $base_url = '')
|
||||||
{
|
{
|
||||||
$final = ['title' => $this->prefix . $tree->getTitle()];
|
$final = ['title' => $this->prefix . $tree->getTitle()];
|
||||||
$config['base_url'] = $base_url;
|
$config['base_url'] = $base_url;
|
||||||
|
@ -16,17 +16,18 @@ class Config extends BaseConfig
|
|||||||
|
|
||||||
public function getEditOn()
|
public function getEditOn()
|
||||||
{
|
{
|
||||||
if (array_key_exists('edit_on', $this)) {
|
if ($this->hasValue('edit_on')) {
|
||||||
if (is_string($this['edit_on'])) {
|
$edit_on = $this->getValue('edit_on');
|
||||||
return $this->prepareGithubUrl($this['edit_on']);
|
if (is_string($edit_on)) {
|
||||||
|
return $this->prepareGithubUrl($edit_on);
|
||||||
} else {
|
} else {
|
||||||
$this['edit_on']['basepath'] = rtrim($this['edit_on']['basepath'], '/');
|
$edit_on['basepath'] = rtrim($edit_on['basepath'], '/');
|
||||||
|
|
||||||
return $this['edit_on'];
|
return $edit_on;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('edit_on_github', $this)) {
|
if ($this->hasValue('edit_on_github')) {
|
||||||
return $this->prepareGithubUrl($this->getValue('edit_on_github'));
|
return $this->prepareGithubUrl($this->getValue('edit_on_github'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config as GlobalConfig;
|
||||||
use Todaymade\Daux\Console\RunAction;
|
use Todaymade\Daux\Console\RunAction;
|
||||||
use Todaymade\Daux\Daux;
|
use Todaymade\Daux\Daux;
|
||||||
use Todaymade\Daux\DauxHelper;
|
use Todaymade\Daux\DauxHelper;
|
||||||
@ -143,14 +143,14 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
|||||||
*
|
*
|
||||||
* @param Directory $tree
|
* @param Directory $tree
|
||||||
* @param string $output_dir
|
* @param string $output_dir
|
||||||
* @param \Todaymade\Daux\Config $config
|
* @param GlobalConfig $config
|
||||||
* @param OutputInterface $output
|
* @param OutputInterface $output
|
||||||
* @param int $width
|
* @param int $width
|
||||||
* @param bool $index_pages
|
* @param bool $index_pages
|
||||||
* @param string $base_url
|
* @param string $base_url
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private function generateRecursive(Directory $tree, $output_dir, $config, $output, $width, $index_pages, $base_url = '')
|
private function generateRecursive(Directory $tree, $output_dir, GlobalConfig $config, $output, $width, $index_pages, $base_url = '')
|
||||||
{
|
{
|
||||||
DauxHelper::rebaseConfiguration($config, $base_url);
|
DauxHelper::rebaseConfiguration($config, $base_url);
|
||||||
|
|
||||||
@ -197,10 +197,10 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Entry $node
|
* @param Entry $node
|
||||||
* @param Config $config
|
* @param GlobalConfig $config
|
||||||
* @return \Todaymade\Daux\Format\Base\Page
|
* @return \Todaymade\Daux\Format\Base\Page
|
||||||
*/
|
*/
|
||||||
public function generateOne(Entry $node, Config $config)
|
public function generateOne(Entry $node, GlobalConfig $config)
|
||||||
{
|
{
|
||||||
if ($node instanceof Raw) {
|
if ($node instanceof Raw) {
|
||||||
return new RawPage($node->getPath());
|
return new RawPage($node->getPath());
|
||||||
|
@ -4,7 +4,7 @@ namespace Todaymade\Daux\Format\HTML;
|
|||||||
|
|
||||||
use League\Plates\Engine;
|
use League\Plates\Engine;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config as GlobalConfig;
|
||||||
use Todaymade\Daux\Daux;
|
use Todaymade\Daux\Daux;
|
||||||
use Todaymade\Daux\Tree\Content;
|
use Todaymade\Daux\Tree\Content;
|
||||||
use Todaymade\Daux\Tree\Directory;
|
use Todaymade\Daux\Tree\Directory;
|
||||||
@ -19,12 +19,12 @@ class Template
|
|||||||
* @param string $base
|
* @param string $base
|
||||||
* @param string $theme
|
* @param string $theme
|
||||||
*/
|
*/
|
||||||
public function __construct(Config $config)
|
public function __construct(GlobalConfig $config)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEngine(Config $config)
|
public function getEngine(GlobalConfig $config)
|
||||||
{
|
{
|
||||||
if ($this->engine) {
|
if ($this->engine) {
|
||||||
return $this->engine;
|
return $this->engine;
|
||||||
|
@ -49,7 +49,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
|||||||
|
|
||||||
$config = $this->daux->getConfig();
|
$config = $this->daux->getConfig();
|
||||||
if (is_null($destination)) {
|
if (is_null($destination)) {
|
||||||
$destination = $this->config->getLocalBase() . DIRECTORY_SEPARATOR . 'static';
|
$destination = $config->getLocalBase() . DIRECTORY_SEPARATOR . 'static';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->runAction(
|
$this->runAction(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user