A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

aaa - Stikked
From dardo, 11 Years ago, written in PHP.
Embed
  1. <?php
  2.  
  3. /**
  4.  * Project:     PHP WSDL generator
  5.  * File:        PHPParser.php
  6.  * Purpose              Parse PHP files to get an array of the classes with details
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Lesser General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2.1 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Lesser General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Lesser General Public
  19.  * License along with this library; if not, write to the Free Software
  20.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  *
  22.  * For questions, help, comments, discussion, etc., please send
  23.  * e-mail to dragos@protung.ro
  24.  *
  25.  * @link http://www.protung.ro/
  26.  * @copyright 2009 Dragos Protung
  27.  * @author Dragos Protung <dragos@protung.ro>
  28.  * @package PHP WSDL generator
  29.  * @version 1.2.2
  30.  */
  31.  
  32. class PHPParser {
  33.        
  34.        
  35.         /**
  36.          * Array with all the files to be parsed
  37.          *
  38.          * @var array
  39.          */
  40.         private $files = array();
  41.        
  42.         /**
  43.          * Classes to be ignored on parsing
  44.          *
  45.          * @var array
  46.          */
  47.         private $ignoredClasses = array();
  48.        
  49.         /**
  50.          * Methods to be ignored on parsing
  51.          *
  52.          * @var array
  53.          */
  54.         private $ignoredMethods = array();
  55.        
  56.         /**
  57.          * Auto ignore all public methods
  58.          *
  59.          * @var boolean
  60.          */
  61.         private $ignorePublic = false;
  62.        
  63.         /**
  64.          * Auto ignore all protected methods
  65.          *
  66.          * @var boolean
  67.          */
  68.         private $ignoreProtected = true;
  69.         /**
  70.          * Auto ignore all private methods
  71.          *
  72.          * @var boolean
  73.          */
  74.         private $ignorePrivate = true;
  75.        
  76.         /**
  77.          * Auto ignore all static methods
  78.          *
  79.          * @var boolean
  80.          */
  81.         private $ignoreStatic = false;
  82.        
  83.         /**
  84.          * Array holding all the classes
  85.          *
  86.          * @var array
  87.          */
  88.         private $classes = array();
  89.        
  90.         /**
  91.          * Array holding found classes but with errors (only classes withoutmethods for now)
  92.          *
  93.          * @var array
  94.          */
  95.         private $foundClasses = array();
  96.        
  97.         /**
  98.          * Array holding all the classes variables
  99.          *
  100.          * @var array
  101.          */
  102.         private $classesVars = array();
  103.        
  104.         /**
  105.          * Array holding all the data
  106.          *
  107.          * @var array
  108.          */
  109.         private $allData = array();
  110.        
  111.         /**
  112.          * Current class that is parsed
  113.          *
  114.          * @var string
  115.          */
  116.         private $currentClass;
  117.        
  118.         /**
  119.          * The latest comment found for a method
  120.          *
  121.          * @var string
  122.          */
  123.         private $currentMethodComment;
  124.        
  125.         /**
  126.          * The latest type found for a method
  127.          *
  128.          * @var string
  129.          */
  130.         private $currentMethodType;
  131.         /**
  132.          * The latest method found for a class
  133.          *
  134.          * @var string
  135.          */
  136.         private $currentMethod;
  137.         /**
  138.          * Latest parameters found for a method
  139.          *
  140.          * @var array
  141.          */
  142.         private $currentParams = array();
  143.        
  144.         /**
  145.          * The variable that holds the XML
  146.          *
  147.          * @var XMLCreator
  148.          */
  149.         private $WSDL;
  150.        
  151.         /**
  152.          * Messages for the WSDL
  153.          *
  154.          * @var array
  155.          */
  156.         private $WSDLMessages = array();
  157.        
  158.         /**
  159.          * Bindings for the WSDL
  160.          *
  161.          * @var array
  162.          */
  163.         private $bindings = array();
  164.        
  165.         /**
  166.          * PortTypes for the WSDL
  167.          *
  168.          * @var array
  169.          */
  170.         private $portTypes = array();
  171.        
  172.         /**
  173.          * Services for the WSDL
  174.          *
  175.          * @var array
  176.          */
  177.         private $WSDLService = array();
  178.        
  179.         /**
  180.          * Constructor
  181.          *
  182.          */
  183.         public function __construct () {
  184.  
  185.         }
  186.        
  187.         /**
  188.          * Unignore all.
  189.          * All ignored items will be removed (including method types)
  190.          *
  191.          */
  192.         public function ignoreNone () {
  193.                 $this->ignoredClasses = array();
  194.                 $this->ignoredMethods = array();
  195.                 $this->ignorePrivate = array();
  196.                 $this->ignoreProtected = array();
  197.                 $this->ignorePublic = array();
  198.                 $this->ignoreStatic = array();
  199.         }
  200.        
  201.         /**
  202.          * Ignore or not all public methods
  203.          *
  204.          * @param boolean $ignore
  205.          */
  206.         public function ignorePublic ($ignore = false) {
  207.                 if ($ignore === true) {
  208.                         $this->ignorePublic = true;
  209.                 } elseif ($ignore === false) {
  210.                         $this->ignorePublic = false;
  211.                 }
  212.         }
  213.        
  214.         /**
  215.          * Ignore or not all protected methods
  216.          *
  217.          * @param boolean $ignore
  218.          */
  219.         public function ignoreProtected ($ignore = false) {
  220.                 if ($ignore === true) {
  221.                         $this->ignoreProtected = true;
  222.                 } elseif ($ignore === false) {
  223.                         $this->ignoreProtected = false;
  224.                 }
  225.         }
  226.        
  227.         /**
  228.          * Ignore or not all private methods
  229.          *
  230.          * @param boolean $ignore
  231.          */
  232.         public function ignorePrivate ($ignore = false) {
  233.                 if ($ignore === true) {
  234.                         $this->ignorePrivate = true;
  235.                 } elseif ($ignore === false) {
  236.                         $this->ignorePrivate = false;
  237.                 }
  238.         }
  239.        
  240.         /**
  241.          * Ignore or not all static methods
  242.          *
  243.          * @param boolean $ignore
  244.          */
  245.         public function ignoreStatic ($ignore = false) {
  246.                 if ($ignore === true) {
  247.                         $this->ignoreStatic = true;
  248.                 } elseif ($ignore === false) {
  249.                         $this->ignoreStatic = false;
  250.                 }
  251.         }
  252.        
  253.         /**
  254.          * Add a class name to ignore on parsing
  255.          *
  256.          * @param string $class
  257.          */
  258.         public function ignoreClass ($class) {
  259.                 $this->ignoredClasses[] = $class;
  260.         }
  261.        
  262.         /**
  263.          * Add classes to ignor on parsing
  264.          *
  265.          * @param array $classes
  266.          */
  267.         public function ignoreClasses ($classes) {
  268.                 if (is_array($classes)) {
  269.                         foreach ($classes as $class) {
  270.                                 $this->ignoreClass($class);
  271.                         }
  272.                 }
  273.         }
  274.        
  275.         /**
  276.          * Add a method of a class to ignore on parsing
  277.          *
  278.          * @param array $method
  279.          */
  280.         public function ignoreMethod ($method) {
  281.                 if (is_array($method)) {
  282.                         $this->ignoredMethods[key($method)][] = $method[key($method)];
  283.                 }
  284.         }
  285.        
  286.         /**
  287.          * Add methods of classes to ignore on parsing
  288.          *
  289.          * @param array $methods
  290.          */
  291.         public function ignoreMethods ($methods) {
  292.                 if (is_array($methods)) {
  293.                         foreach ($methods as $class=>$method) {
  294.                                 if ($class != "" && $method != "")
  295.                                         $this->ignoredMethods[$class][] = $method;
  296.                         }
  297.                 }
  298.         }
  299.        
  300.         /**
  301.          * Add a file to parse
  302.          *
  303.          * @param string $file
  304.          */
  305.         public function addFile ($file) {
  306.                 if (file_exists($file)) {
  307.                         $this->files[] = $file;
  308.                 } else {
  309.                         trigger_error("File <b>".$file."</b> does not exist !!", E_USER_ERROR);
  310.                 }
  311.         }
  312.        
  313.         /**
  314.          * Return the next token resulted alfter token_get_all()
  315.          *
  316.          * @return array
  317.          */
  318.         private function getNextToken () {
  319.                 if (is_array($this->allData)) {
  320.                         while (($c = next($this->allData))) {
  321.                                 if (!is_array($c) || $c[0] == T_WHITESPACE) { // 370
  322.                                         continue;
  323.                                 }
  324.                                 break;
  325.                         }
  326.                         return current($this->allData);
  327.                 }
  328.                 return false;
  329.         }
  330.        
  331.         /**
  332.          * Return the previous token exept white space
  333.          *
  334.          * @return array
  335.          */
  336.         private function getPrevToken () {
  337.                 if (is_array($this->allData)) {
  338.                         while (($c = prev($this->allData))) {
  339.                                 if (!is_array($c) || $c[0] == T_WHITESPACE) { // 370
  340.                                         continue;
  341.                                 }
  342.                                 break;
  343.                         }
  344.                         return current($this->allData);
  345.                 }
  346.                 return false;
  347.         }
  348.        
  349.         /**
  350.          * Get next token with a type
  351.          *
  352.          * @param integer $type
  353.          * @return array
  354.          */
  355.         private function getNextTokenWithType ($type) {
  356.                 while (($current = $this->getNextToken())) {
  357.                         if($current[0] == $type) {
  358.                                 return current($this->allData);
  359.                         }
  360.                 }
  361.                 return array();
  362.         }
  363.        
  364.         /**
  365.          * Parse a file
  366.          * It gets the data from $this->all_data
  367.          *
  368.          */
  369.         private function parseFile () {
  370.                 $lookForClassVariables = true; // When this will be set as false we will not look for class variables because a function was defined
  371.                 while (($token = $this->getNextToken())) {
  372. //                      print_r($this->allData);exit;
  373.                        
  374.                         if ($token[0] == T_CLASS) { // T_CLASS
  375.                                 $className = $this->getNextTokenWithType(T_STRING);
  376.                                 $this->currentClass = $className[1];
  377.                                 $this->currentMethodComment = $this->currentMethodType = $this->currentMethod = $this->currentParams = null;
  378.                                 continue;
  379.                         }
  380.  
  381.                         if ($lookForClassVariables === true && $token[0] == T_VARIABLE && $this->currentClass != null) {
  382.                                 $varName = substr($token[1], 1);
  383.                                 $this->classesVars[$this->currentClass][$varName] = "";
  384.                                 continue;
  385.                         }
  386.                        
  387.                         if ($token[0] == T_DOC_COMMENT) { // T_DOC_COMMENT
  388.                                 $nt = $this->getNextToken();
  389.                                
  390.                                 if ($nt[0] == T_FUNCTION || $nt[0] == T_STATIC || $nt[0] == T_ABSTRACT || $nt[0] == T_FINAL ||
  391.                                         $nt[0] == T_PRIVATE || $nt[0] == T_PROTECTED || $nt[0] == T_PUBLIC) { // public | protected | private | final | abstract | static | function
  392.                                        
  393.                                         $nnt = $this->getNextToken();
  394.                                         if ($nnt[0] == T_VARIABLE) {
  395.                                                 $varName = substr($nnt[1], 1);
  396.                                                 $this->getPrevToken();
  397.                                                 $varType = $this->getPrevToken();
  398.                                                 if ($varType[0] == T_DOC_COMMENT) {
  399.                                                         $varType = $this->parseComment($varType[1]);
  400.                                                         $varType = $varType['params']['type'];
  401.                                                         $this->classesVars[$this->currentClass][$varName] = $varType;
  402.                                                 }
  403.                                                 continue;
  404.                                         } else {
  405.                                                 $this->getPrevToken();
  406.                                         }
  407.                                         $this->currentMethodComment = $token[1];
  408.                                         $this->currentMethod = null;
  409.                                         $this->currentParams = null;
  410.                                         $this->getPrevToken();
  411.                                         continue;
  412.                                 }
  413.                         }
  414.                        
  415.                         if (isset($nt) && ($nt[0] == T_STATIC || $nt[0] == T_ABSTRACT || $nt[0] == T_FINAL ||
  416.                                 $nt[0] == T_PRIVATE || $nt[0] == T_PROTECTED || $nt[0] == T_PUBLIC)) { // public | protected | private | final | abstract | static
  417.                                 $this->currentMethodType = $token[1] ? $token[1] : "public";
  418.                                 $this->currentMethod = $this->currentParams = null;
  419.                                 $token = $this->getNextToken();
  420.                         } else {
  421.                                 $this->currentMethodType = "public";
  422.                         }
  423.                        
  424.                         if ($token[0] == T_FUNCTION) { // T_FUNCTION
  425.                                 $lookForClassVariables = false;
  426.                                 $f = $this->getNextTokenWithType(T_STRING);
  427.                                 $this->currentMethod = $f[1];
  428.                                 $this->currentParams = null;
  429.                                 if (next($this->allData) == "(") {
  430.                                         while (($p = next($this->allData)) != ")") {
  431.                                                 if ($p[0] == T_VARIABLE) { // T_VARIABLE
  432.                                                         $this->currentParams[] = $p[1];
  433.                                                 }
  434.                                         }
  435.                                 }
  436.                         }
  437.                        
  438.                         if (!isset($this->classes[$this->currentClass])) {
  439.                                 $this->foundClasses[$this->currentClass] = $this->currentClass;
  440.                         }
  441.                        
  442.                         if ($this->currentClass && $this->currentMethod) {
  443.                                 $this->classes[$this->currentClass][$this->currentMethod]["comment"] = $this->currentMethodComment;
  444.                                 if ($this->currentMethod == null) $this->currentMethod = "public";
  445.                                 $this->classes[$this->currentClass][$this->currentMethod]["type"] = $this->currentMethodType;
  446.                                 $this->classes[$this->currentClass][$this->currentMethod]["params"] = $this->currentParams;
  447.                                 $this->currentMethodComment = $this->currentMethodType = $this->currentMethod = $this->currentParams = null;
  448.                         }
  449.                 }
  450.         }
  451.        
  452.         /**
  453.          * Filter classes
  454.          * Extracts all the ignored classes and methods and methods types
  455.          *
  456.          */
  457.         private function filterClasses () {
  458.                 foreach ($this->classes as $class=>$methods) {
  459.                         if (in_array($class, $this->ignoredClasses)) {
  460.                                 unset($this->classes[$class]);
  461.                                 continue;
  462.                         }
  463.                        
  464.                         foreach ($methods as $method=>$attrs) {
  465.                                        
  466.                                 if (($attrs["type"] == "public" && $this->ignorePublic === true) ||
  467.                                         ($attrs["type"] == "protected" && $this->ignoreProtected === true) ||
  468.                                         ($attrs["type"] == "private" && $this->ignorePrivate === true) ||
  469.                                         ($attrs["type"] == "static" && $this->ignoreStatic === true))
  470.                                 {
  471.                                         unset($this->classes[$class][$method]);
  472.                                 }
  473.                                
  474.                                 if (isset($this->ignoredMethods[$class]) && is_array($this->ignoredMethods[$class])) {
  475.                                         if (in_array($method, $this->ignoredMethods[$class])) {
  476.                                                 unset($this->classes[$class][$method]);
  477.                                         }
  478.                                 }
  479.                         }
  480.  
  481.                 }
  482.         }
  483.        
  484.         /**
  485.          * Parse a comment
  486.          * Extracts description, parameters type and return type
  487.          *
  488.          * @param string $comment
  489.          * @return array
  490.          */
  491.         private function parseComment ($comment) {
  492.                 $comment = trim($comment);
  493.                 if ($comment == "") return "";
  494.                
  495.                 if (strpos($comment, "/*") === 0 && strripos($comment, "*/") === strlen($comment)-2) {
  496.                         $lines = preg_split("(\\n\\r|\\r\\n\\|\\r|\\n)", $comment);
  497.                         $description = "";
  498.                         $returntype = "";
  499.                         $params = array();
  500.                         while (next($lines)) {
  501.                                 $line = trim(current($lines));
  502.                                 $line = trim(substr($line, strpos($line, "* ")+2));
  503.                                 if (isset($line[0]) && $line[0] == "@") {
  504.                                         $parts = explode(" ", $line);
  505.                                         if ($parts[0] == "@return") {
  506.                                                 $returntype = $parts[1];
  507.                                         } elseif ($parts[0] == "@param") {
  508.                                                 $params[$parts[2]] = $parts[1];
  509.                                         } elseif ($parts[0] == "@var") {
  510.                                                 $params['type'] = $parts[1];
  511.                                         }
  512.                                 } else {
  513.                                         $description .= "\n".trim($line);
  514.                                 }
  515.                         }
  516.                        
  517.                         $comment = array("description"=>$description, "params"=>$params, "return"=>$returntype);
  518.                         return $comment;
  519.                 } else {
  520.                         return "";
  521.                 }
  522.                
  523.         }
  524.        
  525.         /**
  526.          * Parse the classes
  527.          *
  528.          */
  529.         private function parseClasses () {
  530.                 $classes = $this->classes;
  531.                 $this->classes = array();
  532.                 foreach ($classes as $class=>$methods) {
  533.                         foreach ($methods as $method=>$attributes) {
  534.                                 $this->classes[$class][$method]["type"] = $attributes["type"];
  535.                                 $commentParsed = $this->parseComment($attributes["comment"]);
  536.                                 $this->classes[$class][$method]["returnType"] = !isset($commentParsed["return"]) ? false : $commentParsed["return"];
  537.                                 $this->classes[$class][$method]["description"] = isset($commentParsed["description"]) ? $commentParsed["description"] : "";
  538.                                 if (is_array($attributes["params"])) {
  539.                                         foreach ($attributes["params"] as $param) {
  540.                                                 $paramName = substr($param, 1);
  541.                                                 $this->classes[$class][$method]["params"][$paramName]["varName"] = $param;
  542.                                                 if (isset($commentParsed["params"][$param]))
  543.                                                         $this->classes[$class][$method]["params"][$paramName]["varType"] = $commentParsed["params"][$param];
  544.                                         }
  545.                                 }
  546.                         }
  547.                 }
  548.         }
  549.        
  550.         /**
  551.          * Get all the parsed classes from the files (filtered)
  552.          *
  553.          * @return array
  554.          */
  555.         public function getClasses () {
  556.                 foreach ($this->files as $file) {
  557.                         $this->allData = token_get_all(file_get_contents($file));
  558.                         $this->parseFile(file_get_contents($file));
  559.                 }
  560.                 $this->filterClasses();
  561.                 $this->parseClasses();
  562.                 return $this->classes;
  563.         }
  564.        
  565.         /**
  566.          * Get all found classes (after parsing)
  567.          *
  568.          * @return array
  569.          */
  570.         public function getFoundClasses () {
  571.                 return $this->foundClasses;
  572.         }
  573.        
  574.         /**
  575.          * Get all the variables of the classes defined in the files
  576.          *
  577.          * @return array
  578.          */
  579.         public function getClassesVars () {
  580.                 return $this->classesVars;
  581.         }
  582.  
  583. }
  584.  
  585. ?>