idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
50,100
public function distance ( $ text1 , $ text2 ) { return max ( strlen ( $ text1 ) , strlen ( $ text2 ) ) - $ this -> similarity ( $ text1 , $ text2 ) ; }
Returns the distance max string length minus similarity
50,101
protected function exec ( ) { $ descriptors = [ 0 => [ "pipe" , "r" ] , 1 => [ "pipe" , "w" ] , 2 => [ "pipe" , "w" ] ] ; $ process = proc_open ( $ this -> getCommand ( ) , $ descriptors , $ pipes , dirname ( $ this -> getJarPath ( ) ) , [ ] ) ; if ( is_resource ( $ process ) ) { fclose ( $ pipes [ 0 ] ) ; $ this -> ou...
Calls the stanford jar file
50,102
public function isVowel ( $ word , $ index ) { if ( strpbrk ( $ word [ $ index ] , 'aeiou' ) !== false ) { return true ; } elseif ( $ word [ $ index ] === 'y' && strpbrk ( $ word [ -- $ index ] , 'aeiou' ) === false ) { return true ; } return false ; }
Returns true if the letter at the given index is a vowel works with y
50,103
public function similarity ( $ text1 , $ text2 ) { if ( is_string ( $ text1 ) && is_string ( $ text2 ) ) { $ text1 = str_split ( $ text1 ) ; $ text2 = str_split ( $ text2 ) ; } $ inter = array_intersect ( $ text1 , $ text2 ) ; $ union = array_unique ( ( $ text1 + $ text2 ) ) ; return count ( $ inter ) / count ( $ union...
Returns the Jaccard Index
50,104
public function stem ( $ token ) { if ( in_array ( $ token , $ this -> whiteList ) ) { return $ token ; } return $ this -> spell -> suggest ( $ this -> stemmer -> stem ( $ token ) ) [ 0 ] ; }
Stem and then look up the word
50,105
public function getKeyValuesByWeight ( ) { if ( empty ( $ this -> keysByWeight ) ) { $ weightPerToken = $ this -> getWeightPerToken ( ) ; $ keyValuesByWeight = $ this -> keyValues ; array_walk ( $ keyValuesByWeight , function ( & $ value , $ key , $ weightPerToken ) { $ value /= $ weightPerToken ; } , $ this -> totalTo...
Return an array with key weight pairs
50,106
public function verifyChecksum ( ) { if ( empty ( $ this -> getPackage ( ) -> getChecksum ( ) ) ) { return true ; } return $ this -> getPackage ( ) -> getChecksum ( ) === md5_file ( $ this -> getDownloadFullPath ( ) ) ; }
Verify the packages checksum against the downloaded file if the package has a checksum
50,107
public function unpackPackage ( ) { if ( $ this -> getPackage ( ) -> getUnzip ( ) ) { $ this -> extractZip ( $ this -> getDownloadFullPath ( ) , $ this -> getInstallDir ( ) ) ; } else { $ this -> recursiveCopy ( $ this -> getDownloadFullPath ( ) , $ this -> getInstallDir ( ) ) ; } }
de - compress the downloaded corpus into the install directory or copy the files into the install directory
50,108
protected function recursiveCopy ( $ src , $ dst ) { if ( $ this -> isZip ( $ src ) ) { $ this -> extractZip ( $ src , $ this -> getInstallDir ( ) ) ; return ; } $ dir = opendir ( $ src ) ; if ( ! is_dir ( $ dst ) ) { mkdir ( $ dst ) ; } while ( false !== ( $ file = readdir ( $ dir ) ) ) { if ( ( $ file != '.' ) && ( $...
Recursive copy the directory
50,109
protected function extractZip ( $ srcPath , $ extractToDir ) { $ zip = new ZipArchive ( ) ; $ r = $ zip -> open ( $ srcPath ) ; if ( $ r ) { $ zip -> extractTo ( $ extractToDir ) ; $ zip -> close ( ) ; } }
Use PHP s ZipArchive to extract out the data
50,110
public function initialize ( ) { if ( ! is_dir ( dirname ( $ this -> getDownloadFullPath ( ) ) ) ) { mkdir ( dirname ( $ this -> getDownloadFullPath ( ) ) , 0755 , true ) ; } if ( ! is_dir ( $ this -> getInstallDir ( ) ) ) { mkdir ( $ this -> getInstallDir ( ) , 0755 , true ) ; } }
Initialize the directories required for the download
50,111
public function getDownloadFullPath ( ) { return sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . 'pta-downloads' . DIRECTORY_SEPARATOR . $ this -> getPackage ( ) -> getSubdir ( ) . DIRECTORY_SEPARATOR . basename ( $ this -> getPackage ( ) -> getUrl ( ) ) ; }
Has the full path to where the download should go
50,112
public function getStopwords ( ) { if ( ! empty ( $ this -> stopWords ) ) { return $ this -> stopWords ; } foreach ( $ this -> getFilePaths ( ) as $ filePath ) { $ content = $ this -> getFileContent ( $ filePath ) ; $ doc = new TokensDocument ( ( new GeneralTokenizer ( ) ) -> tokenize ( $ content ) ) ; $ doc -> applyTr...
Returns an array of stop words and their frequencies
50,113
protected function computeUsingFreqDist ( array $ tokens ) { $ freqDist = ( new FreqDist ( $ tokens ) ) -> getKeyValuesByFrequency ( ) ; foreach ( $ freqDist as $ token => $ freqValue ) { if ( ! isset ( $ this -> stopWords [ $ token ] ) ) { $ this -> stopWords [ $ token ] = $ freqValue ; } else { $ this -> stopWords [ ...
Adds frequency counts to the stopWords property
50,114
public function getLemma ( $ word , $ pos = '' ) { if ( empty ( $ this -> lemmasIdx ) ) { foreach ( $ this -> getWordnetCorpus ( ) -> getLemmas ( ) as & $ lemma ) { $ this -> lemmasIdx [ "{$lemma->getWord()}.{$lemma->getPos()}" ] = $ lemma ; } ksort ( $ this -> lemmasIdx ) ; } $ found = [ ] ; if ( isset ( $ this -> lem...
Return the lemmas that are linked to the given word provide a pos to filter down the results
50,115
public function getMorph ( $ word , $ pos = '' ) { if ( mb_strlen ( $ word ) < 3 ) { return "" ; } $ searchForFuncWithPos = function ( ExceptionMap $ exceptionMap ) use ( $ word , $ pos ) { return $ exceptionMap -> getPos ( ) === $ pos && in_array ( $ word , $ exceptionMap -> getExceptionList ( ) ) ; } ; $ searchForFun...
Concept taken from nltk Find a possible base form for the given form with the given part of speech by checking WordNet s list of exceptional forms and by recursively stripping affixes for this part of speech until a form in WordNet is found .
50,116
public function getWords ( $ fileId = null , $ tokenizer = null ) { if ( ! $ tokenizer ) { $ tokenizer = new GeneralTokenizer ( ) ; } $ fileIds = [ ] ; if ( empty ( $ fileId ) ) { $ fileIds = $ this -> getFileIds ( ) ; } else { $ fileIds = [ $ fileId ] ; } $ words = [ ] ; foreach ( $ fileIds as $ filename ) { $ content...
Return an array of tokenized words
50,117
public function getRaw ( $ fileId = null ) { $ lamdaFunction = function ( $ text ) { return [ $ text ] ; } ; return $ this -> getWords ( $ fileId , new LambdaTokenizer ( $ lamdaFunction ) ) ; }
Each array element is the text of the selected file loaded file see getWords
50,118
public function getRegexes ( ) : array { return [ $ this -> getPhoneNumbers ( ) , $ this -> getUrls ( ) , $ this -> getEmoticons ( ) , $ this -> getHashTags ( ) , $ this -> getAsciiArrows ( ) , $ this -> getUsernames ( ) , $ this -> getHashTags ( ) , $ this -> getWordsWith ( ) , $ this -> getNumbers ( ) , $ this -> get...
Return an array of regexes ordered by priority
50,119
public function getPhrases ( ) { $ phrases = [ ] ; for ( $ index = $ this -> nGramSize ; $ index >= 2 ; $ index -- ) { $ phrases = array_merge ( $ phrases , NGramFactory :: create ( $ this -> getTokens ( ) , $ index ) ) ; } $ add = [ ] ; $ remove = [ ] ; foreach ( $ phrases as $ phrase ) { if ( isset ( $ remove [ $ phr...
Get all the possible phrases
50,120
public function stem ( $ token ) { if ( strlen ( $ token ) < $ this -> minimumTokenLength ) { return $ token ; } return preg_replace ( "/" . $ this -> regexExpression . "/i" , '' , $ token ) ; }
Return a stemmed word
50,121
public function addFunctionClass ( $ obj ) { $ ref = new \ ReflectionObject ( $ obj ) ; foreach ( $ ref -> getMethods ( ) as $ curMethod ) { if ( ! $ curMethod -> isPublic ( ) ) continue ; $ this -> addFunction ( $ curMethod -> getName ( ) , [ $ obj , $ curMethod -> getName ( ) ] ) ; } return $ this ; }
Register all public Functions from an Object
50,122
public function onPreAutoloadDump ( Event $ event ) { $ basePath = $ this -> getBasePath ( $ event ) ; $ lockPath = "{$basePath}/pre.lock" ; $ shouldOptimize = $ this -> shouldOptimize ( $ event ) ; if ( $ shouldOptimize ) { file_put_contents ( $ lockPath , time ( ) ) ; if ( ! file_exists ( "{$basePath}/vendor/autoload...
Preprocesses all files if the autoloader should be optimized .
50,123
private function getBasePath ( Event $ event ) { $ config = $ event -> getComposer ( ) -> getConfig ( ) ; return realpath ( $ config -> get ( "vendor-dir" ) . "/../" ) ; }
Finds the base application path .
50,124
public function setChildren ( $ children , $ mapper = null ) { $ element = clone $ this ; $ element -> children = new Collection ( ) ; return $ element -> addChildren ( $ children , $ mapper ) ; }
Replace all children with an array of elements .
50,125
public function convert ( $ content , $ from , $ to ) { if ( ! in_array ( $ from , $ this -> inputFormats ) ) { throw new PandocException ( sprintf ( '%s is not a valid input format for pandoc' , $ from ) ) ; } if ( ! in_array ( $ to , $ this -> outputFormats ) ) { throw new PandocException ( sprintf ( '%s is not a val...
Run the conversion from one type to another
50,126
public function move ( $ path , $ name = '' , $ unlinkable = true , $ deferred = false ) { $ this -> path = rtrim ( $ path , "/" ) . "/" ; $ this -> filename = $ name ; $ this -> unlink_file = $ unlinkable ; $ this -> upload_deferred = $ deferred ; if ( ! $ this -> web_path ) $ this -> web_path = $ this -> path ; retur...
move uploaded file to the destination path optionally raname it name param can be passed also as blade syntax unlinkable is a bool tell to the field to unlink or not if remove is checked
50,127
protected function setName ( $ name ) { $ relation = null ; if ( preg_match ( '#^([a-z0-9_-]+)\.([a-z0-9_-]+)$#i' , $ name , $ matches ) ) { $ relation = $ matches [ 1 ] ; $ name = $ matches [ 2 ] ; } elseif ( preg_match ( '#^[a-z0-9_-]+$#i' , $ name ) ) { $ relation = $ name ; } if ( isset ( $ this -> model ) && metho...
check for relation notation and split relation - name and fiel - dname
50,128
public function unique ( $ id = null , $ idClumn = null , $ extra = null ) { $ id = $ id ? : $ this -> model -> id ? : 'NULL' ; $ idClumn = $ idClumn ? : $ this -> model -> getKeyName ( ) ; $ parts = [ "unique:{$this->model->getConnectionName()}.{$this->model->getTable()}" , $ this -> db_name , $ id , $ idClumn ] ; if ...
Laravel Validation unique
50,129
protected function parseString ( $ string , $ is_view = false ) { if ( is_object ( $ this -> model ) && ( strpos ( $ string , '{{' ) !== false || strpos ( $ string , '{!!' ) !== false || $ is_view ) ) { $ fields = $ this -> model -> getAttributes ( ) ; $ relations = $ this -> model -> getRelations ( ) ; $ array = array...
parse blade syntax string using current model
50,130
public function remove ( $ fieldname ) { if ( isset ( $ this -> fields [ $ fieldname ] ) ) unset ( $ this -> fields [ $ fieldname ] ) ; return $ this ; }
remove field from list
50,131
public function field ( $ field_name , array $ attributes = array ( ) ) { if ( isset ( $ this -> fields [ $ field_name ] ) ) { $ field = $ this -> fields [ $ field_name ] ; if ( count ( $ attributes ) ) { $ field -> attributes ( $ attributes ) ; $ field -> build ( ) ; } return $ field ; } }
get field instance from fields array
50,132
public function resize ( $ width , $ height , $ filename = null ) { $ this -> resize [ ] = array ( 'width' => $ width , 'height' => $ height , 'filename' => $ filename ) ; return $ this ; }
shortcut to ImageManager resize
50,133
public function fit ( $ width , $ height , $ filename = null ) { $ this -> fit [ ] = array ( 'width' => $ width , 'height' => $ height , 'filename' => $ filename ) ; return $ this ; }
shortcut to ImageManager fit
50,134
protected function imageProcess ( ) { if ( $ this -> saved ) { if ( ! $ this -> image ) $ this -> image = ImageManager :: make ( $ this -> saved ) ; if ( $ this -> image_callable ) { $ callable = $ this -> image_callable ; $ callable ( $ this -> image ) ; } if ( count ( $ this -> resize ) ) { foreach ( $ this -> resize...
postprocess image if needed
50,135
public function attributes ( $ attributes ) { if ( is_array ( $ this -> attributes ) and is_array ( $ attributes ) ) { $ attributes = array_merge ( $ this -> attributes , $ attributes ) ; } $ this -> attributes = $ attributes ; return $ this ; }
set attributes for widget
50,136
public function buildAttributes ( ) { if ( is_string ( $ this -> attributes ) ) return $ this -> attributes ; if ( count ( $ this -> attributes ) < 1 ) return "" ; $ compiled = '' ; foreach ( $ this -> attributes as $ key => $ val ) { $ compiled .= ' ' . $ key . '="' . $ val . '"' ; } return $ compiled ; }
return a attributes in string format
50,137
public function formButton ( $ url , $ method , $ name , $ position = "BL" , $ attributes = array ( ) ) { $ attributes = array_merge ( array ( "class" => "btn btn-default" ) , $ attributes ) ; $ this -> button_container [ $ position ] [ ] = Form :: open ( array ( 'url' => $ url , 'method' => $ method ) ) . Form :: subm...
return a form with a nested action button
50,138
public function format ( $ format , $ language = 'en' ) { $ this -> format = $ format ; $ this -> language = $ language ; return $ this ; }
set instarnal preview date format
50,139
protected function humanDateToIso ( $ humandate ) { $ datetime = \ DateTime :: createFromFormat ( $ this -> format , $ humandate ) ; if ( ! $ datetime ) return null ; $ humandate = $ datetime -> format ( 'Y-m-d' ) ; return $ humandate ; }
convert from current user format to iso date
50,140
protected function find ( $ id ) { $ model = $ this -> model ; $ this -> model = $ model :: find ( $ id ) ; if ( ! $ this -> model ) { return false ; } return $ this -> model -> exists ; }
find a record on current model and return bool
50,141
public function back ( $ actions = 'insert|update|do_delete' , $ url = "" ) { if ( $ url == "" ) { if ( count ( $ this -> links ) ) { $ url = array_pop ( $ this -> links ) ; } else { return $ this ; } } else { $ base = str_replace ( Request :: path ( ) , '' , strtok ( Request :: fullUrl ( ) , '?' ) ) ; $ match_url = st...
enable auto - back feature on given actions
50,142
protected function buildButtons ( ) { $ saveButtonPosition = Config :: get ( 'rapyd.data_edit.button_position.save' ) != '' ? Config :: get ( 'rapyd.data_edit.button_position.save' ) : 'BL' ; $ showButtonPosition = Config :: get ( 'rapyd.data_edit.button_position.show' ) != '' ? Config :: get ( 'rapyd.data_edit.button_...
it build standard buttons depending on current status
50,143
public function group ( $ value = null ) { if ( func_num_args ( ) ) { $ this -> group = $ value ; return $ this ; } return $ this -> group ; }
Set the group of the DataTree . Multiple DataTrees of the same group will be able to exchange items .
50,144
public function format ( $ format , $ language = 'en' , $ store_as = null ) { $ this -> format = $ format ; $ this -> language = $ language ; if ( $ store_as ) { $ this -> store_as = $ store_as ; } return $ this ; }
set instarnal preview datetime format
50,145
protected function isodatetimeToHuman ( $ isodatetime ) { $ datetime = \ DateTime :: createFromFormat ( $ this -> store_as , $ isodatetime ) ; if ( ! $ datetime ) return '' ; $ timestamp = $ datetime -> getTimestamp ( ) ; if ( $ timestamp < 1 ) { return "" ; } $ isodatetime = date ( $ this -> format , $ timestamp ) ; r...
convert from iso datetime to user format
50,146
protected function humandatetimeToIso ( $ humandatetime ) { $ datetime = \ DateTime :: createFromFormat ( $ this -> format , $ humandatetime ) ; if ( ! $ datetime ) return '' ; $ timestamp = $ datetime -> getTimestamp ( ) ; if ( $ timestamp < 1 ) { return "" ; } $ humandatetime = date ( $ this -> store_as , $ timestamp...
convert from current user format to iso datetime
50,147
public function has ( $ key ) { if ( ! $ this -> checkExtraColumns ( ) ) { return false ; } $ this -> load ( ) ; return Arr :: has ( $ this -> data , $ key ) ; }
Determine if a key exists in the settings data .
50,148
public function set ( $ key , $ value = null ) { if ( ! $ this -> checkExtraColumns ( ) ) { return ; } $ this -> load ( ) ; $ this -> unsaved = true ; if ( is_array ( $ key ) ) { foreach ( $ key as $ k => $ v ) { Arr :: set ( $ this -> data , $ k , $ v ) ; } } else { Arr :: set ( $ this -> data , $ key , $ value ) ; } ...
Set a specific key to a value in the settings data .
50,149
public function load ( $ force = false ) { if ( ! $ this -> checkExtraColumns ( ) ) { return ; } if ( $ this -> loaded && ! $ force ) { return ; } $ this -> data = $ this -> read ( ) ; $ this -> loaded = true ; }
Make sure data is loaded .
50,150
public function findMagentoRootDir ( $ start_directory ) { $ ds = DIRECTORY_SEPARATOR ; $ directory_tree = explode ( $ ds , $ start_directory ) ; while ( count ( $ directory_tree ) > 0 ) { $ current_directory = join ( $ ds , $ directory_tree ) ; $ current_search_location = join ( $ ds , array_merge ( $ directory_tree ,...
Given a start directory work upwards and attempt to identify the Magento root directory . Throws an exception if it can t be found .
50,151
public function display ( Graph $ graph ) { $ tmp = $ this -> createImageFile ( $ graph ) ; static $ next = 0 ; if ( $ next > microtime ( true ) ) { sleep ( self :: DELAY_OPEN ) ; } if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) { exec ( 'start "" ' . escapeshellarg ( $ tmp ) . ' >NUL' ) ; } elseif ( strtoup...
create and display image for this graph
50,152
public function createImageData ( Graph $ graph ) { $ file = $ this -> createImageFile ( $ graph ) ; $ data = file_get_contents ( $ file ) ; unlink ( $ file ) ; return $ data ; }
create image file data contents for this graph
50,153
public function createImageSrc ( Graph $ graph ) { $ format = $ this -> format ; if ( $ this -> format === 'svg' || $ this -> format === 'svgz' ) { $ format = 'svg+xml;charset=' . $ graph -> getAttribute ( 'graphviz.graph.charset' , 'UTF-8' ) ; } return 'data:image/' . $ format . ';base64,' . base64_encode ( $ this -> ...
create base64 - encoded image src target data to be used for html images
50,154
public function createImageHtml ( Graph $ graph ) { if ( $ this -> format === 'svg' || $ this -> format === 'svgz' ) { return '<object type="image/svg+xml" data="' . $ this -> createImageSrc ( $ graph ) . '"></object>' ; } return '<img src="' . $ this -> createImageSrc ( $ graph ) . '" />' ; }
create image html code for this graph
50,155
public function createImageFile ( Graph $ graph ) { $ script = $ this -> createScript ( $ graph ) ; $ tmp = tempnam ( sys_get_temp_dir ( ) , 'graphviz' ) ; if ( $ tmp === false ) { throw new UnexpectedValueException ( 'Unable to get temporary file name for graphviz script' ) ; } $ ret = file_put_contents ( $ tmp , $ sc...
create image file for this graph
50,156
public function registerAnalysers ( ) { $ jsonFile = Environment :: getJsonConfigFilename ( ) ; if ( ! $ jsonFile ) { return ; } $ config = new Config ; $ var = $ config -> validate ( $ jsonFile ) ; foreach ( $ var [ 'analysers' ] as $ analyser ) { if ( class_exists ( $ analyser [ 'class' ] ) ) { $ analyser = new $ ana...
Loads all analysers declared in the JSON config file .
50,157
public function addAnalyser ( NodeVisitor $ analyser ) { $ analyser -> setSubject ( $ this ) ; $ this -> analysers [ ] = $ analyser ; return $ this ; }
Adds a new analyser to get specific metrics
50,158
public function dir ( ) { $ pm = new PluginManager ( new EventDispatcher ( ) ) ; if ( $ this -> registerPlugins ) { $ pm -> registerPlugins ( ) ; } $ plugins = $ pm -> getPlugins ( ) ; $ rows = array ( ) ; foreach ( $ plugins as $ plugin ) { if ( ! $ plugin instanceof EventSubscriberInterface ) { $ events = array ( ) ;...
List all plugins installed .
50,159
public function getNamespaceName ( ) { $ parts = $ this -> node -> consts [ 0 ] -> namespacedName -> parts ; array_pop ( $ parts ) ; return implode ( '\\' , $ parts ) ; }
Get the namespace name where the constant is defined .
50,160
public function getValue ( ) { $ prettyPrinter = new PrettyPrinter \ Standard ; return trim ( $ prettyPrinter -> prettyPrintExpr ( $ this -> node -> consts [ 0 ] -> value ) , '"\'' ) ; }
Gets the constant value .
50,161
public function getInterfaceNames ( ) { $ interfaces = array ( ) ; if ( $ this -> node instanceof Node \ Stmt \ Class_ ) { foreach ( $ this -> node -> implements as $ interface ) { $ interfaces [ ] = ( string ) $ interface ; } } return $ interfaces ; }
Gets the interface names .
50,162
public function getParentClassName ( ) { if ( $ this -> isTrait ( ) ) { return false ; } $ parent = $ this -> node -> extends ; if ( ! empty ( $ parent ) ) { if ( $ this -> isInterface ( ) ) { $ parent = array_pop ( $ parent ) ; } return ( string ) $ parent ; } return false ; }
Gets the parent class .
50,163
public function getConstants ( ) { if ( $ this -> constants === null ) { $ prettyPrinter = new PrettyPrinter \ Standard ; $ this -> constants = array ( ) ; foreach ( $ this -> node -> stmts as $ stmt ) { if ( $ stmt instanceof Node \ Stmt \ ClassConst ) { foreach ( $ stmt -> consts as $ const ) { $ this -> constants [ ...
Gets the constants .
50,164
public function getConstant ( $ name ) { $ constants = $ this -> getConstants ( ) ; $ value = array_key_exists ( $ name , $ constants ) ; if ( $ value ) { $ value = $ constants [ $ name ] ; } return $ value ; }
Gets defined constant .
50,165
public function getMethods ( $ filter = null ) { if ( $ this -> methods === null ) { $ this -> methods = array ( ) ; foreach ( $ this -> node -> stmts as $ stmt ) { if ( $ stmt instanceof Node \ Stmt \ ClassMethod ) { $ stmt -> setAttribute ( 'fileName' , $ this -> getFileName ( ) ) ; $ this -> methods [ $ stmt -> name...
Gets an array of methods .
50,166
public function getMethod ( $ name ) { if ( $ this -> hasMethod ( $ name ) ) { return $ this -> methods [ $ name ] ; } throw new ModelException ( 'Method ' . $ name . ' does not exist.' ) ; }
Gets a MethodModel for a class method .
50,167
public function getStaticProperties ( ) { if ( $ this -> staticProperties === null ) { foreach ( $ this -> node -> stmts as $ stmt ) { if ( $ stmt instanceof Node \ Stmt \ Property ) { if ( $ stmt -> isStatic ( ) === false ) { continue ; } foreach ( $ stmt -> props as $ prop ) { $ this -> staticProperties [ ] = new Pro...
Gets the static properties .
50,168
public function getStaticPropertyValue ( $ name ) { $ properties = $ this -> getStaticProperties ( ) ; if ( array_key_exists ( $ name , $ properties ) ) { return $ properties [ $ name ] ; } throw new ModelException ( 'Property ' . $ name . ' does not exist or is not static.' ) ; }
Gets static property value .
50,169
public function getProperties ( ) { if ( $ this -> properties === null ) { $ this -> properties = array ( ) ; foreach ( $ this -> node -> stmts as $ stmt ) { if ( $ stmt instanceof Node \ Stmt \ Property ) { $ this -> properties [ ] = new PropertyModel ( $ this , $ stmt ) ; } } } return array_values ( $ this -> propert...
Gets the properties .
50,170
public function getProperty ( $ name ) { if ( $ this -> hasProperty ( $ name ) ) { return $ this -> properties [ $ name ] ; } throw new ModelException ( 'Property ' . $ name . ' does not exist.' ) ; }
Gets a PropertyModel for a class property .
50,171
public function isFinal ( ) { if ( $ this -> node instanceof Node \ Stmt \ Class_ ) { return $ this -> node -> isFinal ( ) ; } return false ; }
Checks whether this class is final .
50,172
public function isInstantiable ( ) { if ( $ this -> isTrait ( ) || $ this -> isInterface ( ) || $ this -> isAbstract ( ) ) { return false ; } foreach ( array ( '__construct' , $ this -> getShortName ( ) ) as $ method ) { if ( $ this -> hasMethod ( $ method ) ) { return $ this -> getMethod ( $ method ) -> isPublic ( ) ;...
Checks whether this class is instantiable .
50,173
public function isSubclassOf ( $ class ) { return false ; if ( in_array ( $ class , $ this -> struct [ 'interfaces' ] ) ) { return true ; } $ parent = $ this -> getParentClass ( ) ; if ( ! empty ( $ parent ) ) { if ( $ parent -> getName ( ) === $ class ) { return true ; } return in_array ( $ class , $ parent -> getInte...
Checks if the class is a subclass of a specified class or implements a specified interface .
50,174
public function onReflectProgress ( GenericEvent $ event ) { $ context = $ event -> getArguments ( ) ; $ this -> logger -> info ( 'Parsing file "{file}" in progress.' , $ context ) ; }
Logs PROGRESS event .
50,175
public function onReflectSuccess ( GenericEvent $ event ) { $ context = $ event -> getArguments ( ) ; $ this -> logger -> info ( 'Analyze file "{file}" successful.' , $ context ) ; }
Logs SUCCESS event .
50,176
public function onReflectError ( GenericEvent $ event ) { $ context = $ event -> getArguments ( ) ; $ this -> logger -> error ( 'Parser has detected an error on file "{file}". {error}' , $ context ) ; }
Logs ERROR event .
50,177
public function onReflectComplete ( GenericEvent $ event ) { $ context = $ event -> getArguments ( ) ; unset ( $ context [ 'extra' ] ) ; $ this -> logger -> notice ( 'Parsing data source "{source}" completed.' , $ context ) ; }
Logs COMPLETE event .
50,178
public function onAstBuild ( GenericEvent $ event ) { $ context = $ event -> getArguments ( ) ; if ( isset ( $ context [ 'node' ] ) ) { $ context [ 'node' ] = sprintf ( '%s with attributes %s' , $ context [ 'node' ] -> getType ( ) , json_encode ( $ context [ 'node' ] -> getAttributes ( ) ) ) ; } $ this -> logger -> deb...
Logs BUILD event .
50,179
public function onSniff ( GenericEvent $ event ) { $ context = $ event -> getArguments ( ) ; $ this -> logger -> debug ( 'Visiting SNIFF, process {method} {sniff}' , $ context ) ; }
Logs SNIFF event .
50,180
public function getValue ( ) { if ( ! empty ( $ this -> node -> props [ 0 ] -> default -> value ) ) { return $ this -> node -> props [ 0 ] -> default -> value ; } return ; }
Gets the property value .
50,181
public function isConstructor ( ) { $ name = explode ( '\\' , $ this -> declaringClass -> getName ( ) ) ; $ name = array_pop ( $ name ) ; return in_array ( $ this -> getShortName ( ) , array ( '__construct' , $ name ) ) ; }
Checks if the method is a constructor .
50,182
public function getTypeHint ( ) { $ typeHint = $ this -> node -> type ; if ( $ typeHint instanceof Node \ Name ) { $ typeHint = ( string ) $ typeHint ; } return $ typeHint ; }
Gets the type of the parameter .
50,183
public function allowsNull ( ) { if ( ! empty ( $ this -> node -> type ) ) { if ( $ this -> node -> default instanceof Node \ Expr \ ConstFetch && $ this -> node -> default -> name instanceof Node \ Name && strcasecmp ( 'null' , ( string ) $ this -> node -> default -> name ) === 0 ) { return true ; } return false ; } r...
Checks whether the parameter allows NULL .
50,184
public function getDefaultValue ( ) { if ( $ this -> isDefaultValueAvailable ( ) ) { $ prettyPrinter = new PrettyPrinter \ Standard ; return $ prettyPrinter -> prettyPrintExpr ( $ this -> node -> default ) ; } throw new ModelException ( sprintf ( 'Parameter #%d [$%s] is not optional.' , $ this -> getPosition ( ) , $ th...
Gets the default value of the parameter for a user - defined function or method . If the parameter is not optional a ModelException will be thrown .
50,185
protected function transformToComposer ( $ response ) { $ analyserId = 'Bartlett\CompatInfo\Analyser\CompatibilityAnalyser' ; if ( ! isset ( $ response [ $ analyserId ] ) ) { throw new \ RuntimeException ( 'Could not render result to Composer format' ) ; } $ compatinfo = $ response [ $ analyserId ] ; $ composer = array...
Transforms compatibility analyser results to Composer json format .
50,186
protected function getJsonConfigFile ( $ file ) { $ json = $ this -> validateSyntax ( $ file ) ; $ schemaFile = dirname ( dirname ( dirname ( dirname ( dirname ( __DIR__ ) ) ) ) ) . '/bin/' . basename ( $ file ) . '-schema' ; if ( file_exists ( $ schemaFile ) ) { $ this -> validateSchema ( $ json , $ schemaFile , $ fil...
Gets the contents of a JSON configuration file .
50,187
protected function validateSyntax ( $ file ) { $ fname = realpath ( $ file ) ; if ( $ fname === false ) { $ fname = $ file ; } if ( ! file_exists ( $ fname ) ) { throw new \ RuntimeException ( 'File "' . $ file . '" not found.' ) ; } if ( ! is_readable ( $ fname ) ) { throw new \ RuntimeException ( 'File "' . $ file . ...
Validates the syntax of a JSON file
50,188
public function dir ( OutputInterface $ output , $ response ) { if ( empty ( $ response ) ) { $ output -> writeln ( '<error>No analysers detected.</error>' ) ; } else { $ headers = array ( 'Analyser Name' , 'Analyser Class' ) ; $ rows = array ( ) ; foreach ( $ response as $ name => $ class ) { $ rows [ ] = array ( $ na...
Results of analysers available
50,189
public function run ( OutputInterface $ output , $ response ) { if ( empty ( $ response ) ) { $ output -> writeln ( '<info>No metrics.</info>' ) ; return ; } $ output -> writeln ( '<info>Data Source Analysed</info>' ) ; $ directories = array ( ) ; foreach ( $ response [ 'files' ] as $ file ) { $ directories [ ] = dirna...
Results of analysers metrics
50,190
protected function preNotify ( $ listener , $ eventName , Event $ event ) { if ( Events :: SUCCESS == $ eventName && $ event instanceof GenericEvent ) { if ( is_array ( $ listener ) && ! $ listener [ 0 ] instanceof \ Bartlett \ Reflect \ Plugin \ CachePlugin ) { unset ( $ event [ 'ast' ] ) ; } } return $ event ; }
Called before notify a listener about the event .
50,191
public function getName ( ) { if ( $ this -> isClosure ( ) ) { return '{closure}' ; } if ( isset ( $ this -> node -> namespacedName ) ) { return $ this -> node -> namespacedName ; } return $ this -> node -> name ; }
Get the name of the function .
50,192
public function api ( $ name ) { $ classes = array ( 'Bartlett\Reflect\Api\\' => array ( 'Analyser' , 'Cache' , 'Config' , 'Diagnose' , 'Diagram' , 'Plugin' , 'Reflection' , ) , 'Bartlett\CompatInfo\Api\\' => array ( 'Reference' ) , ) ; $ class = false ; foreach ( $ classes as $ ns => $ basename ) { if ( in_array ( ucf...
Returns an Api
50,193
private function initializeClient ( $ url , ClientInterface $ client = null ) { if ( $ client ) { $ this -> client = $ client ; } else { $ this -> client = new LocalClient ( $ url ) ; } }
Initializes a http or local client
50,194
public function run ( ) { $ response = array ( ) ; if ( version_compare ( PHP_VERSION , self :: PHP_MIN , '<' ) ) { $ response [ 'php_version' ] = false ; } else { $ response [ 'php_version' ] = PHP_VERSION ; } $ response [ 'php_ini' ] = php_ini_loaded_file ( ) ; $ extensions = array ( 'date' , 'json' , 'pcre' , 'phar'...
Diagnoses the system to identify common errors .
50,195
protected function registerAnalysers ( ) { $ file = 'Bartlett/CompatInfo/Analyser/CompatibilityAnalyser.php' ; $ reflectBaseDir = dirname ( dirname ( dirname ( dirname ( dirname ( __DIR__ ) ) ) ) ) ; $ baseDir = dirname ( dirname ( dirname ( $ reflectBaseDir ) ) ) ; $ vendorDir = $ baseDir . '/vendor' ; $ baseAnalyser ...
Registers all analysers bundled with distribution and declared by user in the JSON config file .
50,196
public function function_ ( $ argument , $ source , $ alias = null , $ format = 'txt' ) { return $ this -> request ( 'reflection/function' , 'POST' , array ( $ argument , $ source , $ alias , $ format ) ) ; }
Reports information about a user function present in a data source .
50,197
public function onNotification ( GenericEvent $ event , $ eventName ) { static $ start = false ; switch ( $ eventName ) { case Events :: PROGRESS : if ( ! $ start ) { $ this -> stopwatch -> start ( $ event [ 'source' ] ) ; $ start = true ; } return ; case Events :: ERROR : $ message = 'Parser has detected an error on f...
Notifies all important application events
50,198
protected function getPlaceholders ( GenericEvent $ event ) { return array ( '%eventname%' => $ event [ 'eventname' ] , '%source%' => $ event [ 'source' ] , '%filename%' => $ event -> hasArgument ( 'file' ) ? $ event [ 'file' ] : '' , '%error%' => $ event -> hasArgument ( 'error' ) ? $ event [ 'error' ] : '' , '%profil...
Gets each place holders of event s arguments
50,199
public function onReflectProgress ( GenericEvent $ event ) { static $ start = false ; if ( ! $ start ) { $ this -> stopwatch -> start ( $ event [ 'source' ] ) ; $ start = true ; } $ this -> stopwatch -> start ( $ event [ 'file' ] -> getPathname ( ) ) ; }
Just before parsing a new file of the data source .