Skip to content
Browse files

dont recursively remove duplicate included/extended_modules

  • Loading branch information...
1 parent 169a142 commit e140a57d3dafed435b04474b393387d6fca300ef @shuber committed Mar 1, 2011
Showing with 13 additions and 11 deletions.
  1. +13 −11 lib/klass.php
View
24 lib/klass.php
@@ -77,26 +77,28 @@ function extend($modules) {
return $this;
}
- function extended_modules() {
- $modules = $this->__class()->included_modules();
+ function extended_modules($unique = true) {
+ $modules = $this->__class()->included_modules(false);
if (is_subclass_of($this, __CLASS__)) {
- $modules = array_merge($modules, $this->reference()->extended_modules());
+ $modules = array_merge($modules, $this->reference()->extended_modules(false));
} else if ($this->superclass()) {
- $modules = array_merge($modules, $this->superclass()->extended_modules());
+ $modules = array_merge($modules, $this->superclass()->extended_modules(false));
}
- $modules = array_diff($modules, Klass::instance(__CLASS__)->included_modules());
- return array_reverse(array_unique(array_reverse($modules), SORT_REGULAR));
+ $modules = array_diff($modules, Klass::instance(__CLASS__)->included_modules(false));
+ if ($unique) $modules = array_reverse(array_unique(array_reverse($modules), SORT_REGULAR));
+ return $modules;
}
- function included_modules() {
+ function included_modules($unique = true) {
$modules = array();
- foreach ($this->_included_modules as $module) $modules = array_merge($module->included_modules(), array($module), $modules);
+ foreach ($this->_included_modules as $module) $modules = array_merge($modules, $module->included_modules(false), array($module));
if (is_subclass_of($this, __CLASS__)) {
- $modules = array_merge($modules, $this->reference()->included_modules());
+ $modules = array_merge($modules, $this->reference()->included_modules(false));
} else if ($this->superclass()) {
- $modules = array_merge($modules, $this->superclass()->included_modules());
+ $modules = array_merge($modules, $this->superclass()->included_modules(false));
}
- return array_reverse(array_unique(array_reverse($modules), SORT_REGULAR));
+ if ($unique) $modules = array_reverse(array_unique(array_reverse($modules), SORT_REGULAR));
+ return $modules;
}
function instance_methods($include_super = true) {

0 comments on commit e140a57

Please sign in to comment.
Something went wrong with that request. Please try again.