From b1489f40b55e74dec22f0066bfb07bf1e835132c Mon Sep 17 00:00:00 2001 From: umorigu Date: Mon, 4 Jan 2016 12:19:26 +0900 Subject: [PATCH] BugTrack2/369 Support PHP7 - Remove '& new Class' notation Backward incompatible change of PHP7: New objects cannot be assigned by reference The result of the new statement can no longer be assigned to a variable http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.new-by-ref Deprecated code: ``` class C {} $c =& new C; ``` Solution: ``` class C {} $c = new C; ``` These code changes will cause PHP4 imconpatibility in some cases. --- lib/config.php | 14 +++++++------- lib/convert_html.php | 10 +++++----- lib/func.php | 2 +- lib/link.php | 4 ++-- plugin/attach.inc.php | 22 +++++++++++----------- plugin/map.inc.php | 6 +++--- plugin/tracker.inc.php | 6 +++--- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/config.php b/lib/config.php index 3cac328..b2ecce7 100644 --- a/lib/config.php +++ b/lib/config.php @@ -39,7 +39,7 @@ class Config if (! is_page($this->page)) return FALSE; $this->objs = array(); - $obj = & new ConfigTable(''); + $obj = new ConfigTable(''); $matches = array(); foreach (get_source($this->page) as $line) { @@ -57,22 +57,22 @@ class Config if ($level == 1) { $this->objs[$obj->title] = $obj; - $obj = & new ConfigTable($line); + $obj = new ConfigTable($line); } else { if (! is_a($obj, 'ConfigTable_Direct')) - $obj = & new ConfigTable_Direct('', $obj); + $obj = new ConfigTable_Direct('', $obj); $obj->set_key($line); } } else if ($head == '-' && $level > 1) { if (! is_a($obj, 'ConfigTable_Direct')) - $obj = & new ConfigTable_Direct('', $obj); + $obj = new ConfigTable_Direct('', $obj); $obj->add_value($line); } else if ($head == '|' && preg_match('/^\|(.+)\|\s*$/', $line, $matches)) { // Table row if (! is_a($obj, 'ConfigTable_Sequential')) - $obj = & new ConfigTable_Sequential('', $obj); + $obj = new ConfigTable_Sequential('', $obj); // Trim() each table cell $obj->add_value(array_map('trim', explode('|', $matches[1]))); } else { @@ -109,7 +109,7 @@ class Config function & get_object($title) { if (! isset($this->objs[$title])) - $this->objs[$title] = & new ConfigTable('*' . trim($title) . "\n"); + $this->objs[$title] = new ConfigTable('*' . trim($title) . "\n"); return $this->objs[$title]; } @@ -221,4 +221,4 @@ class ConfigTable_Direct extends ConfigTable return $retval; } } -?> + diff --git a/lib/convert_html.php b/lib/convert_html.php index f7831a1..d46686e 100644 --- a/lib/convert_html.php +++ b/lib/convert_html.php @@ -19,7 +19,7 @@ function convert_html($lines) if (! is_array($lines)) $lines = explode("\n", $lines); - $body = & new Body(++$contents_id); + $body = new Body(++$contents_id); $body->parse($lines); return $body->toString(); @@ -191,7 +191,7 @@ class Inline extends Element function & toPara($class = '') { - $obj = & new Paragraph('', $class); + $obj = new Paragraph('', $class); $obj->insert($this); return $obj; } @@ -572,7 +572,7 @@ class Table extends Element $is_template = ($this->type == 'c'); $row = array(); foreach ($cells as $cell) - $row[] = & new TableCell($cell, $is_template); + $row[] = new TableCell($cell, $is_template); $this->elements[] = $row; } @@ -830,7 +830,7 @@ class Body extends Element function Body($id) { $this->id = $id; - $this->contents = & new Element(); + $this->contents = new Element(); $this->contents_last = & $this->contents; parent::Element(); } @@ -1004,4 +1004,4 @@ class Contents_UList extends ListContainer $this->style = sprintf($_list_pad_str, $this->level, $margin, $margin); } } -?> + diff --git a/lib/func.php b/lib/func.php index 217c29e..ab01f9b 100644 --- a/lib/func.php +++ b/lib/func.php @@ -547,7 +547,7 @@ function get_autolink_pattern(& $pages) { global $WikiName, $autolink, $nowikiname; - $config = &new Config('AutoLink'); + $config = new Config('AutoLink'); $config->read(); $ignorepages = $config->get('IgnoreList'); $forceignorepages = $config->get('ForceIgnoreList'); diff --git a/lib/link.php b/lib/link.php index f3b71e9..b265a41 100644 --- a/lib/link.php +++ b/lib/link.php @@ -240,9 +240,9 @@ function & links_get_objects($page, $refresh = FALSE) static $obj; if (! isset($obj) || $refresh) - $obj = & new InlineConverter(NULL, array('note')); + $obj = new InlineConverter(NULL, array('note')); $result = $obj->get_objects(join('', preg_grep('/^(?!\/\/|\s)./', get_source($page))), $page); return $result; } -?> + diff --git a/plugin/attach.inc.php b/plugin/attach.inc.php index a40899b..b6d5816 100644 --- a/plugin/attach.inc.php +++ b/plugin/attach.inc.php @@ -65,7 +65,7 @@ function plugin_attach_convert() $ret = ''; if (! $nolist) { - $obj = & new AttachPages($page); + $obj = new AttachPages($page); $ret .= $obj->toString($page, TRUE); } if (! $noform) { @@ -139,7 +139,7 @@ function attach_filelist() $page = isset($vars['page']) ? $vars['page'] : ''; - $obj = & new AttachPages($page, 0); + $obj = new AttachPages($page, 0); if (! isset($obj->pages[$page])) { return ''; @@ -186,7 +186,7 @@ function attach_upload($file, $page, $pass = NULL) 'msg'=>$_attach_messages['err_adminpass']); } - $obj = & new AttachFile($page, $file['name']); + $obj = new AttachFile($page, $file['name']); if ($obj->exist) return array('result'=>FALSE, 'msg'=>$_attach_messages['err_exists']); @@ -236,7 +236,7 @@ function attach_info($err = '') foreach (array('refer', 'file', 'age') as $var) ${$var} = isset($vars[$var]) ? $vars[$var] : ''; - $obj = & new AttachFile($refer, $file, $age); + $obj = new AttachFile($refer, $file, $age); return $obj->getstatus() ? $obj->info($err) : array('msg'=>$_attach_messages['err_notfound']); @@ -253,7 +253,7 @@ function attach_delete() if (is_freeze($refer) || ! is_editable($refer)) return array('msg'=>$_attach_messages['err_noparm']); - $obj = & new AttachFile($refer, $file, $age); + $obj = new AttachFile($refer, $file, $age); if (! $obj->getstatus()) return array('msg'=>$_attach_messages['err_notfound']); @@ -272,7 +272,7 @@ function attach_freeze($freeze) if (is_freeze($refer) || ! is_editable($refer)) { return array('msg'=>$_attach_messages['err_noparm']); } else { - $obj = & new AttachFile($refer, $file, $age); + $obj = new AttachFile($refer, $file, $age); return $obj->getstatus() ? $obj->freeze($freeze, $pass) : array('msg'=>$_attach_messages['err_notfound']); @@ -291,7 +291,7 @@ function attach_rename() if (is_freeze($refer) || ! is_editable($refer)) { return array('msg'=>$_attach_messages['err_noparm']); } - $obj = & new AttachFile($refer, $file, $age); + $obj = new AttachFile($refer, $file, $age); if (! $obj->getstatus()) return array('msg'=>$_attach_messages['err_notfound']); @@ -308,7 +308,7 @@ function attach_open() ${$var} = isset($vars[$var]) ? $vars[$var] : ''; } - $obj = & new AttachFile($refer, $file, $age); + $obj = new AttachFile($refer, $file, $age); return $obj->getstatus() ? $obj->open() : array('msg'=>$_attach_messages['err_notfound']); @@ -321,7 +321,7 @@ function attach_list() $refer = isset($vars['refer']) ? $vars['refer'] : ''; - $obj = & new AttachPages($refer); + $obj = new AttachPages($refer); $msg = $_attach_messages[($refer == '') ? 'msg_listall' : 'msg_listpage']; $body = ($refer == '' || isset($obj->pages[$refer])) ? @@ -744,7 +744,7 @@ class AttachFiles function add($file, $age) { - $this->files[$file][$age] = & new AttachFile($this->page, $file, $age); + $this->files[$file][$age] = new AttachFile($this->page, $file, $age); } // ファイル一覧を取得 @@ -825,7 +825,7 @@ class AttachPages $_file = decode($matches[2]); $_age = isset($matches[3]) ? $matches[3] : 0; if (! isset($this->pages[$_page])) { - $this->pages[$_page] = & new AttachFiles($_page); + $this->pages[$_page] = new AttachFiles($_page); } $this->pages[$_page]->add($_file, $_age); } diff --git a/plugin/map.inc.php b/plugin/map.inc.php index 6e840ad..39e83b1 100644 --- a/plugin/map.inc.php +++ b/plugin/map.inc.php @@ -46,7 +46,7 @@ function plugin_map_action() // Generate a tree $nodes = array(); foreach ($pages as $page) - $nodes[$page] = & new MapNode($page, $reverse); + $nodes[$page] = new MapNode($page, $reverse); // Node not found: Because of filtererd by $non_list if (! isset($nodes[$refer])) $vars['refer'] = $refer = $defaultpage; @@ -168,7 +168,7 @@ class MapNode if ($this->parent_id == 0) $this->parent_id = -1; foreach ($this->rels as $page) { - if (! isset($nodes[$page])) $nodes[$page] = & new MapNode($page); + if (! isset($nodes[$page])) $nodes[$page] = new MapNode($page); if ($nodes[$page]->parent_id == 0) $nodes[$page]->parent_id = $this->id; } @@ -203,4 +203,4 @@ class MapNode return $retval; } } -?> + diff --git a/plugin/tracker.inc.php b/plugin/tracker.inc.php index 77320cd..cc7877a 100644 --- a/plugin/tracker.inc.php +++ b/plugin/tracker.inc.php @@ -229,7 +229,7 @@ function plugin_tracker_get_fields($base,$refer,&$config) ) as $field=>$class) { $class = 'Tracker_field_'.$class; - $fields[$field] = &new $class(array($field,$_tracker_messages["btn$field"],'','20',''),$base,$refer,$config); + $fields[$field] = new $class(array($field,$_tracker_messages["btn$field"],'','20',''),$base,$refer,$config); } foreach ($config->get('fields') as $field) @@ -242,7 +242,7 @@ function plugin_tracker_get_fields($base,$refer,&$config) $field[2] = 'text'; $field[3] = '20'; } - $fields[$field[0]] = &new $class($field,$base,$refer,$config); + $fields[$field[0]] = new $class($field,$base,$refer,$config); } return $fields; } @@ -638,7 +638,7 @@ function plugin_tracker_getlist($page,$refer,$config_name,$list,$order='',$limit return "

config file '".make_pagelink($config->page.'/'.$list)."' not found.

"; } - $list = &new Tracker_list($page,$refer,$config,$list); + $list = new Tracker_list($page,$refer,$config,$list); $list->sort($order); return $list->toString($limit); } -- 2.11.0