Index: trunk/extensions/Validator/TopologicalSort.php |
— | — | @@ -102,11 +102,15 @@ |
103 | 103 | * |
104 | 104 | * @return array of node objects |
105 | 105 | */ |
106 | | - function getRootNodes($nodes) { |
| 106 | + function getRootNodes( array $nodes ) { |
107 | 107 | $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 | + |
111 | 115 | return $output; |
112 | 116 | } |
113 | 117 | |
— | — | @@ -121,27 +125,31 @@ |
122 | 126 | * ); |
123 | 127 | * |
124 | 128 | * @param array $dlist Array of dependency pairs for use as parameter in tsort method |
| 129 | + * |
125 | 130 | * @return array |
126 | 131 | */ |
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 | + |
132 | 141 | return $output; |
133 | 142 | } |
134 | 143 | } |
135 | 144 | |
136 | 145 | /** |
137 | 146 | * Node class for Topological Sort Class |
138 | | - * |
139 | 147 | */ |
140 | 148 | class TSNode { |
141 | | - var $name; |
142 | | - var $children = array(); |
143 | | - var $parents = array(); |
| 149 | + public $name; |
| 150 | + public $children = array(); |
| 151 | + public $parents = array(); |
144 | 152 | |
145 | | - function TSNode($name = '') { |
| 153 | + function TSNode( $name = '' ) { |
146 | 154 | $this->name = $name; |
147 | 155 | } |
148 | 156 | } |
\ No newline at end of file |