Exemplo n.º 1
0
 /**
  * Renders the expendable around the array analysis.
  *
  * @return string
  *   The generated markup.
  */
 public function callMe()
 {
     $output = '';
     $recursionMarker = $this->storage->recursionHandler->getMarker();
     $output .= $this->storage->render->renderSingeChildHr();
     // Iterate through.
     foreach ($this->parameters['data'] as $key => &$value) {
         // We will not output our recursion marker.
         // Meh, the only reason for the recursion marker
         // in arrays is because of the $GLOBAL array, which
         // we will only render once.
         if ($key === $recursionMarker) {
             continue;
         }
         if (is_string($key)) {
             $key = $this->storage->encodeString($key);
         }
         $model = new Model($this->storage);
         // Are we dealing with multiline code generation?
         if ($this->parameters['multiline'] === true) {
             // Here we tel the Codegen service that we need some
             // special handling.
             $model->setMultiLineCodeGen('iterator_to_array');
         }
         if (is_string($key)) {
             $model->setData($value)->setName($key)->setConnector1('[\'')->setConnector2('\']');
         } else {
             $model->setData($value)->setName($key)->setConnector1('[')->setConnector2(']');
         }
         $output .= $this->storage->routing->analysisHub($model);
     }
     $output .= $this->storage->render->renderSingeChildHr();
     return $output;
 }
Exemplo n.º 2
0
 /**
  * Iterate though the result of the polled debug methods.
  *
  * @return string
  *   The generated markup.
  */
 public function callMe()
 {
     $model = new Model($this->storage);
     $model->setData($this->parameters['data'])->setName('result');
     // This could be anything, we need to route it.
     return $this->storage->routing->analysisHub($model);
 }
Exemplo n.º 3
0
 /**
  * Renders each section of the footer.
  *
  * @return string
  *   The generated markup.
  */
 public function callMe()
 {
     $sectionOutput = '';
     foreach ($this->parameters['data'] as $name => $setting) {
         // Render the single value.
         // We need to find out where the value comes from.
         $value = $setting->getValue();
         if ($setting->getType() != 'None') {
             // We need to re-translate booleans to something the
             // frontend can understand.
             if ($value === true) {
                 $value = 'true';
             }
             if ($value === false) {
                 $value = 'false';
             }
             $model = new Model($this->storage);
             if ($setting->getEditable()) {
                 $model->setData($name)->setName($value)->setNormal($setting->getSource())->setType($setting->getType())->setHelpid($name);
                 $sectionOutput .= $this->storage->render->renderSingleEditableChild($model);
             } else {
                 $model->setData($value)->setName($name)->setNormal($value)->setType($setting->getSource())->setHelpid($name);
                 $sectionOutput .= $this->storage->render->renderSingleChild($model);
             }
         }
     }
     return $sectionOutput;
 }
Exemplo n.º 4
0
 /**
  * Renders whole configuration.
  *
  * @return string
  *   The generated markup.
  */
 public function callMe()
 {
     $configOutput = '';
     // We need to "explode" our config array into the
     // sections again, for better readability.
     $sections = array();
     foreach ($this->storage->config->settings as $name => $setting) {
         $sections[$setting->getSection()][$name] = $setting;
     }
     foreach ($sections as $sectionName => $sectionData) {
         // Render a whole section.
         $model = new Model($this->storage);
         $model->setName($sectionName)->setType('Config')->setAdditional('. . .')->addParameter('data', $sectionData)->initCallback('Analyse\\ConfigSection');
         $configOutput .= $this->storage->render->renderExpandableChild($model);
     }
     // Render the dev-handle field.
     $editableModel = new Model($this->storage);
     $data = 'Local open function';
     $editableModel->setData($data)->setName($this->storage->config->getDevHandler())->setNormal('\\krexx::')->setType('Input')->setHelpid('localFunction');
     $configOutput .= $this->storage->render->renderSingleEditableChild($editableModel);
     // Render the reset-button which will delete the debug-cookie.
     $buttonModel = new Model($this->storage);
     $buttonModel->setName('resetbutton')->setNormal('Reset local settings')->setHelpid('resetbutton');
     $configOutput .= $this->storage->render->renderButton($buttonModel);
     return $configOutput;
 }
