<commit_before><?php
/**
 * File for WsdlToPhpModel class
 * @package WsdlToPhpGenerator
 * @date 19/12/2012
 */
/**
 * Class WsdlToPhpModel defines the basic properties and methods to operations and structs extracted from the WSDL
 * @package WsdlToPhpGenerator
 * @date 19/12/2012
 */
class WsdlToPhpModel
{
    /**
     * Constant used to define the key to store documentation value in meta
     * @var string
     */
    const META_DOCUMENTATION = 'documentation';
    /**
     * Constant used to define the key to store from schema value in meta
     * @var string
     */
    const META_FROM_SCHEMA = 'from schema';
    /**
     * Original name od the element
     * @var string
     */
    private $name = '';
    /**
     * Values associated to the operation
     * @var array
     */
    private $meta = array();
    /**
     * Define the inheritance of a struct by the name of the parent struct or type
     * @var string
     */
    private $inheritance = '';
    /**
     * Store the object which owns the current model
     * @var WsdlToPhpModel
     */
    private $owner = null;
    /**
     * Store all the models generated
     * @var array
     */
    private static $models = array();
    /**
     * Reserved PHP keywords
     * Plus {PackageName}WsdlClass specific/common methods
     * @var string
     */
    private static $phpReserverKeywords = '__construct|__destruct|__call|__callStatic|__get|__set|__isset|__unset|__sleep|__wakeup|__toString|__invoke|__set_state|__clone|getSoapClient|setSoapClient|initSoapClient|setLocation|getDefaultWsdlOptions|getLastRequest|getLastResponse|getFormatedXml|add|getResult|length|count|current|item|offsetGet|offsetSet|key|last|first|next|offsetExists|offsetUnset|rewind|setResult|toSend|valueIsValid|valid|getLastError|setLastError|saveLastError|getLastErrorForMethod|getInternArrayToIterate|setInternArrayToIterate|getInternArrayToIterateOffset|initInternArrayToIterate|setInternArrayToIterateOffset|getInternArrayToIterateIsArray|setInternArrayToIterateIsArray|getAttributeName|__toString|_set|_get|__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor';
    /**
     * Replaced keywords time in order to generate unique new keyword
     * @var array
     */
    private static $replacedReservedPhpKeywords = array();
    /**
     * Unique name generated in order to ensure unique naming (for struct constructor and setters/getters even for different case attribute name whith same value)
     * @var array
     */
    private static $uniqueNames = array();
    /**
     * Main constructor
     * @uses WsdlToPhpModel::setName()
     * @uses WsdlToPhpModel::updateModels()
     * @param string $_name the original name
     * @return WsdlToPhpModel
     */
    public function __construct($_name)
    {
        $this->setName($_name);
        self::updateModels($this);
    }
    /**
     * Returns comments for the element
     * @return array
     */
    public function getComment()
    {
        return array();
    }
    /**
     * Returns the comments for the file
     * @uses WsdlToPhpModel::getPackagedName()
     * @uses WsdlToPhpGenerator::getOptionAddComments()
     * @uses WsdlToPhpModel::getDocSubPackages()
     * @uses WsdlToPhpGenerator::getPackageName()
     * @return array
     */
    private function getFileComment()
    {
        $comments = array();
        array_push($comments,'File for class ' . $this->getPackagedName());
        array_push($comments,'@package ' . WsdlToPhpGenerator::getPackageName());
        if(count($this->getDocSubPackages()))
            array_push($comments,'@subpackage ' . implode(',',$this->getDocSubPackages()));
        if(count(WsdlToPhpGenerator::getOptionAddComments()))
        {
            foreach(WsdlToPhpGenerator::getOptionAddComments() as $tagName=>$tagValue)
                array_push($comments,"@$tagName $tagValue");
        }
        return $comments;
    }
    /**
     * Returns the comments for the class
     * @uses WsdlToPhpModel::getPackagedName()
     * @uses WsdlToPhpGenerator::getOptionAddComments()
     * @uses WsdlToPhpModel::getDocumentation()
     * @uses WsdlToPhpModel::addMetaComment()
     * @uses WsdlToPhpModel::getDocSubPackages()
     * @uses WsdlToPhpStruct::getIsStruct()
     * @uses WsdlToPhpGenerator::getPackageName()
     * @return array
     */
    private function getClassComment()
    {
        $comments = array();
        array_push($comments,'This class stands for ' . $this->getPackagedName() . ' originally named ' . $this->getName());
        if($this->getDocumentation() != '')
            array_push($comments,'Documentation : ' . $this->getDocumentation());
        $this->addMetaComment($comments,false,true);
        if($this->getInheritance() != '')
        {
            $inheritedModel = self::getModelByName($this->getInheritance());
            /**
             * A virtual struct exists only to store meta informations about itself
             * So don't add meta informations about a valid struct
             */
            if($inheritedModel && !$inheritedModel->getIsStruct())
                $inheritedModel->addMetaComment($comments,false,false);
        }
        array_push($comments,'@package ' . WsdlToPhpGenerator::getPackageName());
        if(count($this->getDocSubPackages()))
            array_push($comments,'@subpackage ' . implode(',',$this->getDocSubPackages()));
        if(count(WsdlToPhpGenerator::getOptionAddComments()))
        {
            foreach(WsdlToPhpGenerator::getOptionAddComments() as $tagName=>$tagValue)
                array_push($comments,"@$tagName $tagValue");
        }
        return $comments;
    }
    /**
     * Method to override in sub class
     * Must return a string in order to declare the function, attribute or the value
     * @uses WsdlToPhpStruct::getIsStruct()
     * @uses WsdlToPhpModel::getModelByName()
     * @uses WsdlToPhpModel::getInheritance()
     * @uses WsdlToPhpModel::getComment()
     * @uses WsdlToPhpModel::getPackagedName()
     * @uses WsdlToPhpModel::getClassBody()
     * @uses WsdlToPhpModel::getGenericWsdlClassName()
     * @uses WsdlToPhpGenerator::getOptionInheritsClassIdentifier()
     * @uses WsdlToPhpGenerator::getOptionGenerateWsdlClassFile()
     * @return string
     */
    public function getClassDeclaration()
    {
        $class = array();
        /**
         * Class comments
         */
        array_push($class,array(
                                'comment'=>$this->getFileComment()));
        array_push($class,array(
                                'comment'=>$this->getClassComment()));
        /**
         * Extends
         */
        $extends = '';
        $base = WsdlToPhpGenerator::getOptionInheritsClassIdentifier();
        if(!empty($base) && ($model = self::getModelByName($this->getName() . $base)))
        {
            if($model->getIsStruct())
                $extends = $model->getPackagedName();
        }
        elseif($this->getInheritance() != '' && ($model = self::getModelByName($this->getInheritance())))
        {
            if($model->getIsStruct())
                $extends = $model->getPackagedName();
        }
        elseif(class_exists($this->getInheritance()))
            $extends = $this->getInheritance();
        if(empty($extends) && WsdlToPhpGenerator::getOptionGenerateWsdlClassFile())
            $extends = self::getGenericWsdlClassName();
        array_push($class,'class ' . $this->getPackagedName() . (!empty($extends)?' extends ' . $extends:''));
        /**
         * Class body starts here
         */
        array_push($class,'{');
        /**<commit_msg>[UPDATE] improvement for generated classes<commit_after><?php
/**
 * File for WsdlToPhpModel class
 * @package WsdlToPhpGenerator
 * @date 19/12/2012
 */
/**
 * Class WsdlToPhpModel defines the basic properties and methods to operations and structs extracted from the WSDL
 * @package WsdlToPhpGenerator
 * @date 19/12/2012
 */
class WsdlToPhpModel
{
    /**
     * Constant used to define the key to store documentation value in meta
     * @var string
     */
    const META_DOCUMENTATION = 'documentation';
    /**
     * Constant used to define the key to store from schema value in meta
     * @var string
     */
    const META_FROM_SCHEMA = 'from schema';
    /**
     * Original name od the element
     * @var string
     */
    private $name = '';
    /**
     * Values associated to the operation
     * @var array
     */
    private $meta = array();
    /**
     * Define the inheritance of a struct by the name of the parent struct or type
     * @var string
     */
    private $inheritance = '';
    /**
     * Store the object which owns the current model
     * @var WsdlToPhpModel
     */
    private $owner = null;
    /**
     * Store all the models generated
     * @var array
     */
    private static $models = array();
    /**
     * Reserved PHP keywords
     * Plus {PackageName}WsdlClass specific/common methods
     * @var string
     */
    private static $phpReserverKeywords = '__construct|__destruct|__call|__callStatic|__get|__set|__isset|__unset|__sleep|__wakeup|__toString|__invoke|__set_state|__clone|getSoapClient|setSoapClient|initSoapClient|setLocation|getDefaultWsdlOptions|getLastRequest|getLastResponse|getFormatedXml|add|getResult|length|count|current|item|offsetGet|offsetSet|key|last|first|next|offsetExists|offsetUnset|rewind|setResult|toSend|valueIsValid|valid|getLastError|setLastError|saveLastError|getLastErrorForMethod|getInternArrayToIterate|setInternArrayToIterate|getInternArrayToIterateOffset|initInternArrayToIterate|setInternArrayToIterateOffset|getInternArrayToIterateIsArray|setInternArrayToIterateIsArray|getAttributeName|__toString|_set|_get|__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor';
    /**
     * Replaced keywords time in order to generate unique new keyword
     * @var array
     */
    private static $replacedReservedPhpKeywords = array();
    /**
     * Unique name generated in order to ensure unique naming (for struct constructor and setters/getters even for different case attribute name whith same value)
     * @var array
     */
    private static $uniqueNames = array();
    /**
     * Main constructor
     * @uses WsdlToPhpModel::setName()
     * @uses WsdlToPhpModel::updateModels()
     * @param string $_name the original name
     * @return WsdlToPhpModel
     */
    public function __construct($_name)
    {
        $this->setName($_name);
        self::updateModels($this);
    }
    /**
     * Returns comments for the element
     * @return array
     */
    public function getComment()
    {
        return array();
    }
    /**
     * Returns the comments for the file
     * @uses WsdlToPhpModel::getPackagedName()
     * @uses WsdlToPhpGenerator::getOptionAddComments()
     * @uses WsdlToPhpModel::getDocSubPackages()
     * @uses WsdlToPhpGenerator::getPackageName()
     * @return array
     */
    private function getFileComment()
    {
        $comments = array();
        array_push($comments,'File for class ' . $this->getPackagedName());
        array_push($comments,'@package ' . WsdlToPhpGenerator::getPackageName());
        if(count($this->getDocSubPackages()))
            array_push($comments,'@subpackage ' . implode(',',$this->getDocSubPackages()));
        if(count(WsdlToPhpGenerator::getOptionAddComments()))
        {
            foreach(WsdlToPhpGenerator::getOptionAddComments() as $tagName=>$tagValue)
                array_push($comments,"@$tagName $tagValue");
        }
        return $comments;
    }
    /**
     * Returns the comments for the class
     * @uses WsdlToPhpModel::getPackagedName()
     * @uses WsdlToPhpGenerator::getOptionAddComments()
     * @uses WsdlToPhpModel::getDocumentation()
     * @uses WsdlToPhpModel::addMetaComment()
     * @uses WsdlToPhpModel::getDocSubPackages()
     * @uses WsdlToPhpStruct::getIsStruct()
     * @uses WsdlToPhpGenerator::getPackageName()
     * @return array
     */
    private function getClassComment()
    {
        $comments = array();
        array_push($comments,'This class stands for ' . $this->getPackagedName() . ' originally named ' . $this->getName());
        if($this->getDocumentation() != '')
            array_push($comments,'Documentation : ' . $this->getDocumentation());
        $this->addMetaComment($comments,false,true);
        if($this->getInheritance() != '')
        {
            $inheritedModel = self::getModelByName($this->getInheritance());
            /**
             * A virtual struct exists only to store meta informations about itself
             * So don't add meta informations about a valid struct
             */
            if($inheritedModel && !$inheritedModel->getIsStruct())
                $inheritedModel->addMetaComment($comments,false,false);
        }
        array_push($comments,'@package ' . WsdlToPhpGenerator::getPackageName());
        if(count($this->getDocSubPackages()))
            array_push($comments,'@subpackage ' . implode(',',$this->getDocSubPackages()));
        if(count(WsdlToPhpGenerator::getOptionAddComments()))
        {
            foreach(WsdlToPhpGenerator::getOptionAddComments() as $tagName=>$tagValue)
                array_push($comments,"@$tagName $tagValue");
        }
        return $comments;
    }
    /**
     * Method to override in sub class
     * Must return a string in order to declare the function, attribute or the value
     * @uses WsdlToPhpStruct::getIsStruct()
     * @uses WsdlToPhpModel::getModelByName()
     * @uses WsdlToPhpModel::getInheritance()
     * @uses WsdlToPhpModel::getComment()
     * @uses WsdlToPhpModel::getPackagedName()
     * @uses WsdlToPhpModel::getClassBody()
     * @uses WsdlToPhpModel::getGenericWsdlClassName()
     * @uses WsdlToPhpGenerator::getOptionInheritsClassIdentifier()
     * @uses WsdlToPhpGenerator::getOptionGenerateWsdlClassFile()
     * @return string
     */
    public function getClassDeclaration()
    {
        $class = array();
        /**
         * Class comments
         */
        array_push($class,array(
                                'comment'=>$this->getFileComment()));
        array_push($class,array(
                                'comment'=>$this->getClassComment()));
        /**
         * Extends
         */
        $extends = '';
        $base = WsdlToPhpGenerator::getOptionInheritsClassIdentifier();
        if(!empty($base) && ($model = self::getModelByName($this->getName() . $base)))
        {
            if($model->getIsStruct())
                $extends = $model->getPackagedName();
        }
        elseif($this->getInheritance() != '' && ($model = self::getModelByName($this->getInheritance())))
        {
            if($model->getIsStruct())
                $extends = $model->getPackagedName();
        }
        elseif(class_exists($this->getInheritance()) && stripos($this->getInheritance(),WsdlToPhpGenerator::getPackageName()) === 0)
            $extends = $this->getInheritance();
        if(empty($extends) && WsdlToPhpGenerator::getOptionGenerateWsdlClassFile())
            $extends = self::getGenericWsdlClassName();
        array_push($class,'class ' . $this->getPackagedName() . (!empty($extends)?' extends ' . $extends:''));
        /**
         * Class body starts here
         */
        array_push($class,'{');
        /**
{'fraction_non_alphanumeric': 0.12517048977061376, 'fraction_numerical': 0.002045877247365158, 'mean_word_length': 3.1574742268041236, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2083666', 'n_tokens_mistral': 4791, 'n_tokens_neox': 4624, 'n_words': 844}