Added:
trunk/Classes/Base/WHReflectionClass.php
Modified:
trunk/Classes/Base/base.php
trunk/Classes/Phaux-base/WHBrowser.php
Log:
The browser is begning to look like the smalltalk browser
Added: trunk/Classes/Base/WHReflectionClass.php
==============================================================================
--- (empty file)
+++ trunk/Classes/Base/WHReflectionClass.php Wed Oct 24 07:23:55 2007
@@ -0,0 +1,21 @@
+<?php
+
+class WHReflectionClass extends ReflectionClass {
+
+ public function getCategory(){
+ if(!$this->isUserDefined()){
+ return 'system';
+ }
+ $parts = explode('/',$this->getFileName());
+ if(sizeof($parts) == 0){
+ //Don't have to worry about Mac : anymore
+ $parts = explode('\\',$this->getFileName());
+ }
+ return $parts[sizeof($parts)-2];
+ }
+
+ public function getMethods(){
+ return parent::getMethods();
+ }
+
+}
\ No newline at end of file
Modified: trunk/Classes/Base/base.php
==============================================================================
--- trunk/Classes/Base/base.php (original)
+++ trunk/Classes/Base/base.php Wed Oct 24 07:23:55 2007
@@ -10,4 +10,5 @@
include("WHDateAndTime.php");
include('WHDuration.php');
include('WHProxyObjectLogCall.php');
-include('WHScopeBreak.php');
\ No newline at end of file
+include('WHScopeBreak.php');
+include('WHReflectionClass.php');
\ No newline at end of file
Modified: trunk/Classes/Phaux-base/WHBrowser.php
==============================================================================
--- trunk/Classes/Phaux-base/WHBrowser.php (original)
+++ trunk/Classes/Phaux-base/WHBrowser.php Wed Oct 24 07:23:55 2007
@@ -3,11 +3,12 @@
class WHBrowser extends WHComponent {
public $currentClass = '';
public $currentMethod = '';
-
+ public $currentCategory = '';
public function setCurrentClass($aString){
$this->currentMethod = '';
$this->currentClass = $aString;
+ $this->currentCategory = $this->currentClassReflected()->getCategory();
return $this;
}
public function currentClass(){
@@ -22,6 +23,16 @@
return $this->currentMethod;
}
+ public function setCurrentCategory($aString){
+ $this->currentCategory = $aString;
+ $this->currentClass = '';
+ $this->currentMethod = '';
+ return $this;
+ }
+
+ public function currentCategory(){
+ return $this->currentCategory();
+ }
public function classList(){
$classes = get_declared_classes();
@@ -29,6 +40,26 @@
return $classes;
}
+ public function currentClassList(){
+ $classInCat = array();
+ foreach($this->classList() as $class){
+ if(Object::construct('WHReflectionClass',$class)->getCategory()
+ == $this->currentCategory){
+
+ $classInCat[] = $class;
+ }
+ }
+ return $classInCat;
+ }
+ public function classCategories(){
+ $keyedCats = array();
+ $keyedCats['system'] = TRUE;
+ foreach($this->classList() as $class){
+
$keyedCats[Object::construct('WHReflectionClass',$class)->getCategory()]
= TRUE;
+ }
+ return array_keys($keyedCats);
+ }
+
public function methodList(){
if($this->currentClass == ''){
return array();
@@ -39,20 +70,70 @@
*/
$methods = $this->currentClassReflected()->getMethods();
+
$methodNames = array();
foreach($methods as $method){
- $methodNames[] = $method->getName();
+
+ if($method->getDeclaringClass()->getName() == $this->currentClassReflected()->getName()){
+ $methodNames[] = $method->getName();
+ }
}
asort($methodNames);
return $methodNames;
}
+ /**
+ **Ick! All this having to do reflection
+ ** in this class makes me feel ill
+ ** We should be able to ask the class about
+ ** it's self
+ */
+ public function methodAsDefined($aMethodName){
+ $method = new ReflectionMethod($this->currentClass,$aMethodName);
+ $return = '';
+ if($method->isStatic()){
+ $return .= 'static ';
+ }
+ if($method->isFinal()){
+ $return .= 'final ';
+ }
+ if($method->isAbstract()){
+ $return .= 'abstract ';
+ }
+ if($method->isPublic()){
+ $return .= 'public ';
+ }
+ if($method->isPrivate()){
+ $return .= 'private ';
+ }
+ if($method->isProtected()){
+ $return .= 'protected ';
+ }
+ if($method->returnsReference()){
+ $return .= ' &';
+ }
+ $return .= $aMethodName.'('.$method->getNumberOfParameters().')';
+ return $return;
+
+ }
+
+ public function methodListWithLabel(){
+ $methodAndLabel = array();
+ foreach($this->methodList() as $method){
+ $methodAndLabel[$method] = $this->methodAsDefined($method);
+ }
+
+ return $methodAndLabel;
+ }
+
+
+
public function currentClassReflected(){
if($this->currentClass == ''){
$this->error('You need to set the class string with setCurrentClass first');
}
- return Object::construct('ReflectionClass',$this->currentClass);
+ return Object::construct('WHReflectionClass',$this->currentClass);
}
public function currentMethodReflected(){
if($this->currentMethod == ''){
@@ -76,6 +157,9 @@
if($this->currentMethod == ''){
return '';
}
+ if(!is_file($this->currentMethodReflected()->getFileName())){
+ return '//UNKNOWN SOURCE';
+ }
$classSource = file($this->currentMethodReflected()->getFileName());
return $this->currentMethodReflected()->getDocComment(). " \n".
@@ -86,16 +170,24 @@
}
public function renderClassSelectionOn($html){
- return $html->form()->with(
- $html->select()->setItems($this->classList())->
- size(10)->
+ return
+ $html->form()->with(
+ $html->select()->setItems($this->classCategories())->
+ size(20)->
+ submitFormOnChange()->
+ callback($this,'setCurrentCategory')->
+ setSelectedItem($this->currentCategory)
+ ).
+ $html->form()->with(
+ $html->select()->setItems($this->currentClassList())->
+ size(20)->
submitFormOnChange()->
callback($this,'setCurrentClass')->
setSelectedItem($this->currentClass)
- ).
+ ).
$html->form()->with(
- $html->select()->setItems($this->methodList())->
- size(10)->
+ $html->select()->itemsAndLabels($this->methodListWithLabel())->
+ size(20)->
submitFormOnChange()->
callback($this,'setCurrentMethod')->
setSelectedItem($this->currentMethod)
@@ -121,6 +213,7 @@
.whbrowser-source {
font-size: 14px;
}
+ .whbrowser select{width:200px;}
';
}