Exemplo n.º 5
0
 /**
  * Simply iterate though object constants.
  *
  * @return string
  *   The generated markup.
  */
 public function callMe()
 {
     $output = '';
     // We do not need to check the recursionHandler, this is class
     // internal stuff. Is it even possible to create a recursion here?
     // Iterate through.
     foreach ($this->parameters['data'] as $k => &$v) {
         $model = new Model($this->storage);
         $model->setData($v)->setName($k)->setConnector1($this->parameters['classname'] . '::');
         $output .= $this->storage->routing->analysisHub($model);
     }
     return $output;
 }
Exemplo n.º 6
0
 /**
  * Renders the info of a single method.
  *
  * @return string
  *   The generated markup.
  */
 public function callMe()
 {
     $data = $this->parameters['data'];
     $output = '';
     foreach ($data as $key => $string) {
         $model = new Model($this->storage);
         $model->setData($string)->setName($key)->setType('reflection')->setConnector2('=');
         if ($key !== 'comments' && $key !== 'declared in' && $key !== 'source') {
             $model->setNormal($string);
         } else {
             $model->setNormal('. . .');
             $model->hasExtras();
         }
         $output .= $this->storage->render->renderSingleChild($model);
     }
     return $output;
 }
Exemplo n.º 7
0
 /**
  * Renders the properties of a class.
  *
  * @return string
  *   The generated markup.
  */
 public function callMe()
 {
     // I need to preprocess them, since I do not want to render a
     // reflection property.
     /* @var \ReflectionClass $ref */
     $ref = $this->parameters['ref'];
     $output = '';
     $default = $ref->getDefaultProperties();
     foreach ($this->parameters['data'] as $refProperty) {
         /* @var \ReflectionProperty $refProperty */
         $refProperty->setAccessible(true);
         // Getting our values from the reflection.
         $value = $refProperty->getValue($this->parameters['orgObject']);
         $propName = $refProperty->name;
         if (is_null($value) && $refProperty->isDefault()) {
             // We might want to look at the default value.
             $value = $default[$propName];
         }
         // Check memory and runtime.
         if (!$this->storage->emergencyHandler->checkEmergencyBreak()) {
             return '';
         }
         // Recursion tests are done in the analyseObject and
         // iterateThrough (for arrays).
         // We will not check them here.
         // Now that we have the key and the value, we can analyse it.
         // Stitch together our additional info about the data:
         // public, protected, private, static.
         $additional = '';
         $connector1 = '->';
         if ($refProperty->isPublic()) {
             $additional .= 'public ';
         }
         if ($refProperty->isPrivate()) {
             $additional .= 'private ';
         }
         if ($refProperty->isProtected()) {
             $additional .= 'protected ';
         }
         if (is_a($refProperty, '\\Brainworxx\\Krexx\\Analysis\\Flection')) {
             /* @var \Brainworxx\Krexx\Analyse\Flection $refProperty */
             $additional .= $refProperty->getWhatAmI() . ' ';
         }
         if ($refProperty->isStatic()) {
             $additional .= 'static ';
             $connector1 = '::';
             // There is always a $ in front of a static property.
             $propName = '$' . $propName;
         }
         // Stitch together our model
         $model = new Model($this->storage);
         $model->setData($value)->setName($propName)->setAdditional($additional)->setConnector1($connector1);
         $output .= $this->storage->routing->analysisHub($model);
     }
     return $output;
 }
Exemplo n.º 8
0
 /**
  * Render a dump for a string value.
  *
  * @param Model $model
  *   The data we are analysing.
  *
  * @return string
  *   The rendered markup.
  */
 public function analyseString(Model $model)
 {
     $json = array();
     $json['type'] = 'string';
     $data = $model->getData();
     // Extra ?
     if (strlen($data) > 50) {
         $cut = substr($this->storage->encodeString($data), 0, 50) . '. . .';
         $model->hasExtras();
     } else {
         $cut = $this->storage->encodeString($data);
     }
     $json['encoding'] = @mb_detect_encoding($data);
     // We need to take care for mixed encodings here.
     $json['length'] = (string) ($strlen = @mb_strlen($data, $json['encoding']));
     if ($strlen === false) {
         // Looks like we have a mixed encoded string.
         $json['length'] = '~ ' . strlen($data);
         $strlen = ' broken encoding ' . $json['length'];
         $json['encoding'] = 'broken';
     }
     $data = $this->storage->encodeString($data);
     $model->setData($data)->setNormal($cut)->setType($model->getAdditional() . 'string' . ' ' . $strlen)->setJson($json);
     // Check if this is a possible callback.
     // We are not going to analyse this further, because modern systems
     // do not use these anymore.
     if (is_callable($data)) {
         $model->setIsCallback(true);
     }
     return $this->storage->render->renderSingleChild($model);
 }
Exemplo n.º 9
0
 /**
  * Dump information about a variable.
  *
  * Here everything starts and ends (well, unless we are only outputting
  * the settings editor).
  *
  * @param mixed $data
  *   The variable we want to analyse.
  * @param string $headline
  *   The headline of the markup we want to produce. Most likely the name of
  *   the variable.
  */
 public function dumpAction($data, $headline = '')
 {
     if ($this->storage->emergencyHandler->checkMaxCall()) {
         // Called too often, we might get into trouble here!
         return;
     }
     $this->storage->reset();
     // Find caller.
     $caller = $this->storage->callerFinder->findCaller();
     if ($headline != '') {
         $caller['type'] = $headline;
     } else {
         $caller['type'] = 'Analysis';
     }
     $this->storage->codegenHandler->setScope($caller['varname']);
     // Set the headline, if it's not set already.
     if (empty($headline)) {
         if (is_object($data)) {
             $headline = get_class($data);
         }
         if (is_array($data)) {
             $headline = 'array';
         }
         if (is_bool($data)) {
             $headline = 'boolean';
         }
         if (is_float($data)) {
             $headline = 'float';
         }
         if (is_int($data)) {
             $headline = 'integer';
         }
         if (is_null($data)) {
             $headline = 'null';
         }
         if (is_resource($data)) {
             $headline = 'resource';
         }
         if (is_string($data)) {
             $headline = 'string';
         }
     }
     // We need to get the footer before the generating of the header,
     // because we need to display messages in the header from the configuration.
     $footer = $this->outputFooter($caller);
     $this->storage->codegenHandler->checkAllowCodegen();
     // Enable code generation only if we were aqble to determine the varname.
     if ($caller['varname'] != '. . .') {
         // We were able to determine the variable name and can generate some
         // sourcecode.
         $headline = $caller['varname'];
     }
     // Start the magic.
     $model = new Model($this->storage);
     $model->setData($data)->setName($caller['varname']);
     $analysis = $this->storage->routing->analysisHub($model);
     // Now that our analysis is done, we must check if there was an emergency
     // break.
     if (!$this->storage->emergencyHandler->checkEmergencyBreak()) {
         return;
     }
     $this->shutdownHandler->addChunkString($this->outputHeader($headline));
     $this->shutdownHandler->addChunkString($analysis);
     $this->shutdownHandler->addChunkString($footer);
     // Add the caller as metadata to the chunks class. It will be saved as
     // additional info, in case we are logging to a file.
     if ($this->storage->config->getSetting('destination') === 'file') {
         $this->storage->chunks->addMetadata($caller);
     }
 }
