/**
  * Will return a definition of an attribute as far as we can extract it from the token array
  *
  * @param array $tokens            Array of tokens for this class
  * @param int   $attributePosition Position of the attribute within the token array
  *
  * @return AttributeDefinition
  */
 public function getAttributeProperties(array $tokens, $attributePosition)
 {
     // We got the tokens and the position of the attribute, so look in front of it for visibility and a
     // possible static keyword
     $attribute = new AttributeDefinition();
     $attribute->setName($tokens[$attributePosition][1]);
     $attribute->setLine($tokens[$attributePosition][2]);
     $attribute->setStructureName($this->currentDefinition->getQualifiedName());
     for ($i = $attributePosition; $i > $attributePosition - 6; $i--) {
         // Search for the visibility
         if (is_array($tokens[$i]) && ($tokens[$i][0] === T_PRIVATE || $tokens[$i][0] === T_PROTECTED)) {
             // Got it!
             $attribute->setVisibility($tokens[$i][1]);
         }
         // Do we get a static keyword?
         if (is_array($tokens[$i]) && $tokens[$i][0] === T_STATIC) {
             // default is false, so set it to true
             $attribute->setIsStatic(true);
         }
     }
     // Now check if there is any default value for this attribute, if so we have to get it
     $defaultValue = null;
     for ($i = $attributePosition; $i < count($tokens); $i++) {
         // If we reach the semicolon we do not have anything here.
         if ($tokens[$i] === ';') {
             break;
         }
         if ($defaultValue !== null) {
             // Do we get a static keyword?
             if (is_array($tokens[$i])) {
                 $defaultValue .= $tokens[$i][1];
             } else {
                 $defaultValue .= $tokens[$i];
             }
         }
         // If we pass a = we have to get ready to make notes
         if ($tokens[$i] === '=') {
             $defaultValue = '';
         }
     }
     // Set the default Value
     $attribute->setDefaultValue($defaultValue);
     // Last but not least we have to check if got the visibility, if not, set it public.
     // This is necessary, as missing visibility in the definition will also default to public
     if ($attribute->getVisibility() === '') {
         $attribute->setVisibility('public');
     }
     return $attribute;
 }
 /**
  * Used to "straighten out" an expression as some expressions allow for shell regex which makes them hard to
  * generate code from.
  * So with this method a matching pointcut can be altered into having a directly readable expression
  *
  * @param FunctionDefinition|AttributeDefinition $definition Definition to straighten the expression against
  *
  * @return null
  */
 public function straightenExpression($definition)
 {
     // structure name has to be absolute
     $structureName = '\\' . ltrim($definition->getStructureName(), '\\');
     // fix the expression
     $this->expression = str_replace(array($this->callType . $this->function, $this->structure), array($this->callType . $definition->getName(), $structureName), $this->getExpression());
     // set the obvious properties
     $this->function = $definition->getName();
     $this->structure = $structureName;
 }