idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
51,700 | public function getCustomText ( $ fallbackText = "Learn More" ) { if ( $ this -> getAllowCustomText ( ) && ! empty ( $ this -> customText ) ) { return $ this -> customText ; } $ defaultText = $ this -> getDefaultText ( ) ; return empty ( $ defaultText ) ? $ fallbackText : $ defaultText ; } | Try to use provided custom text or field default . Allows user to specify a fallback string if the custom text and default are not set . |
51,701 | public function setConfirmation ( array $ confirmation ) { if ( ! array_key_exists ( 'text' , $ confirmation ) ) { throw InvalidConfirmationHash :: missingTextField ( ) ; } $ this -> confirmation = $ confirmation ; return $ this ; } | Sets the confirmation hash for the action . |
51,702 | public function toArray ( ) : array { return [ 'name' => $ this -> name , 'text' => $ this -> text , 'type' => $ this -> type , 'value' => $ this -> value , 'style' => $ this -> style , 'confirm' => $ this -> confirmation , ] ; } | Convert this action to its array representation . |
51,703 | public function handle ( Request $ request ) : Response { $ response = $ this -> respondToSlack ( "I did not recognize this command: `/{$request->command} {$request->text}`" ) ; list ( $ command ) = explode ( ' ' , $ this -> request -> text ) ; $ alternativeHandlers = $ this -> findAlternativeHandlers ( $ command ) ; i... | Handle the given request . Remember that Slack expects a response within three seconds after the slash command was issued . If there is more time needed dispatch a job . |
51,704 | public function addFields ( array $ fields ) { collect ( $ fields ) -> each ( function ( $ field , $ key ) { if ( ! $ field instanceof AttachmentField ) { $ field = [ $ key => $ field ] ; } $ this -> addField ( $ field ) ; } ) ; return $ this ; } | Add the fields for the attachment . |
51,705 | public function addActions ( array $ actions ) { collect ( $ actions ) -> each ( function ( $ action ) { $ this -> addAction ( $ action ) ; } ) ; return $ this ; } | Add the actions for the attachment . |
51,706 | public function handle ( Request $ request ) : Response { $ handlers = $ this -> findAvailableHandlers ( ) ; if ( $ command = $ this -> getArgument ( 'command' ) ) { return $ this -> displayHelpForCommand ( $ handlers , $ command ) ; } return $ this -> displayListOfAllCommands ( $ handlers ) ; } | Handle the given request . |
51,707 | protected function findAvailableHandlers ( ) : Collection { return collect ( config ( 'laravel-slack-slash-command.handlers' ) ) -> map ( function ( string $ handlerClassName ) { return new $ handlerClassName ( $ this -> request ) ; } ) -> filter ( function ( HandlesSlashCommand $ handler ) { return $ handler instanceo... | Find all handlers that are available for the current SlashCommand and have a signature . |
51,708 | protected function displayHelpForCommand ( Collection $ handlers , string $ command ) : Response { $ helpRequest = clone $ this -> request ; $ helpRequest -> text = $ command ; $ handler = $ handlers -> filter ( function ( HandlesSlashCommand $ handler ) use ( $ helpRequest ) { return $ handler -> canHandle ( $ helpReq... | Show the help information for a single SignatureHandler . |
51,709 | protected function displayListOfAllCommands ( Collection $ handlers ) : Response { $ attachmentFields = $ handlers -> sort ( function ( SignatureHandler $ handlerA , SignatureHandler $ handlerB ) { return strcmp ( $ handlerA -> getFullCommand ( ) , $ handlerB -> getFullCommand ( ) ) ; } ) -> map ( function ( SignatureH... | Show a list of all available handlers . |
51,710 | public function getHelpDescription ( ) : string { $ inputDefinition = $ this -> inputDefinition ; $ output = new BufferedOutput ( ) ; $ name = $ this -> getFullCommand ( ) ; $ command = ( new Command ( $ name ) ) -> setDefinition ( $ inputDefinition ) -> setDescription ( $ this -> getDescription ( ) ) ; $ descriptor = ... | Get the usage description including parameters and options . |
51,711 | public function generate ( $ key ) { $ key = $ result = preg_replace ( '/[^a-zA-Z0-9]+/' , '' , $ key ) ; $ extra = sha1 ( $ _SERVER [ 'REMOTE_ADDR' ] . $ _SERVER [ 'HTTP_USER_AGENT' ] ) ; $ token = base64_encode ( time ( ) . $ extra . $ this -> randomString ( 32 ) ) ; $ this -> session -> set ( $ this -> session_prefi... | Generate a CSRF token |
51,712 | public function check ( $ key , $ token , $ timespan = null , $ multiple = false ) { $ key = $ result = preg_replace ( '/[^a-zA-Z0-9]+/' , '' , $ key ) ; if ( ! $ token ) { throw new \ Exception ( 'Missing CSRF form token.' ) ; } $ session_token = $ this -> session -> get ( $ this -> session_prefix . $ key ) ; if ( ! $... | Check the CSRF token is valid |
51,713 | public static function bootTask ( ) { if ( ! self :: isTaskBooted ( ) ) { self :: configure ( ) ; foreach ( self :: scheme ( ) as $ name => $ scheme ) { self :: registerDriver ( $ name , $ scheme ) ; } } } | Bootstrap the task . |
51,714 | protected static function initScheme ( array & $ config ) { $ config = empty ( $ config ) ? include __DIR__ . '/../config/phpsms.php' : $ config ; $ scheme = isset ( $ config [ 'scheme' ] ) ? $ config [ 'scheme' ] : [ ] ; self :: scheme ( $ scheme ) ; } | Initialize the dispatch scheme . |
51,715 | protected static function initAgentsConfig ( array $ agents , array & $ config ) { if ( empty ( $ agents ) ) { return ; } $ config = empty ( $ config ) ? include __DIR__ . '/../config/phpsms.php' : $ config ; $ agentsConfig = isset ( $ config [ 'agents' ] ) ? $ config [ 'agents' ] : [ ] ; foreach ( $ agents as $ name )... | Initialize the configuration information . |
51,716 | protected static function registerDriver ( $ name , $ scheme ) { $ settings = [ ] ; if ( is_array ( $ scheme ) ) { $ settings = self :: parseScheme ( $ scheme ) ; $ scheme = $ settings [ 'scheme' ] ; } self :: getTask ( ) -> driver ( "$name $scheme" ) -> work ( function ( Driver $ driver ) use ( $ settings ) { $ agent ... | register driver . |
51,717 | protected static function parseScheme ( array $ options ) { $ weight = Util :: pullFromArray ( $ options , 'weight' ) ; $ backup = Util :: pullFromArray ( $ options , 'backup' ) ? 'backup' : '' ; $ props = array_filter ( array_values ( $ options ) , function ( $ prop ) { return is_numeric ( $ prop ) || is_string ( $ pr... | Parse the higher - order dispatch scheme . |
51,718 | public static function getAgent ( $ name , array $ options = [ ] ) { if ( ! self :: hasAgent ( $ name ) ) { $ scheme = self :: scheme ( $ name ) ; $ config = self :: config ( $ name ) ; if ( is_array ( $ scheme ) && empty ( $ options ) ) { $ options = self :: parseScheme ( $ scheme ) ; } if ( isset ( $ options [ 'schem... | Get the agent instance by name . |
51,719 | public static function scheme ( $ name = null , $ scheme = null , $ override = false ) { if ( is_array ( $ name ) && is_bool ( $ scheme ) ) { $ override = $ scheme ; } return Util :: operateArray ( self :: $ scheme , $ name , $ scheme , null , function ( $ key , $ value ) { if ( is_string ( $ key ) ) { self :: modifySc... | Set or get the dispatch scheme . |
51,720 | protected static function modifyScheme ( $ name , $ scheme ) { self :: validateAgentName ( $ name ) ; self :: $ scheme [ $ name ] = $ scheme ; if ( self :: isTaskBooted ( ) ) { $ driver = self :: getTask ( ) -> getDriver ( $ name ) ; if ( $ driver ) { if ( is_array ( $ scheme ) ) { $ higherOrderScheme = self :: parseSc... | Modify the dispatch scheme of agent . |
51,721 | public static function config ( $ name = null , $ config = null , $ override = false ) { $ overrideAll = ( is_array ( $ name ) && is_bool ( $ config ) ) ? $ config : false ; return Util :: operateArray ( self :: $ agentsConfig , $ name , $ config , [ ] , function ( $ name , array $ config ) use ( $ override ) { self ::... | Set or get the configuration information . |
51,722 | protected static function modifyConfig ( $ name , array $ config , $ override = false ) { self :: validateAgentName ( $ name ) ; if ( ! isset ( self :: $ agentsConfig [ $ name ] ) ) { self :: $ agentsConfig [ $ name ] = [ ] ; } $ target = & self :: $ agentsConfig [ $ name ] ; if ( $ override ) { $ target = $ config ; }... | Modify the configuration information . |
51,723 | public static function make ( $ agentName = null , $ tempId = null ) { $ sms = new self ( ) ; $ sms -> type ( self :: TYPE_SMS ) ; if ( is_array ( $ agentName ) ) { $ sms -> template ( $ agentName ) ; } elseif ( $ agentName && is_string ( $ agentName ) ) { if ( $ tempId === null ) { $ sms -> content ( $ agentName ) ; }... | Create a instance for send sms . |
51,724 | public static function voice ( $ code = null ) { $ sms = new self ( ) ; $ sms -> type ( self :: TYPE_VOICE ) ; $ sms -> code ( $ code ) ; return $ sms ; } | Create a instance for send voice . |
51,725 | public static function queue ( $ enable = null , $ handler = null ) { if ( $ enable === null && $ handler === null ) { return self :: $ enableQueue ; } if ( is_callable ( $ enable ) ) { $ handler = $ enable ; $ enable = true ; } self :: $ enableQueue = ( bool ) $ enable ; if ( is_callable ( $ handler ) ) { self :: $ ho... | Set whether to use the queue system and define how to use it . |
51,726 | public function type ( $ type ) { if ( $ type !== self :: TYPE_SMS && $ type !== self :: TYPE_VOICE ) { throw new PhpSmsException ( 'Expected the parameter equals to `Sms::TYPE_SMS` or `Sms::TYPE_VOICE`.' ) ; } $ this -> smsData [ 'type' ] = $ type ; return $ this ; } | Set the type of Sms instance . |
51,727 | public function to ( $ mobile ) { if ( is_string ( $ mobile ) ) { $ mobile = trim ( $ mobile ) ; } $ this -> smsData [ 'to' ] = $ mobile ; return $ this ; } | Set the recipient s mobile number . |
51,728 | public function template ( $ name , $ tempId = null ) { Util :: operateArray ( $ this -> smsData [ 'templates' ] , $ name , $ tempId ) ; return $ this ; } | Set the template ids . |
51,729 | public function data ( $ key , $ value = null ) { Util :: operateArray ( $ this -> smsData [ 'data' ] , $ key , $ value ) ; return $ this ; } | Set the template data . |
51,730 | public function file ( $ name , $ id = null ) { Util :: operateArray ( $ this -> smsData [ 'files' ] , $ name , $ id ) ; return $ this ; } | Set voice file . |
51,731 | public function params ( $ name , $ params = null , $ override = false ) { $ overrideAll = ( is_array ( $ name ) && is_bool ( $ params ) ) ? $ params : false ; Util :: operateArray ( $ this -> smsData [ 'params' ] , $ name , $ params , [ ] , function ( $ name , array $ params ) use ( $ override ) { if ( ! isset ( $ thi... | Set params of agent . |
51,732 | public function agent ( $ name ) { if ( ! is_string ( $ name ) || empty ( $ name ) ) { throw new PhpSmsException ( 'Expected the parameter to be non-empty string.' ) ; } $ this -> firstAgent = $ name ; return $ this ; } | Set the first agent . |
51,733 | public function send ( $ immediately = false ) { if ( ! self :: $ enableQueue || $ this -> pushedToQueue ) { $ immediately = true ; } if ( $ immediately ) { return self :: $ task -> data ( $ this -> all ( ) ) -> run ( $ this -> firstAgent ) ; } return $ this -> push ( ) ; } | Start send . |
51,734 | public function push ( ) { if ( ! is_callable ( self :: $ howToUseQueue ) ) { throw new PhpSmsException ( 'Expected define how to use the queue system by methods `queue`.' ) ; } try { $ this -> pushedToQueue = true ; return call_user_func_array ( self :: $ howToUseQueue , [ $ this , $ this -> all ( ) ] ) ; } catch ( \ ... | Push to the queue system . |
51,735 | public function all ( $ key = null ) { if ( $ key !== null ) { return isset ( $ this -> smsData [ $ key ] ) ? $ this -> smsData [ $ key ] : null ; } return $ this -> smsData ; } | Get all of the data . |
51,736 | protected static function toggleSerializeScheme ( array $ scheme ) { foreach ( $ scheme as $ name => & $ options ) { if ( is_array ( $ options ) ) { foreach ( ParasiticAgent :: methods ( ) as $ method ) { self :: toggleSerializeClosure ( $ options , $ method ) ; } } } return $ scheme ; } | Serialize or deserialize the scheme . |
51,737 | protected static function serializeHandlers ( ) { $ hooks = ( array ) self :: getTask ( ) -> handlers ; foreach ( $ hooks as & $ handlers ) { foreach ( array_keys ( $ handlers ) as $ key ) { self :: toggleSerializeClosure ( $ handlers , $ key ) ; } } return $ hooks ; } | Serialize the hooks handlers . |
51,738 | protected static function reinstallHandlers ( array $ handlers ) { $ serializer = Util :: getClosureSerializer ( ) ; foreach ( $ handlers as $ hookName => $ serializedHandlers ) { foreach ( $ serializedHandlers as $ index => $ handler ) { if ( is_string ( $ handler ) ) { $ handler = $ serializer -> unserialize ( $ hand... | Reinstall hooks handlers . |
51,739 | protected static function toggleSerializeClosure ( array & $ options , $ key ) { if ( ! isset ( $ options [ $ key ] ) ) { return ; } $ serializer = Util :: getClosureSerializer ( ) ; if ( is_callable ( $ options [ $ key ] ) ) { $ options [ $ key ] = ( string ) $ serializer -> serialize ( $ options [ $ key ] ) ; } elsei... | Serialize or deserialize the specified closure and then replace the original value . |
51,740 | protected function handle ( $ name , array $ args = [ ] ) { if ( isset ( $ this -> handlers [ $ name ] ) && is_callable ( $ this -> handlers [ $ name ] ) ) { array_unshift ( $ args , $ this ) ; call_user_func_array ( $ this -> handlers [ $ name ] , $ args ) ; } } | Handle send process by closure . |
51,741 | public static function methods ( ) { if ( ! is_array ( self :: $ methods ) ) { self :: $ methods = [ ] ; $ interfaces = class_implements ( 'Toplan\\PhpSms\\ParasiticAgent' ) ; foreach ( $ interfaces as $ interface ) { self :: $ methods = array_merge ( self :: $ methods , get_class_methods ( $ interface ) ) ; } } return... | Get methods name which inherit from interfaces . |
51,742 | public function reset ( ) { $ this -> result = [ self :: SUCCESS => false , self :: INFO => null , self :: CODE => 0 , ] ; } | Reset states . |
51,743 | public function config ( $ key = null , $ value = null , $ override = false ) { if ( is_array ( $ key ) && is_bool ( $ value ) ) { $ override = $ value ; } return Util :: operateArray ( $ this -> config , $ key , $ value , null , null , $ override ) ; } | Get or set the configuration information . |
51,744 | public function sendSms ( $ to , $ content = null , $ tempId = null , array $ data = [ ] , array $ params = [ ] ) { $ this -> reset ( ) ; $ this -> params ( $ params , true ) ; $ to = $ this -> formatMobile ( Util :: formatMobiles ( $ to ) ) ; if ( $ tempId && $ this instanceof TemplateSms ) { $ this -> sendTemplateSms... | SMS send process . |
51,745 | public function sendVoice ( $ to , $ content = null , $ tempId = null , array $ data = [ ] , $ code = null , $ fileId = null , array $ params = [ ] ) { $ this -> reset ( ) ; $ this -> params ( $ params , true ) ; $ to = $ this -> formatMobile ( Util :: formatMobiles ( $ to ) ) ; if ( $ tempId && $ this instanceof Templ... | Voice send process . |
51,746 | public function formatMobile ( array $ list ) { return implode ( ',' , array_unique ( array_map ( function ( $ value ) { return is_array ( $ value ) ? "{$value['number']}" : $ value ; } , $ list ) ) ) ; } | Formatting a mobile number from the list of mobile numbers . |
51,747 | public function result ( $ name = null , $ value = null ) { if ( $ name === null ) { return $ this -> result ; } if ( array_key_exists ( $ name , $ this -> result ) ) { if ( $ value === null ) { return $ this -> result [ $ name ] ; } $ this -> result [ $ name ] = $ value ; } } | Get or set the result data . |
51,748 | public function sendTemplateSms ( $ to , $ tempId , array $ tempData ) { $ params = [ 'method' => 'alibaba.aliqin.fc.sms.num.send' , 'sms_type' => 'normal' , 'sms_free_sign_name' => $ this -> smsFreeSignName , 'sms_param' => $ this -> getTempDataString ( $ tempData ) , 'rec_num' => $ to , 'sms_template_code' => $ tempI... | Template SMS send process . |
51,749 | public function sendTemplateVoice ( $ to , $ tempId , array $ tempData ) { $ params = [ 'called_num' => $ to , 'called_show_num' => $ this -> calledShowNum , 'method' => 'alibaba.aliqin.fc.tts.num.singlecall' , 'tts_code' => $ tempId , 'tts_param' => $ this -> getTempDataString ( $ tempData ) , ] ; $ this -> request ( ... | Template voice send process . |
51,750 | public function sendVoiceCode ( $ to , $ code ) { $ params = [ 'called_num' => $ to , 'called_show_num' => $ this -> calledShowNum , 'method' => 'alibaba.aliqin.fc.voice.num.singlecall' , 'voice_code' => $ code , ] ; $ this -> request ( $ params ) ; } | Voice code send process . |
51,751 | public static function doTypesOverlap ( Schema $ schema , TypeInterface $ typeA , TypeInterface $ typeB ) : bool { if ( $ typeA === $ typeB ) { return true ; } if ( $ typeA instanceof AbstractTypeInterface ) { if ( $ typeB instanceof AbstractTypeInterface ) { return arraySome ( $ schema -> getPossibleTypes ( $ typeA ) ... | Provided two composite types determine if they overlap . Two composite types overlap when the Sets of possible concrete types for each intersect . |
51,752 | public static function compareTypes ( TypeInterface $ typeA , TypeInterface $ typeB ) : bool { if ( $ typeA instanceof ListType ) { return $ typeB instanceof ListType ? self :: compareTypes ( $ typeA -> getOfType ( ) , $ typeB -> getOfType ( ) ) : true ; } if ( $ typeB instanceof ListType ) { return true ; } if ( $ typ... | Two types conflict if both types could not apply to a value simultaneously . Composite types are ignored as their individual field types will be compared later recursively . However List and Non - Null types must match . |
51,753 | protected function readToken ( Token $ prev ) : Token { $ this -> position = $ prev -> getEnd ( ) ; $ this -> skipWhitespace ( ) ; $ line = $ this -> line ; $ column = ( 1 + $ this -> position ) - $ this -> lineStart ; if ( $ this -> position >= $ this -> bodyLength ) { return $ this -> createEndOfFileToken ( $ line , ... | Reads the token after the given token . |
51,754 | protected function lexPunctuation ( int $ code , int $ line , int $ column , Token $ prev ) : ? Token { if ( ! isset ( self :: $ codeTokenKindMap [ $ code ] ) ) { throw $ this -> createSyntaxErrorException ( ) ; } return new Token ( self :: $ codeTokenKindMap [ $ code ] , $ this -> position , $ this -> position + 1 , $... | Reads a punctuation token from the source file . |
51,755 | protected function lexName ( int $ line , int $ column , Token $ prev ) : Token { $ start = $ this -> position ; ++ $ this -> position ; while ( $ this -> position !== $ this -> bodyLength && ( $ code = $ this -> readCharCode ( $ this -> position ) ) !== 0 && isAlphaNumeric ( $ code ) ) { ++ $ this -> position ; } $ va... | Reads a name token from the source file . |
51,756 | protected function skipDigits ( int $ code ) : void { if ( isNumber ( $ code ) ) { do { $ code = $ this -> readCharCode ( ++ $ this -> position ) ; } while ( isNumber ( $ code ) ) ; return ; } throw $ this -> createSyntaxErrorException ( \ sprintf ( 'Invalid number, expected digit but got: %s.' , printCharCode ( $ code... | Skips digits at the current position . |
51,757 | protected function lexComment ( int $ line , int $ column , Token $ prev ) : Token { $ start = $ this -> position ; do { $ code = $ this -> readCharCode ( ++ $ this -> position ) ; } while ( $ code !== 0 && ( $ code > 0x001f || 0x0009 === $ code ) ) ; return new Token ( TokenKindEnum :: COMMENT , $ start , $ this -> po... | Reads a comment token from the source file . |
51,758 | protected function lexSpread ( int $ line , int $ column , Token $ prev ) : Token { return new Token ( TokenKindEnum :: SPREAD , $ this -> position , $ this -> position + 3 , $ line , $ column , $ prev ) ; } | Reads a spread token from the source . |
51,759 | protected function lexString ( int $ line , int $ column , Token $ prev ) : Token { $ start = $ this -> position ; $ chunkStart = ++ $ this -> position ; $ value = '' ; while ( $ this -> position < $ this -> bodyLength ) { $ code = $ this -> readCharCode ( $ this -> position ) ; if ( isLineTerminator ( $ code ) ) { bre... | Reads a string token from the source . |
51,760 | protected function lexBlockString ( int $ line , int $ column , Token $ prev ) : Token { $ start = $ this -> position ; $ this -> position = $ start + 3 ; $ chunkStart = $ this -> position ; $ rawValue = '' ; while ( $ this -> position < $ this -> bodyLength ) { $ code = $ this -> readCharCode ( $ this -> position ) ; ... | Reads a block string token from the source file . |
51,761 | protected function skipWhitespace ( ) : void { while ( $ this -> position < $ this -> bodyLength ) { $ code = $ this -> readCharCode ( $ this -> position ) ; if ( 9 === $ code || 32 === $ code || 44 === $ code || 0xfeff === $ code ) { ++ $ this -> position ; } elseif ( 10 === $ code ) { ++ $ this -> position ; ++ $ thi... | Skips whitespace at the current position . |
51,762 | protected function unexpectedCharacterMessage ( int $ code ) : string { if ( isSourceCharacter ( $ code ) && ! isLineTerminator ( $ code ) ) { return \ sprintf ( 'Cannot contain the invalid character %s.' , printCharCode ( $ code ) ) ; } if ( $ code === 39 ) { return 'Unexpected single quote character (\'), did you mea... | Report a message that an unexpected character was encountered . |
51,763 | protected function detectFragmentCycle ( FragmentDefinitionNode $ fragment ) : void { $ fragmentName = $ fragment -> getNameValue ( ) ; $ this -> visitedFragments [ $ fragmentName ] = true ; $ spreadNodes = $ this -> context -> getFragmentSpreads ( $ fragment -> getSelectionSet ( ) ) ; if ( empty ( $ spreadNodes ) ) { ... | This does a straight - forward DFS to find cycles . It does not terminate when a cycle was found but continues to explore the graph to find all possible cycles . |
51,764 | public static function isValidError ( string $ name , $ node = null ) : ? ValidationException { if ( \ strlen ( $ name ) > 1 && $ name { 0 } === '_' && $ name { 1 } === '_' ) { return new ValidationException ( sprintf ( 'Name "%s" must not begin with "__", which is reserved by GraphQL introspection.' , $ name ) , $ nod... | Returns an Error if a name is invalid . |
51,765 | protected function registerProviders ( Container $ container ) : void { foreach ( self :: $ providers as $ className ) { $ container -> addServiceProvider ( $ className ) ; } } | Registers the service provides with the container . |
51,766 | protected function resolveField ( ObjectType $ parentType , $ rootValue , array $ fieldNodes , array $ path ) { $ fieldNode = $ fieldNodes [ 0 ] ; $ fieldName = $ fieldNode -> getNameValue ( ) ; $ field = $ this -> getFieldDefinition ( $ this -> context -> getSchema ( ) , $ parentType , $ fieldName ) ; if ( null === $ ... | Resolves the field on the given source object . In particular this figures out the value that the field returns by calling its resolve function then calls completeValue to complete promises serialize scalars or execute the sub - selection - set for objects . |
51,767 | protected function normalizeException ( $ exception , array $ nodes , array $ path = [ ] ) : ExecutionException { if ( $ exception instanceof \ Throwable ) { return new ExecutionException ( $ exception -> getMessage ( ) , $ nodes , null , null , $ path , null , $ exception ) ; } if ( \ is_string ( $ exception ) ) { ret... | Normalizes exceptions which are usually a \ Throwable but can even be a string or null when resolving promises . |
51,768 | public function completeValueCatchingError ( TypeInterface $ returnType , array $ fieldNodes , ResolveInfo $ info , array $ path , & $ result ) { try { $ completed = $ result instanceof PromiseInterface ? $ result -> then ( function ( $ resolvedResult ) use ( $ returnType , $ fieldNodes , $ info , $ path ) { return $ t... | This is a small wrapper around completeValue which detects and logs error in the execution context . |
51,769 | public static function defaultFieldResolver ( $ rootValue , array $ arguments , $ contextValues , ResolveInfo $ info ) { $ fieldName = $ info -> getFieldName ( ) ; $ property = null ; if ( \ is_array ( $ rootValue ) && isset ( $ rootValue [ $ fieldName ] ) ) { $ property = $ rootValue [ $ fieldName ] ; } if ( \ is_obje... | Try to resolve a field without any field resolver function . |
51,770 | public function coerceDirectiveValues ( Directive $ directive , $ node , array $ variableValues = [ ] ) : ? array { $ directiveNode = $ node -> hasDirectives ( ) ? find ( $ node -> getDirectives ( ) , function ( NameAwareInterface $ value ) use ( $ directive ) { return $ value -> getNameValue ( ) === $ directive -> get... | Prepares an object map of argument values given a directive definition and a AST node which may contain directives . Optionally also accepts a map of variable values . |
51,771 | public function coerceVariableValues ( Schema $ schema , array $ variableDefinitionNodes , array $ inputs ) : CoercedValue { $ coercedValues = [ ] ; $ errors = [ ] ; foreach ( $ variableDefinitionNodes as $ variableDefinitionNode ) { $ variableName = $ variableDefinitionNode -> getVariable ( ) -> getNameValue ( ) ; $ v... | Prepares an object map of variableValues of the correct type based on the provided variable definitions and arbitrary input . If the input cannot be parsed to match the variable definitions a GraphQLError will be thrown . |
51,772 | private function coerceValue ( $ value , $ type , $ blameNode , ? Path $ path = null ) : CoercedValue { if ( $ type instanceof NonNullType ) { return $ this -> coerceValueForNonNullType ( $ value , $ type , $ blameNode , $ path ) ; } if ( null === $ value ) { return new CoercedValue ( null ) ; } if ( $ type instanceof ... | Returns either a value which is valid for the provided type or a list of encountered coercion errors . |
51,773 | public function parse ( Source $ source , array $ options = [ ] ) : DocumentNode { $ this -> lexer = $ this -> createLexer ( $ source , $ options ) ; return $ this -> lexDocument ( ) ; } | Given a GraphQL source parses it into a Document . Throws GraphQLError if a syntax error is encountered . |
51,774 | protected function skip ( string $ kind ) : bool { if ( $ match = $ this -> peek ( $ kind ) ) { $ this -> lexer -> advance ( ) ; } return $ match ; } | If the next token is of the given kind return true after advancing the lexer . Otherwise do not change the parser state and return false . |
51,775 | protected function expect ( string $ kind ) : Token { $ token = $ this -> lexer -> getToken ( ) ; if ( $ kind === $ token -> getKind ( ) ) { $ this -> lexer -> advance ( ) ; return $ token ; } throw $ this -> lexer -> createSyntaxErrorException ( \ sprintf ( 'Expected %s, found %s.' , $ kind , $ token ) ) ; } | If the next token is of the given kind return that token after advancing the lexer . Otherwise do not change the parser state and throw an error . |
51,776 | protected function unexpected ( ? Token $ atToken = null ) : SyntaxErrorException { $ token = $ atToken ?? $ this -> lexer -> getToken ( ) ; return $ this -> lexer -> createSyntaxErrorException ( \ sprintf ( 'Unexpected %s' , $ token ) ) ; } | Helper function for creating an error when an unexpected lexed token is encountered . |
51,777 | protected function any ( string $ openKind , callable $ parseFunction , string $ closeKind ) : array { $ this -> expect ( $ openKind ) ; $ nodes = [ ] ; while ( ! $ this -> skip ( $ closeKind ) ) { $ nodes [ ] = $ parseFunction ( ) ; } return $ nodes ; } | Returns a possibly empty list of parse nodes determined by the parseFn . This list begins with a lex token of openKind and ends with a lex token of closeKind . Advances the parser to the next lex token after the closing token . |
51,778 | public static function convert ( $ value , TypeInterface $ type ) : ? ValueNodeInterface { if ( $ type instanceof NonNullType ) { $ node = self :: convert ( $ value , $ type -> getOfType ( ) ) ; return null !== $ node && $ node -> getKind ( ) === NodeKindEnum :: NULL ? null : $ node ; } if ( null === $ value ) { return... | Produces a GraphQL Value AST given a PHP value . |
51,779 | protected function isValidScalar ( ValueNodeInterface $ node ) : void { $ locationType = $ this -> context -> getInputType ( ) ; if ( null === $ locationType ) { return ; } $ type = getNamedType ( $ locationType ) ; if ( ! ( $ type instanceof ScalarType ) ) { $ didYouMean = $ this -> getEnumTypeSuggestion ( $ type , $ ... | Any value literal may be a valid representation of a Scalar depending on that scalar type . |
51,780 | public static function convert ( ? NodeInterface $ node , TypeInterface $ type , array $ variables = [ ] ) { if ( null === $ node ) { throw new ConversionException ( 'Node is not defined.' ) ; } if ( $ type instanceof NonNullType ) { return self :: convertNonNullType ( $ node , $ type , $ variables ) ; } if ( $ node in... | Produces a PHP value given a GraphQL Value AST . |
51,781 | protected function registerMetaFields ( ) { $ this -> container -> share ( GraphQL :: SCHEMA_META_FIELD_DEFINITION , function ( $ __Schema ) { return newField ( [ 'name' => '__schema' , 'description' => 'Access the current type schema of this server.' , 'type' => newNonNull ( $ __Schema ) , 'resolve' => function ( $ so... | Registers the introspection meta fields with the container . |
51,782 | protected function collectConflictsBetweenFieldsAndFragment ( ComparisonContext $ context , array & $ comparedFragments , array $ fieldMap , string $ fragmentName , bool $ areMutuallyExclusive ) : void { if ( isset ( $ comparedFragments [ $ fragmentName ] ) ) { return ; } $ comparedFragments [ $ fragmentName ] = true ;... | Collect all conflicts found between a set of fields and a fragment reference including via spreading in any nested fragments . |
51,783 | protected function collectConflictsBetweenFragments ( ComparisonContext $ context , string $ fragmentNameA , string $ fragmentNameB , bool $ areMutuallyExclusive ) : void { if ( $ fragmentNameA === $ fragmentNameB ) { return ; } if ( $ this -> comparedFragmentPairs -> has ( $ fragmentNameA , $ fragmentNameB , $ areMutu... | Collect all conflicts found between two fragments including via spreading in any nested fragments . |
51,784 | protected function findConflictsBetweenSubSelectionSets ( ? NamedTypeInterface $ parentTypeA , SelectionSetNode $ selectionSetA , ? NamedTypeInterface $ parentTypeB , SelectionSetNode $ selectionSetB , bool $ areMutuallyExclusive ) : array { $ context = new ComparisonContext ( ) ; $ contextA = $ this -> getFieldsAndFra... | Find all conflicts found between two selection sets including those found via spreading in fragments . Called when determining if conflicts exist between the sub - fields of two overlapping fields . |
51,785 | protected function collectConflictsWithin ( ComparisonContext $ context ) : void { foreach ( $ context -> getFieldMap ( ) as $ responseName => $ fields ) { $ fieldsCount = \ count ( $ fields ) ; if ( $ fieldsCount > 1 ) { for ( $ i = 0 ; $ i < $ fieldsCount ; $ i ++ ) { for ( $ j = $ i + 1 ; $ j < $ fieldsCount ; $ j +... | Collect all Conflicts within one collection of fields . |
51,786 | protected function collectConflictsBetween ( ComparisonContext $ context , array $ fieldMapA , array $ fieldMapB , bool $ parentFieldsAreMutuallyExclusive ) : void { foreach ( $ fieldMapA as $ responseName => $ fieldsA ) { $ fieldsB = $ fieldMapB [ $ responseName ] ?? null ; if ( null !== $ fieldsB ) { $ fieldsACount =... | Collect all Conflicts between two collections of fields . This is similar to but different from the collectConflictsWithin function above . This check assumes that collectConflictsWithin has already been called on each provided collection of fields . This is true because this validator traverses each individual selecti... |
51,787 | protected function findConflict ( string $ responseName , FieldContext $ fieldA , FieldContext $ fieldB , bool $ parentFieldsAreMutuallyExclusive ) : ? Conflict { $ parentTypeA = $ fieldA -> getParentType ( ) ; $ parentTypeB = $ fieldB -> getParentType ( ) ; $ areMutuallyExclusive = $ parentFieldsAreMutuallyExclusive |... | Determines if there is a conflict between two particular fields including comparing their sub - fields . |
51,788 | protected function getReferencedFieldsAndFragmentNames ( FragmentDefinitionNode $ fragment ) : ComparisonContext { if ( $ this -> cachedFieldsAndFragmentNames -> offsetExists ( $ fragment ) ) { return $ this -> cachedFieldsAndFragmentNames -> offsetGet ( $ fragment ) ; } $ fragmentType = TypeASTConverter :: convert ( $... | Given a reference to a fragment return the represented collection of fields as well as a list of nested fragment names referenced via fragment spreads . |
51,789 | protected function subfieldConflicts ( array $ conflicts , string $ responseName , FieldNode $ nodeA , FieldNode $ nodeB ) : ? Conflict { if ( empty ( $ conflicts ) ) { return null ; } return new Conflict ( $ responseName , array_map ( function ( Conflict $ conflict ) { return [ $ conflict -> getResponseName ( ) , $ co... | Given a series of Conflicts which occurred between two sub - fields generate a single Conflict . |
51,790 | protected function getSuggestedTypeNames ( Schema $ schema , TypeInterface $ type , string $ fieldName ) : array { if ( ! $ type instanceof AbstractTypeInterface ) { return [ ] ; } $ suggestedObjectTypes = [ ] ; $ interfaceUsageCount = [ ] ; foreach ( $ schema -> getPossibleTypes ( $ type ) as $ possibleType ) { if ( !... | Go through all of the implementations of type as well as the interfaces that they implement . If any of those types include the provided field suggest them sorted by how often the type is referenced starting with Interfaces . |
51,791 | protected function getSuggestedFieldNames ( OutputTypeInterface $ type , string $ fieldName ) : array { if ( ! ( $ type instanceof ObjectType || $ type instanceof InterfaceType ) ) { return [ ] ; } $ possibleFieldNames = \ array_keys ( $ type -> getFields ( ) ) ; return suggestionList ( $ fieldName , $ possibleFieldNam... | For the field name provided determine if there are any similar field names that may be the result of a typo . |
51,792 | protected function createLocation ( array $ ast ) : ? Location { return isset ( $ ast [ 'loc' ] [ 'start' ] , $ ast [ 'loc' ] [ 'end' ] ) ? new Location ( $ ast [ 'loc' ] [ 'start' ] , $ ast [ 'loc' ] [ 'end' ] , $ ast [ 'loc' ] [ 'source' ] ?? null ) : null ; } | Creates a location object . |
51,793 | protected function buildNode ( array $ ast , string $ propertyName ) : ? NodeInterface { return isset ( $ ast [ $ propertyName ] ) ? $ this -> build ( $ ast [ $ propertyName ] ) : null ; } | Builds a single item from the given AST . |
51,794 | protected function buildNodes ( array $ ast , string $ propertyName ) : array { $ array = [ ] ; if ( isset ( $ ast [ $ propertyName ] ) && \ is_array ( $ ast [ $ propertyName ] ) ) { foreach ( $ ast [ $ propertyName ] as $ subAst ) { $ array [ ] = $ this -> build ( $ subAst ) ; } } return $ array ; } | Builds many items from the given AST . |
51,795 | public static function build ( ) : array { $ rules = [ ] ; foreach ( self :: $ supportedRules as $ className ) { $ rules [ ] = GraphQL :: make ( $ className ) ; } return $ rules ; } | Rules maintain state so they should always new instances . |
51,796 | protected function getEffectiveType ( TypeInterface $ variableType , VariableDefinitionNode $ variableDefinition ) : TypeInterface { return ( ! $ variableDefinition -> hasDefaultValue ( ) || $ variableType instanceof NonNullType ) ? $ variableType : newNonNull ( $ variableType ) ; } | If a variable definition has a default value it s effectively non - null . |
51,797 | public function build ( ) { $ this -> createPathDirectories ( ) ; if ( ! is_file ( $ this -> createSupervisorConfigurationFilePath ( ) ) ) { $ this -> generateSupervisorConfiguration ( ) ; } foreach ( new \ DirectoryIterator ( $ this -> paths [ 'worker_configuration_directory' ] ) as $ item ) { if ( $ item -> isDir ( )... | Build all supervisor worker configuration files |
51,798 | public function kill ( $ signal = '' , $ waitForProcessToDisappear = false ) { $ pid = $ this -> getSupervisorPid ( ) ; if ( ! empty ( $ pid ) && $ this -> isProcessRunning ( $ pid ) ) { if ( ! empty ( $ signal ) ) { $ signal = sprintf ( '-%s' , $ signal ) ; } $ command = sprintf ( 'kill %s %d' , $ signal , $ pid ) ; p... | Send kill signal to supervisord |
51,799 | public function wait ( ) { $ pid = $ this -> getSupervisorPid ( ) ; if ( ! empty ( $ pid ) ) { while ( $ this -> isProcessRunning ( $ pid ) ) { sleep ( 1 ) ; } } } | Wait for supervisord process to disappear |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.