Exemplo n.º 10
0
 /**
  * Try to get the possible result of all getter methods.
  *
  * @return string
  *   The generated markup.
  */
 public function callMe()
 {
     $output = '';
     /** @var \reflectionClass $ref */
     $ref = $this->parameters['ref'];
     foreach ($this->parameters['methodList'] as $methodName) {
         $propertyName = substr($methodName, 3);
         // We may be facing different writing styles.
         // The property we want from getMyProperty() should be named
         // myProperty, but we can not rely on this.
         // We will check:
         // MyProperty
         // myProperty
         // myproperty
         // my_property
         if ($ref->hasProperty($propertyName)) {
             $refProp = $ref->getProperty($propertyName);
         }
         $realName = lcfirst($propertyName);
         if ($ref->hasProperty(lcfirst($realName))) {
             $refProp = $ref->getProperty($realName);
         }
         $realName = strtolower($propertyName);
         if ($ref->hasProperty(strtolower($realName))) {
             $refProp = $ref->getProperty($realName);
         }
         $realName = $this->convertToSnakeCase($propertyName);
         if ($ref->hasProperty($this->convertToSnakeCase($realName))) {
             $refProp = $ref->getProperty($realName);
         }
         if (empty($refProp)) {
             // Found nothing  :-(
             $value = null;
         } else {
             // We've got ourself a possible result!
             $refProp->setAccessible(true);
             $value = $refProp->getValue($this->parameters['data']);
         }
         // We need to decide if we are handling static getters.
         $model = new Model($this->storage);
         $model->setData($value)->setName($methodName)->setConnector2('()');
         if ($ref->getMethod($methodName)->isStatic()) {
             $model->setConnector1('::');
         } else {
             $model->setConnector1('->');
         }
         $output .= $this->storage->routing->analysisHub($model);
     }
     return $output;
 }
Exemplo n.º 11
0
 /**
  * Renders a backtrace step.
  *
  * @return string
  *   The generated markup.
  */
 public function callMe()
 {
     $output = '';
     // We are handling the following values here:
     // file, line, function, object, type, args, sourcecode.
     $stepData = $this->parameters['data'];
     // File.
     if (isset($stepData['file'])) {
         $fileModel = new Model($this->storage);
         $fileModel->setData($stepData['file'])->setName('File')->setNormal($stepData['file'])->setType('string ' . strlen($stepData['file']));
         $output .= $this->storage->render->renderSingleChild($fileModel);
     }
     // Line.
     if (isset($stepData['line'])) {
         $lineModel = new Model($this->storage);
         $lineModel->setData($stepData['line'])->setName('Line no.')->setNormal($stepData['line'])->setType('integer');
         $output .= $this->storage->render->renderSingleChild($lineModel);
     }
     // Sourcecode, is escaped by now.
     $sourceModel = new Model($this->storage);
     if (isset($stepData['line'])) {
         $lineNo = $stepData['line'] + $this->parameters['offset'];
         $source = trim($this->storage->readSourcecode($stepData['file'], $lineNo, $lineNo - 5, $lineNo + 5));
         if (empty($source)) {
             $source = $this->storage->messages->getHelp('noSourceAvailable');
         }
     } else {
         $source = $this->storage->messages->getHelp('noSourceAvailable');
     }
     $sourceModel->setData($source)->setName('Sourcecode')->setNormal('. . .')->hasExtras()->setType('PHP');
     $output .= $this->storage->render->renderSingleChild($sourceModel);
     // Function.
     if (isset($stepData['function'])) {
         $functionModel = new Model($this->storage);
         $functionModel->setData($stepData['function'])->setName('Last called function')->setNormal($stepData['function'])->setType('string ' . strlen($stepData['function']));
         $output .= $this->storage->render->renderSingleChild($functionModel);
     }
     // Object.
     if (isset($stepData['object'])) {
         $objectModel = new Model($this->storage);
         $objectModel->setData($stepData['object'])->setName('Calling object');
         $output .= $this->storage->routing->analyseObject($objectModel);
     }
     // Type.
     if (isset($stepData['type'])) {
         $typeModel = new Model($this->storage);
         $typeModel->setData($stepData['type'])->setName('Call type')->setNormal($stepData['type'])->setType('string ' . strlen($stepData['type']));
         $output .= $this->storage->render->renderSingleChild($typeModel);
     }
     // Args.
     if (isset($stepData['args'])) {
         $argsModel = new Model($this->storage);
         $argsModel->setData($stepData['args'])->setName('Arguments from the call');
         $output .= $this->storage->routing->analyseArray($argsModel);
     }
     return $output;
 }