[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] com phd: render return type in PHP 7 style: phpdotnet/phd/Package/Generic/XHTML.php phpdot
From: Peter Cowburn <salathe () php ! net>
Date: 2017-11-15 0:48:06
Message-ID: php-mail-e7dfad42e0c1a2ff62cc7e1c9b9932e92103400191 () git ! php ! net
[Download RAW message or body]
Commit: 126b9bea13ba138e33277bcb3edafd28d6c932f0
Author: Peter Cowburn <salathe@php.net> Wed, 15 Nov 2017 00:48:06 +0000
Parents: 3e2b498c10ccee6e3e4463d2f441c5829e9a08e4
Branches: master
Link: http://git.php.net/?p=phd.git;a=commitdiff;h=126b9bea13ba138e33277bcb3edafd28d6c932f0
Log:
render return type in PHP 7 style
This change moves the return type name to the right-hand side of the
function/method prototypes, along the same lines as PHP 7 code.
Before:
int time ( void )
After:
time ( void ) : int
While this is a step towards PHP 7 style, there are still some
departures. Notably:
- No conversion to valid scalar type names is done (e.g. converting
"<type>boolean</type>" to " : bool")
- Pseudo-types and other invalid type names are used (e.g. resource,
mixed)
Changed paths:
M phpdotnet/phd/Package/Generic/XHTML.php
M phpdotnet/phd/Package/PHP/XHTML.php
Diff:
diff --git a/phpdotnet/phd/Package/Generic/XHTML.php \
b/phpdotnet/phd/Package/Generic/XHTML.php index 053286a..7473d7f 100644
--- a/phpdotnet/phd/Package/Generic/XHTML.php
+++ b/phpdotnet/phd/Package/Generic/XHTML.php
@@ -426,6 +426,9 @@ abstract class Package_Generic_XHTML extends \
Format_Abstract_XHTML { "fieldsynopsis" => array(
"modifier" => "public",
),
+ "methodsynopsis" => array(
+ "returntype" => false,
+ ),
"co" => 0,
"callouts" => 0,
"segmentedlist" => array(
diff --git a/phpdotnet/phd/Package/PHP/XHTML.php \
b/phpdotnet/phd/Package/PHP/XHTML.php index 48f60df..871ad68 100644
--- a/phpdotnet/phd/Package/PHP/XHTML.php
+++ b/phpdotnet/phd/Package/PHP/XHTML.php
@@ -12,6 +12,7 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML {
'colophon' => 'format_chunk',
'function' => 'format_function',
'methodname' => 'format_function',
+ 'methodsynopsis' => 'format_methodsynopsis',
'legalnotice' => 'format_chunk',
'part' => 'format_container_chunk',
'partintro' => 'format_partintro',
@@ -69,7 +70,7 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML {
),
'type' => array(
/* DEFAULT */ 'span',
- 'methodsynopsis' => 'format_type_tag_methodsynopsis',
+ 'methodsynopsis' => 'format_suppressed_tags',
),
);
private $mytextmap = array(
@@ -102,10 +103,7 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML {
'classsynopsisinfo' => false,
'fieldsynopsis' => 'format_type_if_object_or_pseudo_text',
'methodparam' => 'format_type_if_object_or_pseudo_text',
- 'methodsynopsis' => array(
- /* DEFAULT */ 'format_type_if_object_or_pseudo_text',
- 'classsynopsis' => false,
- ),
+ 'methodsynopsis' => 'format_type_methodsynopsis_text',
),
'titleabbrev' => array(
/* DEFAULT */ 'format_suppressed_text',
@@ -390,15 +388,37 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML \
{
}
- public function format_type_tag_methodsynopsis($open, $tag, $attrs, $props) {
+ public function format_methodsynopsis($open, $name, $attrs) {
if ($open) {
- return '<span class="type">';
+ return parent::format_methodsynopsis($open, $name, $attrs);
+ }
+
+ $content = "";
+ if ($this->params["opt"]) {
+ $content = str_repeat("]", $this->params["opt"]);
+ }
+ $content .= " )";
+
+ if ($this->cchunk["methodsynopsis"]["returntype"]) {
+ $return_type = $this->cchunk["methodsynopsis"]["returntype"];
+ $formatted_type = \
self::format_type_if_object_or_pseudo_text($return_type, "type"); + if \
($formatted_type === false) { + $formatted_type = $return_type;
+ }
+ $content .= ' : <span class="type">' . $formatted_type . '</span>';
}
- // Trailing space intentional as phpdoc doesn't have a
- // space between <type> and the <methodname> in methodsynopsis
- return '</span> ';
+ $content .= "</div>\n";
+ $this->cchunk["methodsynopsis"] = $this->dchunk["methodsynopsis"];
+
+ return $content;
}
+
+ public function format_type_methodsynopsis_text($type, $tagname) {
+ $this->cchunk["methodsynopsis"]["returntype"] = $type;
+ return "";
+ }
+
public function format_type_if_object_or_pseudo_text($type, $tagname) {
if (in_array(strtolower($type), array("bool", "int", "double", "boolean", \
"integer", "float", "string", "array", "object", "resource", "null"))) { return \
false;
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic