r65578 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65577‎ | r65578 | r65579 >
Date:17:48, 27 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Cleaned up sort class a bit
Modified paths:
  • /trunk/extensions/Validator/TopologicalSort.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/TopologicalSort.php
@@ -102,11 +102,15 @@
103103 *
104104 * @return array of node objects
105105 */
106 - function getRootNodes($nodes) {
 106+ function getRootNodes( array $nodes ) {
107107 $output = array ();
108 - foreach ( $nodes as $name => $node )
109 - if (! count ( $node->parents ))
110 - $output [$name] = $node;
 108+
 109+ foreach ( $nodes as $name => $node ) {
 110+ if ( !count ( $node->parents )) {
 111+ $output[$name] = $node;
 112+ }
 113+ }
 114+
111115 return $output;
112116 }
113117
@@ -121,27 +125,31 @@
122126 * );
123127 *
124128 * @param array $dlist Array of dependency pairs for use as parameter in tsort method
 129+ *
125130 * @return array
126131 */
127 - function parseDependencyList($dlist = array()) {
128 - $output = array ();
129 - foreach ( $dlist as $name => $dependencies )
130 - foreach ( $dependencies as $d )
131 - array_push ( $output, array ($d => $name ) );
 132+ function parseDependencyList( array $dlist = array() ) {
 133+ $output = array();
 134+
 135+ foreach ( $dlist as $name => $dependencies ) {
 136+ foreach ( $dependencies as $d ) {
 137+ array_push ( $output, array ( $d => $name ) );
 138+ }
 139+ }
 140+
132141 return $output;
133142 }
134143 }
135144
136145 /**
137146 * Node class for Topological Sort Class
138 - *
139147 */
140148 class TSNode {
141 - var $name;
142 - var $children = array();
143 - var $parents = array();
 149+ public $name;
 150+ public $children = array();
 151+ public $parents = array();
144152
145 - function TSNode($name = '') {
 153+ function TSNode( $name = '' ) {
146154 $this->name = $name;
147155 }
148156 }
\ No newline at end of file

Status & tagging log