Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions phpdotnet/phd/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ final public function registerElementMap(array $map) {
final public function registerTextMap(array $map) {
$this->textmap = $map;
}
final public function attach($obj, $inf = array()): void {
if (!($obj instanceof $this) && get_class($obj) != get_class($this)) {
throw new \InvalidArgumentException(get_class($this) . " themes *MUST* _inherit_ " .get_class($this). ", got " . get_class($obj));
final public function attach(object $object, mixed $info = array()): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal for $info to be mixed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. I only took the type from the parent. In the next PR maybe I will check the types, but I'd rather not restrict the type in this one.

if (!($object instanceof $this) && get_class($object) != get_class($this)) {
throw new \InvalidArgumentException(get_class($this) . " themes *MUST* _inherit_ " .get_class($this). ", got " . get_class($object));
}
$obj->notify(Render::STANDALONE, false);
parent::attach($obj, $inf);
$object->notify(Render::STANDALONE, false);
parent::attach($object, $info);
}
final public function getElementMap() {
return $this->elementmap;
Expand Down
8 changes: 4 additions & 4 deletions phpdotnet/phd/Format/Abstract/Manpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public function UNDEF($open, $name, $attrs, $props) {
return "\n.B [NOT PROCESSED] $name [/NOT PROCESSED]";
}

public function CDATA($str) {
return $this->highlight(trim($str), $this->role, 'troff');
public function CDATA($value) {
return $this->highlight(trim($value), $this->role, 'troff');
}

public function TEXT($str) {
$ret = preg_replace( '/[ \n\t]+/', ' ', $str);
public function TEXT($value) {
$ret = preg_replace( '/[ \n\t]+/', ' ', $value);

// Escape \ ' and NUL byte
$ret = addcslashes($ret, "\\'\0");
Expand Down
6 changes: 3 additions & 3 deletions phpdotnet/phd/Format/Abstract/PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public function UNDEF($open, $name, $attrs, $props) {
return "";
}

public function CDATA($str) {
$this->pdfDoc->appendText(utf8_decode(trim($str)));
public function CDATA($value) {
$this->pdfDoc->appendText(utf8_decode(trim($value)));
return "";
}

Expand All @@ -33,7 +33,7 @@ public function transformFromMap($open, $tag, $name, $attrs, $props) {

public function createLink($for, &$desc = null, $type = Format::SDESC){}

public function TEXT($str) {}
public function TEXT($value) {}

}

Expand Down
10 changes: 5 additions & 5 deletions phpdotnet/phd/Format/Abstract/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function transformFromMap($open, $tag, $name, $attrs, $props) {
return '</' .$tag. '>';
}

public function TEXT($str) {
return htmlspecialchars($str, ENT_QUOTES, "UTF-8");
public function TEXT($value) {
return htmlspecialchars($value, ENT_QUOTES, "UTF-8");
}

public function UNDEF($open, $name, $attrs, $props) {
Expand All @@ -40,15 +40,15 @@ public function UNDEF($open, $name, $attrs, $props) {
}
}

public function CDATA($str) {
public function CDATA($value) {
switch($this->getRole()) {
case '':
return '<div class="cdata"><pre>'
. htmlspecialchars($str, ENT_QUOTES, "UTF-8")
. htmlspecialchars($value, ENT_QUOTES, "UTF-8")
. '</pre></div>';
default:
return '<div class="' . $this->getRole() . 'code">'
. $this->highlight(trim($str), $this->getRole(), 'xhtml')
. $this->highlight(trim($value), $this->getRole(), 'xhtml')
. '</div>';
}
}
Expand Down
14 changes: 7 additions & 7 deletions phpdotnet/phd/ObjectStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@

class ObjectStorage extends \SplObjectStorage
{
public function attach($obj, $inf = array()): void {
if (!($obj instanceof Format)) {
public function attach(object $object, mixed $info = array()): void {
if (!($object instanceof Format)) {
throw new \InvalidArgumentException(
'Only classess inheriting ' . __NAMESPACE__ . '\\Format supported'
);
}
if (empty($inf)) {
$inf = array(
\XMLReader::ELEMENT => $obj->getElementMap(),
\XMLReader::TEXT => $obj->getTextMap(),
if (empty($info)) {
$info = array(
\XMLReader::ELEMENT => $object->getElementMap(),
\XMLReader::TEXT => $object->getTextMap(),
);
}
parent::attach($obj, $inf);
parent::attach($object, $info);
}
}

Expand Down
8 changes: 4 additions & 4 deletions phpdotnet/phd/Package/Generic/BigXHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ public function close() {
}
}

public function update($event, $val = null) {
public function update($event, $value = null) {
switch($event) {
case Render::CHUNK:
$this->flags = $val;
$this->flags = $value;
break;

case Render::STANDALONE:
if ($val) {
if ($value) {
$this->registerElementMap(parent::getDefaultElementMap());
$this->registerTextMap(parent::getDefaultTextMap());
}
break;

case Render::INIT:
if ($val) {
if ($value) {
if (!is_resource($this->getFileStream())) {
$filename = $this->config->output_dir();
if ($this->config->output_filename()) {
Expand Down
6 changes: 3 additions & 3 deletions phpdotnet/phd/Package/Generic/ChunkedXHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public function close() {
}
}

public function update($event, $val = null) {
public function update($event, $value = null) {
switch($event) {
case Render::CHUNK:
$this->flags = $val;
$this->flags = $value;
break;

case Render::STANDALONE:
if ($val) {
if ($value) {
$this->registerElementMap(static::getDefaultElementMap());
$this->registerTextMap(static::getDefaultTextMap());
}
Expand Down
6 changes: 3 additions & 3 deletions phpdotnet/phd/Package/Generic/Manpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ public function __construct(Config $config) {
$this->cchunk = $this->dchunk;
}

public function update($event, $val = null) {
public function update($event, $value = null) {
switch($event) {
case Render::CHUNK:
switch($val) {
switch($value) {
case self::OPEN_CHUNK:
if ($this->getFileStream()) {
/* I have an already open stream, back it up */
Expand Down Expand Up @@ -299,7 +299,7 @@ public function update($event, $val = null) {
break;

case Render::STANDALONE:
if ($val) {
if ($value) {
$this->registerElementMap(self::getDefaultElementMap());
$this->registerTextMap(self::getDefaultTextMap());
} else {
Expand Down
6 changes: 3 additions & 3 deletions phpdotnet/phd/Package/Generic/PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,16 @@ public function getDefaultTextmap() {
return $this->textmap;
}

public function TEXT($str) {
public function TEXT($value) {
if (isset($this->cchunk["refsection"]) && $this->cchunk["refsection"]) // DUMMY REFSECTION DELETION
return "";

if (isset($this->cchunk["verbatim-block"]) && $this->cchunk["verbatim-block"]) {
$this->pdfDoc->appendText(utf8_decode($str));
$this->pdfDoc->appendText(utf8_decode($value));
return "";
}

$ret = utf8_decode(trim(preg_replace('/[ \n\t]+/', ' ', $str)));
$ret = utf8_decode(trim(preg_replace('/[ \n\t]+/', ' ', $value)));
// No whitespace if current text value begins with ',', ';', ':', '.'
if (strncmp($ret, ",", 1) && strncmp($ret, ";", 1) && strncmp($ret, ":", 1) && strncmp($ret, ".", 1))
$this->pdfDoc->appendText(" " . $ret);
Expand Down
8 changes: 4 additions & 4 deletions phpdotnet/phd/Package/Generic/TocFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ public function close()
*
* @return void
*/
public function update($event, $val = null)
public function update($event, $value = null)
{
switch($event) {
case Render::STANDALONE:
if ($val) {
if ($value) {
$this->registerElementMap(static::getDefaultElementMap());
$this->registerTextMap(static::getDefaultTextMap());
}
Expand Down Expand Up @@ -499,9 +499,9 @@ public function CDATA($value)
*
* @uses $targetBaseUri
*/
public function createLink($id, &$desc = null, $type = Format::SDESC)
public function createLink($for, &$desc = null, $type = Format::SDESC)
{
return $this->feedBaseUri . $id . $this->ext;
return $this->feedBaseUri . $for . $this->ext;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions phpdotnet/phd/Package/PEAR/BigXHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ public function appendData($data) {
}
}

public function update($event, $val = null) {
public function update($event, $value = null) {
switch($event) {
case Render::CHUNK:
$this->flags = $val;
$this->flags = $value;
break;

case Render::STANDALONE:
if ($val) {
if ($value) {
$this->registerElementMap(parent::getDefaultElementMap());
$this->registerTextMap(parent::getDefaultTextMap());
}
break;

case Render::INIT:
if ($val) {
if ($value) {
$this->postConstruct();
if ($this->config->css()) {
$this->fetchStylesheet();
Expand Down
8 changes: 4 additions & 4 deletions phpdotnet/phd/Package/PEAR/CHM.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ public function __destruct() {
parent::__destruct();
}

public function update($event, $val = null) {
public function update($event, $value = null) {
switch($event) {
case Render::CHUNK:
parent::update($event, $val);
parent::update($event, $value);
break;
case Render::STANDALONE:
parent::update($event, $val);
parent::update($event, $value);
break;
case Render::INIT:
$this->chmdir = $this->config->output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR;
Expand All @@ -239,7 +239,7 @@ public function update($event, $val = null) {
self::headerChm();
break;
case Render::VERBOSE:
parent::update($event, $val);
parent::update($event, $value);
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions phpdotnet/phd/Package/PEAR/ChunkedXHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public function close() {
}
}

public function update($event, $val = null) {
public function update($event, $value = null) {
switch($event) {
case Render::CHUNK:
$this->flags = $val;
$this->flags = $value;
break;

case Render::STANDALONE:
if ($val) {
if ($value) {
$this->registerElementMap(static::getDefaultElementMap());
$this->registerTextMap(static::getDefaultTextMap());
}
Expand Down
20 changes: 10 additions & 10 deletions phpdotnet/phd/Package/PEAR/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -744,42 +744,42 @@ public function format_literallayout($open, $name, $attrs)
* Format a CDATA section. Automatically trims and highlights
* the text when necessary.
*
* @param string $str CDATA content
* @param string $value CDATA content
*
* @return string Formatted string
*
* @see $trim
* @see $role
*/
public function CDATA($str)
public function CDATA($value)
{
if ($this->trim) {
$str = rtrim($str);
$value = rtrim($value);
}
if (!$this->getRole()) {
return str_replace(
array("\n", ' '), array('<br/>', '&nbsp;'),
htmlspecialchars($str, ENT_QUOTES, 'UTF-8')
htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
);
}

switch ($this->getRole()) {
case 'php':
if (strrpos($str, '<?php') || strrpos($str, '?>')) {
$str = $this->highlight(trim($str), $this->getRole(), 'xhtml');
if (strrpos($value, '<?php') || strrpos($value, '?>')) {
$value = $this->highlight(trim($value), $this->getRole(), 'xhtml');
} else {
$str = $this->highlight("<?php\n" . trim($str) . "\n?>", $this->getRole(), 'xhtml');
$value = $this->highlight("<?php\n" . trim($value) . "\n?>", $this->getRole(), 'xhtml');
}
break;
case '':
$str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
break;
default:
$str = $this->highlight($str, $this->getRole(), 'xhtml');
$value = $this->highlight($value, $this->getRole(), 'xhtml');
break;
}

return $str;
return $value;
}

public function format_surname($open, $name, $attrs)
Expand Down
4 changes: 2 additions & 2 deletions phpdotnet/phd/Package/PHP/BigPDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public function __construct(Config $config) {
$this->registerFormatName("PHP-BigPDF");
}

public function update($event, $val = null) {
public function update($event, $value = null) {
switch($event) {
case Render::STANDALONE:
if ($val) {
if ($value) {
$this->registerElementMap(parent::getDefaultElementMap());
$this->registerTextMap(parent::getDefaultTextMap());
}
Expand Down
8 changes: 4 additions & 4 deletions phpdotnet/phd/Package/PHP/BigXHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ public function appendData($data) {

}

public function update($event, $val = null) {
public function update($event, $value = null) {
switch($event) {
case Render::CHUNK:
$this->flags = $val;
$this->flags = $value;
break;

case Render::STANDALONE:
if ($val) {
if ($value) {
$this->registerElementMap(parent::getDefaultElementMap());
$this->registerTextMap(parent::getDefaultTextMap());
}
break;

case Render::INIT:
if ($val) {
if ($value) {
$this->loadVersionAcronymInfo();
$this->postConstruct();
if ($this->config->css()) {
Expand Down
Loading
Loading