idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
46,300 | public function serialize ( SpanContext $ context ) { $ ret = '00-' . $ context -> traceId ( ) ; if ( $ context -> spanId ( ) ) { $ ret .= '-' . str_pad ( $ context -> spanId ( ) , 16 , "0" , STR_PAD_LEFT ) ; } if ( $ context -> enabled ( ) !== null ) { $ ret .= '-' . ( $ context -> enabled ( ) ? '01' : '00' ) ; } retu... | Convert a SpanContext to header string . Uses version 0 . |
46,301 | public static function load ( ) { if ( ! extension_loaded ( 'opencensus' ) ) { trigger_error ( 'opencensus extension required to load Laravel integrations.' , E_USER_WARNING ) ; return ; } Eloquent :: load ( ) ; opencensus_trace_method ( CompilerEngine :: class , 'get' , function ( $ scope , $ path , $ data ) { return ... | Static method to add instrumentation to the Laravel framework |
46,302 | public static function newFloatMeasure ( string $ name , string $ description , string $ unit ) : FloatMeasure { return FloatMeasure :: create ( $ name , $ description , $ unit ) ; } | Constructs a new FloatMeasure . |
46,303 | public static function load ( ) { if ( ! extension_loaded ( 'opencensus' ) ) { trigger_error ( 'opencensus extension required to load Doctrine integrations.' , E_USER_WARNING ) ; return ; } PDO :: load ( ) ; $ persisterClass = ( Version :: compare ( '2.5.0' ) < 0 ) ? 'Doctrine\ORM\Persisters\Entity\BasicEntityPersister... | Static method to add instrumentation to Doctrine ORM calls |
46,304 | private static function isPrintable ( $ str ) { for ( $ i = 0 ; $ i < strlen ( $ str ) ; $ i ++ ) { if ( ! ( $ str [ $ i ] >= ' ' && $ str [ $ i ] <= '~' ) ) { return false ; } } return true ; } | Determines whether the string contains only printable characters . |
46,305 | public function spanData ( ) { return new SpanData ( $ this -> name , $ this -> traceId , $ this -> spanId , $ this -> startTime , $ this -> endTime , [ 'parentSpanId' => $ this -> parentSpanId , 'attributes' => $ this -> attributes , 'timeEvents' => $ this -> timeEvents , 'links' => $ this -> links , 'status' => $ thi... | Return a read - only version of this span . |
46,306 | public function addAttribute ( $ attribute , $ value ) { $ this -> attributes [ $ attribute ] = ( string ) $ value ; $ this -> eventHandler -> attributeAdded ( $ this , $ attribute , $ value ) ; } | Add an attribute to this span . |
46,307 | public function addTimeEvent ( TimeEvent $ timeEvent ) { $ this -> timeEvents [ ] = $ timeEvent ; $ this -> eventHandler -> timeEventAdded ( $ this , $ timeEvent ) ; } | Add a time event to this span . |
46,308 | public function addLink ( Link $ link ) { $ this -> links [ ] = $ link ; $ this -> eventHandler -> linkAdded ( $ this , $ link ) ; } | Add a link to this span . |
46,309 | private function filterStackTrace ( $ stackTrace ) { return array_values ( array_filter ( $ stackTrace , function ( $ st ) { return ! array_key_exists ( 'class' , $ st ) || substr ( $ st [ 'class' ] , 0 , 16 ) != 'OpenCensus\Trace' ; } ) ) ; } | Return a filtered stackTrace where we strip out all functions from the OpenCensus \ Trace namespace |
46,310 | public function value ( $ key , $ default = null ) { return array_key_exists ( $ key , $ this -> values ) ? $ this -> values [ $ key ] : $ default ; } | Fetches the value for a given key in this context . Returns the provided default if not set . |
46,311 | public static function load ( ) { if ( ! extension_loaded ( 'opencensus' ) ) { trigger_error ( 'opencensus extension required to load Wordpress integrations.' , E_USER_WARNING ) ; return ; } Mysql :: load ( ) ; $ nameClosure = function ( ) { if ( func_num_args ( ) > 0 ) { return [ 'attributes' => [ 'name' => func_get_a... | Static method to add instrumentation to the Wordpress framework |
46,312 | public static function create ( string $ name ) : TagKey { if ( strlen ( $ name ) == 0 || strlen ( $ name ) > self :: MAX_LENGTH || ! self :: isPrintable ( $ name ) ) { throw new \ Exception ( "Invalid TagKey name: " . $ name ) ; } return new self ( $ name ) ; } | Constructs a TagKey with the given name . |
46,313 | public static function load ( ) { if ( ! extension_loaded ( 'opencensus' ) ) { trigger_error ( 'opencensus extension required to load pg integrations.' , E_USER_WARNING ) ; return ; } opencensus_trace_function ( 'pg_connect' ) ; opencensus_trace_function ( 'pg_pconnect' ) ; opencensus_trace_function ( 'pg_query' , func... | Static method to add instrumentation to the postgres requests |
46,314 | public static function load ( ) { if ( ! extension_loaded ( 'opencensus' ) ) { trigger_error ( 'opencensus extension required to load Symfony integrations.' , E_USER_WARNING ) ; return ; } Doctrine :: load ( ) ; opencensus_trace_method ( HttpKernel :: class , 'handle' , function ( $ kernel , $ request ) { return [ 'nam... | Static method to add instrumentation to the Symfony framework |
46,315 | public static function load ( ) { if ( ! extension_loaded ( 'opencensus' ) ) { trigger_error ( 'opencensus extension required to load grpc integrations.' , E_USER_WARNING ) ; return ; } opencensus_trace_method ( BaseStub :: class , '_simpleRequest' , function ( $ stub , $ method ) { return [ 'name' => 'grpc/simpleReque... | Static method to add instrumentation to grpc requests |
46,316 | public static function updateMetadata ( $ metadata , $ jwtAuthUri ) { $ context = Tracer :: spanContext ( ) ; if ( $ context -> enabled ( ) ) { $ propagator = new GrpcMetadataPropagator ( ) ; $ metadata += [ $ propagator -> key ( ) => [ $ propagator -> formatter ( ) -> serialize ( $ context ) ] ] ; } return $ metadata ... | Update metadata handler for grpc clients . |
46,317 | public function onBefore ( BeforeEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ context = Tracer :: spanContext ( ) ; if ( $ context -> enabled ( ) ) { $ request -> setHeader ( $ this -> propagator -> key ( ) , $ this -> propagator -> formatter ( ) -> serialize ( $ context ) ) ; } $ span = Tracer :: startS... | Handler for the BeforeEvent request lifecycle event . Adds the current trace context as the trace context header . Also starts a span representing this outgoing http request . |
46,318 | final public function m ( int $ value ) : Measurement { return new class ( $ this , $ value ) extends Measurement { public function __construct ( Measure & $ measure , int $ value ) { parent :: __construct ( $ measure , $ value ) ; } } ; } | Creates a Measurement of provided value . |
46,319 | final public function insert ( TagKey $ key , TagValue $ value ) : bool { if ( \ array_key_exists ( $ key -> getName ( ) , $ this -> m ) ) { return false ; } $ this -> m [ $ key -> getName ( ) ] = new Tag ( $ key , $ value ) ; return true ; } | Insert a Tag into TagContext given provided TagKey and string value . If TagKey already exists in TagContext this method is a noop . |
46,320 | final public function upsert ( TagKey $ key , TagValue $ value ) { $ this -> m [ $ key -> getName ( ) ] = new Tag ( $ key , $ value ) ; } | Insert or Update a Tag into TagContext given provided TagKey with provided string value . |
46,321 | final public function delete ( TagKey $ key ) : bool { if ( ! \ array_key_exists ( $ key -> getName ( ) , $ this -> m ) ) { return false ; } unset ( $ this -> m [ $ key -> getName ( ) ] ) ; return true ; } | Deletes Tag from TagContext identified by its TagKey . |
46,322 | final public static function fromContext ( Context $ ctx = null ) : TagContext { if ( $ ctx === null ) { $ ctx = Context :: current ( ) ; } return $ ctx -> value ( self :: CTX_KEY , new self ( ) ) ; } | Extract a TagContext from the provided Context object . If Context is not provided the current Context is used . If no TagContext is found a new empty TagContext is returned . |
46,323 | final public function newContext ( Context $ ctx = null ) : Context { if ( $ ctx === null ) { $ ctx = Context :: current ( ) ; } return $ ctx -> withValue ( self :: CTX_KEY , $ this ) ; } | Creates a new Context with our TagContext attached . To propagate a TagContext to downstream methods and downstream RPCs add a TagContext to the current Context . If there is already a TagContext in the current context it will be replaced with this TagContext . |
46,324 | public function export ( array $ spans ) { $ spans = $ this -> convertSpans ( $ spans ) ; return file_put_contents ( $ this -> filename , json_encode ( $ spans ) . PHP_EOL , FILE_APPEND ) !== false ; } | Report the provided SpanData to a file in json format . |
46,325 | private function convertSpans ( array $ spans ) { return array_map ( function ( SpanData $ span ) { return [ 'traceId' => $ span -> traceId ( ) , 'name' => $ span -> name ( ) , 'spanId' => $ span -> spanId ( ) , 'parentSpanId' => $ span -> parentSpanId ( ) , 'stackTrace' => $ span -> stackTrace ( ) , 'startTime' => $ s... | Convert spans into array ready for serialization . |
46,326 | public function inSpan ( array $ spanOptions , callable $ callable , array $ arguments = [ ] ) { $ span = $ this -> startSpan ( $ spanOptions + [ 'sameProcessAsParentSpan' => $ this -> hasSpans ] ) ; $ scope = $ this -> withSpan ( $ span ) ; try { return call_user_func_array ( $ callable , $ arguments ) ; } finally { $... | Instrument a callable by creating a Span |
46,327 | public function startSpan ( array $ spanOptions ) { if ( ! array_key_exists ( 'name' , $ spanOptions ) ) { $ spanOptions [ 'name' ] = $ this -> generateSpanName ( ) ; } $ spanOptions [ 'eventHandler' ] = $ this ; return new Span ( $ spanOptions ) ; } | Start a new Span . The start time is already set to the current time . |
46,328 | public function spans ( ) { $ traceId = $ this -> spanContext ( ) -> traceId ( ) ; return array_map ( function ( $ span ) use ( $ traceId ) { return $ this -> mapSpan ( $ span , $ traceId ) ; } , opencensus_trace_list ( ) ) ; } | Return the spans collected . |
46,329 | public function attributeAdded ( Span $ span , $ attribute , $ value ) { if ( $ span -> attached ( ) ) { $ this -> addAttribute ( $ attribute , $ value , [ 'span' => $ span ] ) ; } } | Triggers when an attribute is added to a span . |
46,330 | public function linkAdded ( Span $ span , Link $ link ) { if ( $ span -> attached ( ) ) { $ this -> addLink ( $ link -> traceId ( ) , $ link -> spanId ( ) , [ 'type' => $ link -> type ( ) , 'attributes' => $ link -> attributes ( ) , 'span' => $ span ] ) ; } } | Triggers when a link is added to a span . |
46,331 | public function timeEventAdded ( Span $ span , TimeEvent $ timeEvent ) { if ( $ span -> attached ( ) ) { if ( $ timeEvent instanceof Annotation ) { $ this -> addAnnotation ( $ timeEvent -> description ( ) , [ 'time' => $ timeEvent -> time ( ) , 'attributes' => $ timeEvent -> attributes ( ) , 'span' => $ span ] ) ; } el... | Triggers when a time event is added to a span . |
46,332 | public function locateFiles ( array $ bundles , string $ environment ) : array { $ fixtureFiles = array_flip ( $ this -> fixtureLocator -> locateFiles ( $ bundles , $ environment ) ) ; $ fixtureFiles = $ fixtureFiles + array_flip ( $ this -> fixtureLocator -> locateFiles ( $ bundles , '' ) ) ; return array_keys ( $ fix... | Locate fixture files found matching the environment name . |
46,333 | public function locateFiles ( array $ bundles , string $ environment ) : array { $ fixtureFiles = array_merge ( ... array_map ( function ( string $ rootDir ) use ( $ environment ) : array { return $ this -> doLocateFiles ( $ rootDir , $ environment ) ; } , $ this -> rootDirs ) , ... array_map ( function ( BundleInterfa... | Locates fixture files found inside a folder matching the environment name . |
46,334 | private function doLocateFiles ( string $ path , string $ environment ) : array { $ fullPaths = array_filter ( array_map ( static function ( string $ fixturePath ) use ( $ environment , $ path ) : string { return '' !== $ environment ? sprintf ( '%s/%s/%s' , $ path , $ fixturePath , $ environment ) : sprintf ( '%s/%s' ... | Gets the list of files that can be found in the given path . |
46,335 | private function askConfirmation ( InputInterface $ input , OutputInterface $ output , $ question , $ default ) { $ questionHelper = $ this -> getHelperSet ( ) -> get ( 'question' ) ; $ question = new ConfirmationQuestion ( $ question , $ default ) ; return ( bool ) $ questionHelper -> ask ( $ input , $ output , $ ques... | Prompts to the user a message to ask him a confirmation . |
46,336 | public function generate ( ConfigInterface $ config ) { $ this -> config = $ config ; $ this -> log ( 'Starting generation' ) ; $ options = $ this -> config -> get ( 'soapClientOptions' ) ; if ( empty ( $ options [ 'features' ] ) || ( ( $ options [ 'features' ] & SOAP_SINGLE_ELEMENT_ARRAYS ) != SOAP_SINGLE_ELEMENT_ARRA... | Generates php source code from a wsdl file |
46,337 | protected function load ( $ wsdl ) { $ this -> log ( 'Loading the WSDL' ) ; $ this -> wsdl = new WsdlDocument ( $ this -> config , $ wsdl ) ; $ this -> types = array ( ) ; $ this -> loadTypes ( ) ; $ this -> loadService ( ) ; } | Load the wsdl file into php |
46,338 | protected function loadService ( ) { $ service = $ this -> wsdl -> getService ( ) ; $ this -> log ( 'Starting to load service ' . $ service -> getName ( ) ) ; $ this -> service = new Service ( $ this -> config , $ service -> getName ( ) , $ this -> types , $ service -> getDocumentation ( ) ) ; foreach ( $ this -> wsdl ... | Loads the service class |
46,339 | protected function loadTypes ( ) { $ this -> log ( 'Loading types' ) ; $ types = $ this -> wsdl -> getTypes ( ) ; foreach ( $ types as $ typeNode ) { $ type = null ; if ( $ typeNode -> isComplex ( ) ) { if ( $ typeNode -> isArray ( ) ) { $ type = new ArrayType ( $ this -> config , $ typeNode -> getName ( ) ) ; } else {... | Loads all type classes |
46,340 | protected function savePhp ( ) { $ factory = new FilterFactory ( ) ; $ filter = $ factory -> create ( $ this -> config ) ; $ filteredService = $ filter -> filter ( $ this -> service ) ; $ service = $ filteredService -> getClass ( ) ; $ filteredTypes = $ filteredService -> getTypes ( ) ; if ( $ service == null ) { throw... | Save all the loaded classes to the configured output dir |
46,341 | public function setElement ( $ document , $ element = null ) { if ( empty ( $ document ) ) { $ document = new DOMDocument ( ) ; $ document -> loadXML ( '<dummy/>' ) ; } $ this -> document = $ document ; if ( empty ( $ element ) ) { $ element = $ this -> document -> documentElement ; } $ this -> element = $ element ; } | Sets the document and element for the node . |
46,342 | protected function xpath ( $ query , $ args = null ) { $ xpath = new DOMXPath ( $ this -> document ) ; $ xpath -> registerNamespace ( 'wsdl' , self :: WSDL_NS ) ; $ xpath -> registerNamespace ( 's' , self :: SCHEMA_NS ) ; $ args = func_get_args ( ) ; array_shift ( $ args ) ; foreach ( $ args as & $ arg ) { if ( strpos ... | Make an XPath query against the element with escaped variables if necessary . |
46,343 | public function getSource ( ) { $ description = '' ; if ( strlen ( $ this -> description ) > 0 ) { $ preDescription = trim ( $ this -> description ) ; $ lines = explode ( PHP_EOL , $ preDescription ) ; foreach ( $ lines as $ line ) { $ description .= ' ' . trim ( '* ' . $ line ) . PHP_EOL ; } } $ tags = '' ; if ( count... | Returns the generated source |
46,344 | public function isElementNillable ( $ name ) { foreach ( $ this -> element -> getElementsByTagName ( 'element' ) as $ element ) { if ( $ element -> getAttribute ( 'name' ) == $ name && $ element -> getAttribute ( 'nillable' ) == true ) { return true ; } } return false ; } | Returns whether a sub element of the type may be undefined for the type . |
46,345 | public function getElementMinOccurs ( $ name ) { foreach ( $ this -> element -> getElementsByTagName ( 'element' ) as $ element ) { if ( $ element -> getAttribute ( 'name' ) == $ name ) { $ minOccurs = $ element -> getAttribute ( 'minOccurs' ) ; if ( $ minOccurs === '' ) { return null ; } return ( int ) $ minOccurs ; }... | Returns the minOccurs value of the element . |
46,346 | public function getBase ( ) { $ base = null ; $ extensions = $ this -> element -> getElementsByTagName ( 'extension' ) ; if ( $ extensions -> length > 0 ) { $ base = $ this -> cleanNamespace ( $ extensions -> item ( 0 ) -> getAttribute ( 'base' ) ) ; } return $ base ; } | Returns the base type for the type . |
46,347 | public function getParts ( ) { $ wsdlLines = $ this -> getWsdlLines ( ) ; $ parts = array ( ) ; if ( sizeof ( $ wsdlLines ) == 1 && substr ( $ wsdlLines [ 0 ] , - 2 , 2 ) == '[]' ) { list ( $ typeName , $ name ) = explode ( " " , $ wsdlLines [ 0 ] ) ; $ name = substr ( $ name , 0 , - 2 ) ; $ typeName .= '[]' ; $ parts ... | Returns the sub elements of the type . |
46,348 | public function getPattern ( ) { $ pattern = null ; if ( $ patternNodes = $ this -> element -> getElementsByTagName ( 'pattern' ) ) { if ( $ patternNodes -> length > 0 ) { $ pattern = $ patternNodes -> item ( 0 ) -> getAttribute ( 'value' ) ; } } return $ pattern ; } | Returns the pattern which the type represents if any . |
46,349 | public function getEnumerations ( ) { $ enums = array ( ) ; foreach ( $ this -> element -> getElementsByTagName ( 'enumeration' ) as $ enum ) { $ enums [ ] = $ enum -> getAttribute ( 'value' ) ; } ; return $ enums ; } | Returns an array of values that the type may have if the type is an enumeration . |
46,350 | public function isArray ( ) { $ parts = $ this -> getParts ( ) ; return $ this -> isComplex ( ) && count ( $ parts ) == 1 && ( substr ( $ this -> name , 0 , 7 ) == 'ArrayOf' ) && substr ( reset ( $ parts ) , - 2 , 2 ) == '[]' ; } | Returns whether the type is an array . |
46,351 | public function getDocumentation ( ) { $ documentation = null ; $ documentationNodes = $ this -> element -> getElementsByTagName ( 'documentation' ) ; if ( $ documentationNodes -> length > 0 ) { $ documentation = $ documentationNodes -> item ( 0 ) -> nodeValue ; } return $ documentation ; } | Retrieves the documentation for the node . |
46,352 | public function findTypeElement ( $ name ) { $ type = null ; $ elements = $ this -> xpath ( '//s:simpleType[@name=%s]|//s:complexType[@name=%s]' , $ name , $ name ) ; if ( $ elements -> length > 0 ) { $ type = $ elements -> item ( 0 ) ; } if ( empty ( $ type ) ) { foreach ( $ this -> referereces as $ import ) { $ type ... | Parses the schema for a type with a specific name . |
46,353 | public function getBaseTypeClass ( ) { if ( $ this -> baseType !== null && $ this -> baseType !== $ this ) { return $ this -> baseType -> getPhpIdentifier ( ) ; } return null ; } | Determine parent class |
46,354 | public function addMember ( $ type , $ name , $ nullable ) { $ this -> members [ $ name ] = new Variable ( $ type , $ name , $ nullable ) ; } | Adds the member . Owerwrites members with same name |
46,355 | protected function getBaseTypeMembers ( ComplexType $ type ) { if ( empty ( $ type -> baseType ) ) { return array ( ) ; } if ( $ type === $ type -> baseType ) { return array ( ) ; } return array_merge ( $ this -> getBaseTypeMembers ( $ type -> baseType ) , $ type -> baseType -> getMembers ( ) ) ; } | Get members from base types all the way through the type hierarchy . |
46,356 | public function save ( PhpClass $ service , array $ types ) { $ this -> setOutputDirectory ( ) ; $ this -> saveClassToFile ( $ service ) ; foreach ( $ types as $ type ) { $ this -> saveClassToFile ( $ type ) ; } $ classes = array_merge ( array ( $ service ) , $ types ) ; $ this -> saveAutoloader ( $ service -> getIdent... | Saves the service and types php code to file |
46,357 | private function setOutputDirectory ( ) { $ outputDirectory = $ this -> config -> get ( 'outputDir' ) ; if ( is_dir ( $ outputDirectory ) == false ) { if ( mkdir ( $ outputDirectory , 0777 , true ) == false ) { throw new Exception ( 'Could not create output directory and it does not exist!' ) ; } } $ this -> dir = $ ou... | Sets the output directory creates it if needed This must be called before saving a file |
46,358 | private function saveClassToFile ( PhpClass $ class ) { if ( $ this -> isValidClass ( $ class ) ) { $ file = new PhpFile ( $ class -> getIdentifier ( ) ) ; $ namespace = $ this -> config -> get ( 'namespaceName' ) ; if ( ! empty ( $ namespace ) ) { $ file -> addNamespace ( $ namespace ) ; } $ file -> addClass ( $ class... | Append a class to a file and save it If no file is created the name of the class is the filename |
46,359 | private function isValidClass ( PhpClass $ class ) { $ classNames = $ this -> config -> get ( 'classNames' ) ; return ( empty ( $ classNames ) || in_array ( $ class -> getIdentifier ( ) , $ classNames ) ) ; } | Checks if the class is approved Removes the prefix and suffix for namechecking |
46,360 | private function saveAutoloader ( $ name , array $ classes ) { $ autoloaderName = 'autoload_' . md5 ( $ name . $ this -> config -> get ( 'namespaceName' ) ) ; $ autoloadedClasses = array ( ) ; foreach ( $ classes as $ class ) { $ className = $ this -> config -> get ( 'namespaceName' ) . '\\' . $ class -> getIdentifier ... | Save a file containing an autoloader for the generated files . Developers can include this when using the generated classes . |
46,361 | public function getSource ( ) { $ ret = '<?php' . PHP_EOL . PHP_EOL ; if ( count ( $ this -> namespaces ) > 0 ) { $ ret .= 'namespace ' . $ this -> namespaces [ 0 ] . ';' . PHP_EOL . PHP_EOL ; } if ( count ( $ this -> classes ) > 0 ) { foreach ( $ this -> classes as $ class ) { $ ret .= $ class -> getSource ( ) ; } } i... | Generates the complete source code for the file |
46,362 | public function addClass ( PhpClass $ class ) { if ( $ this -> classExists ( $ class -> getIdentifier ( ) ) ) { throw new Exception ( 'A class of the name (' . $ class -> getIdentifier ( ) . ') does already exist.' ) ; } $ this -> classes [ $ class -> getIdentifier ( ) ] = $ class ; } | Adds a class to the file |
46,363 | public static function getParam ( $ dataType , $ name , $ description ) { if ( strlen ( $ name ) == 0 ) { throw new Exception ( 'A parameter must have a name!' ) ; } if ( $ name [ 0 ] == '$' ) { $ name = substr ( $ name , 1 ) ; } if ( $ dataType == 'long' ) { $ dataType = 'int' ; } elseif ( $ dataType == 'double' ) { $... | Creates a param element |
46,364 | public function create ( ConfigInterface $ config ) { $ operationNames = $ config -> get ( 'operationNames' ) ; if ( ! empty ( $ operationNames ) ) { return new ServiceOperationFilter ( $ config ) ; } else { return new DefaultFilter ( ) ; } } | Returns a filter matching the provided configuration . |
46,365 | public function getOperation ( $ operationName ) { return isset ( $ this -> operations [ $ operationName ] ) ? $ this -> operations [ $ operationName ] : null ; } | Returns an operation provided by the service based on its name . |
46,366 | public function getType ( $ identifier ) { return isset ( $ this -> types [ $ identifier ] ) ? $ this -> types [ $ identifier ] : null ; } | Returns a type used by the service based on its name . |
46,367 | private function findUsedTypes ( $ service , Type $ type ) { if ( $ type instanceof Enum ) { return array ( $ type ) ; } if ( ! $ type instanceof ComplexType ) { return array ( ) ; } $ foundTypes = array ( $ type ) ; $ baseType = $ type -> getBaseType ( ) ; if ( $ baseType ) { $ foundTypes = array_merge ( $ foundTypes ... | Function to find all needed types . |
46,368 | public function getSource ( ) { $ ret = ' * ' ; $ ret .= '@' . $ this -> type ; if ( strlen ( $ this -> datatype ) > 0 ) { $ ret .= ' ' . $ this -> datatype ; } if ( strlen ( $ this -> variableName ) > 0 ) { $ ret .= ' $' . $ this -> variableName ; } if ( strlen ( $ this -> description ) > 0 ) { $ ret .= ' ' . $ this -... | Returns the whole row of generated comment source |
46,369 | public function getSourceRow ( $ source ) { if ( strpos ( $ source , PHP_EOL ) === false ) { return $ this -> indentionStr . $ source . PHP_EOL ; } $ ret = '' ; $ rows = explode ( PHP_EOL , $ source ) ; if ( strlen ( trim ( $ rows [ 0 ] ) ) == 0 ) { $ rows = array_splice ( $ rows , 1 ) ; } if ( strlen ( trim ( $ rows [... | Takes a string and prepends ith with the current indention string Has support for multiple lines |
46,370 | public function get ( $ key ) { if ( ! array_key_exists ( $ key , $ this -> options ) ) { throw new InvalidArgumentException ( sprintf ( 'The key %s does not exist.' , $ key ) ) ; } return $ this -> options [ $ key ] ; } | Get a value from the configuration by key . |
46,371 | protected function normalizeSoapClientOptions ( Options $ options , array $ value ) { if ( ! isset ( $ value [ 'features' ] ) ) { $ value [ 'features' ] = SOAP_SINGLE_ELEMENT_ARRAYS ; } if ( ! empty ( $ options [ 'proxy' ] ) ) { $ value = array_merge ( $ options [ 'proxy' ] , $ value ) ; } return $ value ; } | Normalize the soapClientOptions configuration option . |
46,372 | protected function normalizeProxy ( Options $ options , $ value ) { if ( ! $ value ) { return false ; } if ( is_string ( $ value ) ) { $ url_parts = parse_url ( $ value ) ; if ( $ url_parts === false ) { throw new InvalidOptionsException ( '"proxy" configuration setting contains a malformed url.' ) ; } $ proxy_array = ... | Normalize the proxy configuration option . |
46,373 | public static function validateClass ( $ name , $ namespace = null ) { $ name = self :: validateNamingConvention ( $ name ) ; $ prefix = ! empty ( $ namespace ) ? $ namespace . '\\' : '' ; $ name = self :: validateUnique ( $ name , function ( $ name ) use ( $ prefix ) { $ isKeywordMethod = new \ ReflectionMethod ( __CL... | Validates a class name against PHP naming conventions and already defined classes . |
46,374 | public static function validateOperation ( $ name ) { $ name = self :: validateNamingConvention ( $ name ) ; if ( self :: isKeyword ( $ name ) ) { $ name = self :: NAME_PREFIX . ucfirst ( $ name ) ; } return $ name ; } | Validates an operation name against PHP naming conventions . |
46,375 | public static function validateConstant ( $ name ) { $ name = self :: validateNamingConvention ( $ name ) ; if ( self :: isKeyword ( $ name ) ) { $ name = self :: NAME_PREFIX . ucfirst ( $ name ) ; } return $ name ; } | Validates a constant name against PHP naming conventions . |
46,376 | public static function validateType ( $ typeName ) { if ( substr ( $ typeName , - 2 ) == "[]" ) { return self :: validateNamingConvention ( substr ( $ typeName , 0 , - 2 ) ) . "[]" ; } switch ( strtolower ( $ typeName ) ) { case "int" : case "integer" : case "long" : case "byte" : case "short" : case "negativeinteger" ... | Validates a wsdl type against known PHP primitive types or otherwise validates the namespace of the type to PHP naming conventions |
46,377 | public static function validateTypeHint ( $ typeName ) { $ typeHint = null ; if ( substr ( $ typeName , - 2 ) == "[]" ) { $ typeHint = 'array' ; } elseif ( $ typeName == '\DateTime' ) { $ typeHint = $ typeName ; } return $ typeHint ; } | Validates a type to be used as a method parameter type hint . |
46,378 | public static function validateUnique ( $ name , $ function , $ suffix = null ) { $ i = 1 ; $ newName = $ name ; while ( ! call_user_func ( $ function , $ newName ) ) { if ( ! $ suffix ) { $ newName = $ name . ( $ i + 1 ) ; } elseif ( $ i == 1 ) { $ newName = $ name . $ suffix ; } else { $ newName = $ name . $ suffix .... | Validate that a name is unique . |
46,379 | private static function validateNamingConvention ( $ name ) { $ name = iconv ( "UTF-8" , "ASCII//TRANSLIT" , $ name ) ; if ( preg_match ( '/^[A-Za-z_]/' , $ name ) == false ) { $ name = self :: NAME_PREFIX . ucfirst ( $ name ) ; } return preg_replace ( '/[^a-zA-Z0-9_x7f-xff]*/' , '' , preg_replace ( '/^[^a-zA-Z_x7f-xff... | Validates a name against standard PHP naming conventions |
46,380 | public function addDependency ( $ filename ) { if ( in_array ( $ filename , $ this -> dependencies ) == false ) { $ this -> dependencies [ ] = $ filename ; } } | Adds a dependency to be loaded for the class to use Only adds it if it does not already exist |
46,381 | public function addConstant ( $ value , $ name = '' ) { if ( strlen ( $ value ) == 0 ) { throw new Exception ( 'No value supplied' ) ; } if ( strlen ( $ name ) == 0 ) { if ( is_string ( $ value ) ) { $ name = $ value ; } else { throw new Exception ( 'No name supplied' ) ; } } if ( array_key_exists ( $ name , $ this -> ... | Adds a constant to the class . If no name is supplied and the value is a string the value is used as name otherwise exception is raised |
46,382 | public function addVariable ( PhpVariable $ variable ) { if ( $ this -> variableExists ( $ variable -> getIdentifier ( ) ) ) { throw new Exception ( 'A variable of the name (' . $ variable -> getIdentifier ( ) . ') does already exist.' ) ; } $ this -> variables [ $ variable -> getIdentifier ( ) ] = $ variable ; } | Adds a variable to the class Throws Exception if the variable does already exist |
46,383 | public function addValue ( $ value ) { if ( $ this -> datatype == 'string' ) { if ( is_string ( $ value ) == false ) { throw new InvalidArgumentException ( 'The value(' . $ value . ') is not string but the restriction demands it' ) ; } } elseif ( $ this -> datatype == 'integer' ) { if ( is_string ( $ value ) ) { $ valu... | Adds the value typechecks strings and integers . Otherwise it only checks so the value is not null |
46,384 | public function getValidValues ( ) { $ ret = '' ; foreach ( $ this -> values as $ value ) { $ ret .= $ value . ', ' ; } $ ret = substr ( $ ret , 0 , - 2 ) ; return $ ret ; } | Returns a comma separated list of all the possible values for the enum |
46,385 | public function getTypes ( ) { $ types = array ( ) ; $ typeStrings = $ this -> soapClient -> __getTypes ( ) ; foreach ( $ typeStrings as $ typeString ) { $ type = new TypeNode ( $ typeString ) ; $ element = $ this -> findTypeElement ( $ type -> getName ( ) ) ; if ( ! empty ( $ element ) ) { $ type -> setElement ( $ thi... | Returns representations of all the data types used when working with the SOAP service . |
46,386 | public function getService ( ) { $ serviceNodes = $ this -> element -> getElementsByTagName ( 'service' ) ; if ( $ serviceNodes -> length > 0 ) { return new ServiceNode ( $ this -> document , $ serviceNodes -> item ( 0 ) ) ; } return null ; } | Returns a representation of the service described by the WSDL file . |
46,387 | public function getOperations ( ) { $ functions = array ( ) ; foreach ( $ this -> soapClient -> __getFunctions ( ) as $ functionString ) { $ function = new OperationNode ( $ functionString ) ; $ functionNodes = $ this -> xpath ( '//wsdl:operation[@name=%s]' , $ function -> getName ( ) ) ; if ( $ functionNodes -> length... | Returns representations of all the operations exposed by the service . |
46,388 | public function create ( ConfigInterface $ config ) { $ options = array ( ) ; $ headers = array ( ) ; $ proxy = $ config -> get ( 'proxy' ) ; if ( is_array ( $ proxy ) ) { $ options = array ( 'http' => array ( 'proxy' => $ proxy [ 'proxy_host' ] . ':' . $ proxy [ 'proxy_port' ] ) ) ; if ( isset ( $ proxy [ 'proxy_login... | Creates a stream context based on the provided configuration . |
46,389 | public function withBody ( StreamInterface $ body ) : self { $ new = clone $ this ; return $ new -> setResponse ( $ this -> response -> withBody ( $ body ) ) ; } | Returns an instance with the specified message body . |
46,390 | protected function onSuccess ( ResponseInterface $ response , ? callable $ callback = null ) : void { if ( ! is_null ( $ callback ) ) { $ callback ( $ response ) ; } } | Handles async request success . |
46,391 | protected function onError ( Exception $ exception , ? callable $ callback = null ) : void { if ( ! is_null ( $ callback ) ) { $ callback ( $ exception ) ; } } | Handles async request failure . |
46,392 | protected function namespaceHandler ( Throwable $ exception ) : ? Throwable { if ( $ this -> namespace && $ exception instanceof ClientException ) { return $ exception -> withNamespace ( $ this -> namespace ) ; } return null ; } | Handle namespace change . |
46,393 | protected function requestExceptionHandler ( Throwable $ exception ) : ? Throwable { if ( $ exception instanceof RequestException ) { if ( $ exception -> hasResponse ( ) && $ exception -> getResponse ( ) -> hasError ( ) ) { return new BadRemoteCallException ( $ exception -> getResponse ( ) ) ; } return new ConnectionEx... | Handle request exception . |
46,394 | public function handle ( Throwable $ exception ) : void { foreach ( $ this -> handlers as $ handler ) { $ result = $ handler ( $ exception ) ; if ( $ result instanceof Throwable ) { $ exception = $ result ; } } throw $ exception ; } | Handles exception . |
46,395 | public function getCa ( ) : ? string { if ( isset ( $ this -> config [ 'ca' ] ) && is_file ( $ this -> config [ 'ca' ] ) ) { return $ this -> config [ 'ca' ] ; } return null ; } | Gets CA file from config . |
46,396 | public function getDsn ( ) : string { $ scheme = $ this -> config [ 'scheme' ] ?? 'http' ; return $ scheme . '://' . $ this -> config [ 'host' ] . ':' . $ this -> config [ 'port' ] ; } | Gets DSN string . |
46,397 | public function request ( string $ method , ... $ params ) : ResponseInterface { try { $ response = $ this -> client -> post ( $ this -> path , $ this -> makeJson ( $ method , $ params ) ) ; if ( $ response -> hasError ( ) ) { throw new BadRemoteCallException ( $ response ) ; } return $ response ; } catch ( Throwable $... | Makes request to Bitcoin Core . |
46,398 | public function requestAsync ( string $ method , $ params = [ ] , ? callable $ fulfilled = null , ? callable $ rejected = null ) : Promise \ Promise { $ promise = $ this -> client -> postAsync ( $ this -> path , $ this -> makeJson ( $ method , $ params ) ) ; $ promise -> then ( function ( $ response ) use ( $ fulfilled... | Makes async request to Bitcoin Core . |
46,399 | public function wait ( ) : void { if ( ! empty ( $ this -> promises ) ) { Promise \ settle ( $ this -> promises ) -> wait ( ) ; } } | Settle all promises . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.