idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
6,800
|
public function setResult ( $ result ) : self { $ this -> _result = $ result ; $ this -> _hasResult = true ; return $ this ; }
|
Set result associated with this event .
|
6,801
|
public function getName ( ) { if ( $ this -> _name === null ) { $ this -> _name = $ this -> defaultName ( ) ; } return $ this -> _name ; }
|
Returns event name .
|
6,802
|
public function fromArray ( array $ array ) { $ this -> removeAll ( ) ; foreach ( $ array as $ name => $ values ) { if ( \ is_array ( $ values ) ) { foreach ( $ values as $ value ) { $ this -> add ( $ name , $ value ) ; } } else { $ this -> add ( $ name , $ values ) ; } } }
|
Populates the header collection from an array .
|
6,803
|
public static function createObject ( $ config , array $ params = [ ] , ContainerInterface $ container = null ) { return static :: get ( 'factory' , $ container ) -> create ( $ config , $ params ) ; }
|
Creates a new object using the given configuration and constructor parameters .
|
6,804
|
public static function log ( $ level , $ message , $ category = 'application' ) { if ( LogLevel :: DEBUG === $ level && ! YII_DEBUG ) { return ; } $ logger = static :: get ( 'logger' , null , false ) ; if ( $ logger ) { return $ logger -> log ( $ level , $ message , [ 'category' => $ category ] ) ; } error_log ( $ message ) ; }
|
Logs given message with level and category .
|
6,805
|
public static function getLocaleString ( string $ default = 'en-US' ) : string { $ i18n = static :: get ( 'i18n' , null , false ) ; return $ i18n ? ( string ) $ i18n -> getLocale ( ) : $ default ; }
|
Returns current locale if set or default .
|
6,806
|
public static function getSourceLocaleString ( string $ default = 'en-US' ) : string { $ view = static :: get ( 'view' , null , false ) ; return $ view ? ( string ) $ view -> getSourceLocale ( ) : $ default ; }
|
Returns current source locale if set or default .
|
6,807
|
public static function getTimeZone ( string $ default = 'UTC' ) : string { $ i18n = static :: get ( 'i18n' , null , false ) ; return $ i18n ? ( string ) $ i18n -> getTimeZone ( ) : $ default ; }
|
Returns current timezone if set or default .
|
6,808
|
public static function getEncoding ( ContainerInterface $ container = null ) : string { $ i18n = static :: get ( 'i18n' , $ container , false ) ; return $ i18n ? $ i18n -> getEncoding ( ) : mb_internal_encoding ( ) ; }
|
Returns current application encoding .
|
6,809
|
public static function get ( string $ name , ContainerInterface $ container = null , bool $ throwException = true ) { if ( $ container === null ) { $ container = static :: $ container ; } if ( $ container !== null && $ container -> has ( $ name ) ) { return static :: $ container -> get ( $ name ) ; } if ( $ throwException ) { throw new InvalidConfigException ( "No '$name' service can be found" ) ; } else { return null ; } }
|
Returns service from container .
|
6,810
|
protected function decrypt ( $ data , $ passwordBased , $ secret , $ info ) { if ( ! extension_loaded ( 'openssl' ) ) { throw new InvalidConfigException ( 'Encryption requires the OpenSSL PHP extension' ) ; } if ( ! isset ( $ this -> allowedCiphers [ $ this -> cipher ] [ 0 ] , $ this -> allowedCiphers [ $ this -> cipher ] [ 1 ] ) ) { throw new InvalidConfigException ( $ this -> cipher . ' is not an allowed cipher' ) ; } [ $ blockSize , $ keySize ] = $ this -> allowedCiphers [ $ this -> cipher ] ; $ keySalt = StringHelper :: byteSubstr ( $ data , 0 , $ keySize ) ; if ( $ passwordBased ) { $ key = $ this -> pbkdf2 ( $ this -> kdfHash , $ secret , $ keySalt , $ this -> derivationIterations , $ keySize ) ; } else { $ key = $ this -> hkdf ( $ this -> kdfHash , $ secret , $ keySalt , $ info , $ keySize ) ; } $ authKey = $ this -> hkdf ( $ this -> kdfHash , $ key , null , $ this -> authKeyInfo , $ keySize ) ; $ data = $ this -> validateData ( StringHelper :: byteSubstr ( $ data , $ keySize ) , $ authKey ) ; if ( $ data === false ) { return false ; } $ iv = StringHelper :: byteSubstr ( $ data , 0 , $ blockSize ) ; $ encrypted = StringHelper :: byteSubstr ( $ data , $ blockSize ) ; $ decrypted = openssl_decrypt ( $ encrypted , $ this -> cipher , $ key , OPENSSL_RAW_DATA , $ iv ) ; if ( $ decrypted === false ) { throw new \ yii \ exceptions \ Exception ( 'OpenSSL failure on decryption: ' . openssl_error_string ( ) ) ; } return $ decrypted ; }
|
Decrypts data .
|
6,811
|
public function createController ( $ route ) { if ( $ route === '' ) { $ route = $ this -> defaultRoute ; } $ route = trim ( $ route , '/' ) ; if ( strpos ( $ route , '//' ) !== false ) { return false ; } if ( strpos ( $ route , '/' ) !== false ) { [ $ id , $ route ] = explode ( '/' , $ route , 2 ) ; } else { $ id = $ route ; $ route = '' ; } if ( isset ( $ this -> controllerMap [ $ id ] ) ) { $ controller = $ this -> app -> createObject ( $ this -> controllerMap [ $ id ] , [ $ id , $ this ] ) ; return [ $ controller , $ route ] ; } $ module = $ this -> getModule ( $ id ) ; if ( $ module !== null ) { return $ module -> createController ( $ route ) ; } if ( ( $ pos = strrpos ( $ route , '/' ) ) !== false ) { $ id .= '/' . substr ( $ route , 0 , $ pos ) ; $ route = substr ( $ route , $ pos + 1 ) ; } $ controller = $ this -> createControllerByID ( $ id ) ; if ( $ controller === null && $ route !== '' ) { $ controller = $ this -> createControllerByID ( $ id . '/' . $ route ) ; $ route = '' ; } return $ controller === null ? false : [ $ controller , $ route ] ; }
|
Creates a controller instance based on the given route .
|
6,812
|
public function get ( $ id , bool $ throwException = true ) { if ( ! $ this -> _container -> has ( $ id ) ) { if ( $ throwException ) { throw new InvalidConfigException ( "Unknown component ID: $id" ) ; } return null ; } return $ this -> _container -> get ( $ id ) ; }
|
Returns instance from DI by ID .
|
6,813
|
public function getHeaderCollection ( ) { if ( $ this -> _headerCollection === null ) { $ headerCollection = new HeaderCollection ( ) ; $ headerCollection -> fromArray ( $ this -> defaultHeaders ( ) ) ; $ this -> _headerCollection = $ headerCollection ; } return $ this -> _headerCollection ; }
|
Returns the header collection . The header collection contains the currently registered HTTP headers .
|
6,814
|
public function setHeaders ( $ headers ) { $ headerCollection = $ this -> getHeaderCollection ( ) ; $ headerCollection -> removeAll ( ) ; $ headerCollection -> fromArray ( $ headers ) ; }
|
Sets up message s headers at batch removing any previously existing ones .
|
6,815
|
public function withBody ( StreamInterface $ body ) { if ( $ this -> getBody ( ) === $ body ) { return $ this ; } $ newInstance = clone $ this ; $ newInstance -> setBody ( $ body ) ; return $ newInstance ; }
|
Return an instance with the specified message body . This method retains the immutability of the message and returns an instance that has the new body stream .
|
6,816
|
public static function canonical ( ) { $ params = Yii :: getApp ( ) -> controller -> actionParams ; $ params [ 0 ] = Yii :: getApp ( ) -> controller -> getRoute ( ) ; return static :: getUrlManager ( ) -> createAbsoluteUrl ( $ params ) ; }
|
Returns the canonical URL of the currently requested page .
|
6,817
|
public static function beginTag ( $ name , $ options = [ ] ) { if ( $ name === null || $ name === false ) { return '' ; } return '<' . $ name . static :: renderTagAttributes ( $ options ) . '>' ; }
|
Generates a start tag .
|
6,818
|
public static function getInputId ( $ model , $ attribute ) { $ name = strtolower ( static :: getInputName ( $ model , $ attribute ) ) ; return str_replace ( [ '[]' , '][' , '[' , ']' , ' ' , '.' ] , [ '' , '-' , '-' , '' , '-' , '-' ] , $ name ) ; }
|
Generates an appropriate input ID for the specified attribute name or expression .
|
6,819
|
public function set ( string $ alias , ? string $ path ) : void { if ( strncmp ( $ alias , '@' , 1 ) ) { $ alias = '@' . $ alias ; } $ pos = strpos ( $ alias , '/' ) ; $ root = $ pos === false ? $ alias : substr ( $ alias , 0 , $ pos ) ; if ( $ path !== null ) { $ path = strncmp ( $ path , '@' , 1 ) ? rtrim ( $ path , '\\/' ) : $ this -> get ( $ path ) ; if ( ! isset ( $ this -> aliases [ $ root ] ) ) { if ( $ pos === false ) { $ this -> aliases [ $ root ] = $ path ; } else { $ this -> aliases [ $ root ] = [ $ alias => $ path ] ; } } elseif ( \ is_string ( $ this -> aliases [ $ root ] ) ) { if ( $ pos === false ) { $ this -> aliases [ $ root ] = $ path ; } else { $ this -> aliases [ $ root ] = [ $ alias => $ path , $ root => $ this -> aliases [ $ root ] , ] ; } } else { $ this -> aliases [ $ root ] [ $ alias ] = $ path ; krsort ( $ this -> aliases [ $ root ] ) ; } } elseif ( isset ( $ this -> aliases [ $ root ] ) ) { if ( \ is_array ( $ this -> aliases [ $ root ] ) ) { unset ( $ this -> aliases [ $ root ] [ $ alias ] ) ; } elseif ( $ pos === false ) { unset ( $ this -> aliases [ $ root ] ) ; } } }
|
Registers a path alias .
|
6,820
|
public function getSizeLimit ( ) { $ limit = $ this -> sizeToBytes ( ini_get ( 'upload_max_filesize' ) ) ; $ postLimit = $ this -> sizeToBytes ( ini_get ( 'post_max_size' ) ) ; if ( $ postLimit > 0 && $ postLimit < $ limit ) { Yii :: warning ( 'PHP.ini\'s \'post_max_size\' is less than \'upload_max_filesize\'.' , __METHOD__ ) ; $ limit = $ postLimit ; } if ( $ this -> maxSize !== null && $ limit > 0 && $ this -> maxSize < $ limit ) { $ limit = $ this -> maxSize ; } if ( ( $ request = Yii :: getApp ( ) -> getRequest ( ) ) instanceof \ yii \ web \ Request ) { $ maxFileSize = Yii :: getApp ( ) -> getRequest ( ) -> getParsedBodyParam ( 'MAX_FILE_SIZE' , 0 ) ; if ( $ maxFileSize > 0 && $ maxFileSize < $ limit ) { $ limit = ( int ) $ maxFileSize ; } } return $ limit ; }
|
Returns the maximum size allowed for uploaded files .
|
6,821
|
public static function unlink ( $ path ) : bool { $ isWindows = DIRECTORY_SEPARATOR === '\\' ; if ( ! $ isWindows ) { return unlink ( $ path ) ; } if ( is_link ( $ path ) && is_dir ( $ path ) ) { return rmdir ( $ path ) ; } return unlink ( $ path ) ; }
|
Removes a file or symlink in a cross - platform way
|
6,822
|
private static function firstWildcardInPattern ( $ pattern ) { $ wildcards = [ '*' , '?' , '[' , '\\' ] ; $ wildcardSearch = function ( $ carry , $ item ) use ( $ pattern ) { $ position = strpos ( $ pattern , $ item ) ; if ( $ position === false ) { return $ carry === false ? $ position : $ carry ; } return $ carry === false ? $ position : min ( $ carry , $ position ) ; } ; return array_reduce ( $ wildcards , $ wildcardSearch , false ) ; }
|
Searches for the first wildcard character in the pattern .
|
6,823
|
public function debug ( $ message , string $ category = 'application' ) : void { $ this -> log ( LogLevel :: DEBUG , $ message , $ category ) ; }
|
Logs a debug message . Trace messages are logged mainly for development purpose to see the execution work flow of some code .
|
6,824
|
public function log ( string $ level , $ message , $ category = 'application' ) : void { $ this -> getLogger ( ) -> log ( $ level , $ message , [ 'category' => $ category ] ) ; }
|
Logs given message through logger service .
|
6,825
|
public function setBasePath ( $ path ) { parent :: setBasePath ( $ path ) ; $ this -> setAlias ( '@app' , $ this -> getBasePath ( ) ) ; if ( empty ( $ this -> getAlias ( '@root' , false ) ) ) { $ this -> setAlias ( '@root' , dirname ( __DIR__ , 5 ) ) ; } }
|
Sets the root directory of the application and the
|
6,826
|
public function run ( ) { if ( YII_ENABLE_ERROR_HANDLER ) { $ this -> get ( 'errorHandler' ) -> register ( ) ; } try { $ this -> state = self :: STATE_BEFORE_REQUEST ; $ this -> trigger ( RequestEvent :: BEFORE ) ; $ this -> state = self :: STATE_HANDLING_REQUEST ; $ this -> response = $ this -> handleRequest ( $ this -> getRequest ( ) ) ; $ this -> state = self :: STATE_AFTER_REQUEST ; $ this -> trigger ( RequestEvent :: AFTER ) ; $ this -> state = self :: STATE_SENDING_RESPONSE ; $ this -> response -> send ( ) ; $ this -> state = self :: STATE_END ; return $ this -> response -> exitStatus ; } catch ( ExitException $ e ) { $ this -> end ( $ e -> statusCode , $ this -> response ?? null ) ; return $ e -> statusCode ; } }
|
Runs the application . This is the main entrance of an application .
|
6,827
|
public function asNtext ( $ value ) { if ( $ value === null ) { return $ this -> getNullDisplay ( ) ; } return nl2br ( Html :: encode ( $ value ) ) ; }
|
Formats the value as an HTML - encoded plain text with newlines converted into breaks .
|
6,828
|
public function asImage ( $ value , $ options = [ ] ) { if ( $ value === null ) { return $ this -> getNullDisplay ( ) ; } return Html :: img ( $ value , $ options ) ; }
|
Formats the value as an image tag .
|
6,829
|
public function asBoolean ( $ value ) { if ( $ value === null ) { return $ this -> getNullDisplay ( ) ; } return $ value ? $ this -> getBooleanFormat ( ) [ 1 ] : $ this -> getBooleanFormat ( ) [ 0 ] ; }
|
Formats the value as a boolean .
|
6,830
|
public function asScientific ( $ value , $ decimals = null , $ options = [ ] , $ textOptions = [ ] ) { if ( $ value === null ) { return $ this -> getNullDisplay ( ) ; } $ value = $ this -> normalizeNumericValue ( $ value ) ; if ( $ this -> _intlLoaded ) { $ f = $ this -> createNumberFormatter ( NumberFormatter :: SCIENTIFIC , $ decimals , $ options , $ textOptions ) ; if ( ( $ result = $ f -> format ( $ value ) ) === false ) { throw new InvalidArgumentException ( 'Formatting scientific number value failed: ' . $ f -> getErrorCode ( ) . ' ' . $ f -> getErrorMessage ( ) ) ; } return $ result ; } if ( $ decimals !== null ) { return sprintf ( "%.{$decimals}E" , $ value ) ; } return sprintf ( '%.E' , $ value ) ; }
|
Formats the value as a scientific number .
|
6,831
|
public function asCurrency ( $ value , $ currency = null , $ options = [ ] , $ textOptions = [ ] ) { if ( $ value === null ) { return $ this -> getNullDisplay ( ) ; } $ normalizedValue = $ this -> normalizeNumericValue ( $ value ) ; if ( $ this -> isNormalizedValueMispresented ( $ value , $ normalizedValue ) ) { return $ this -> asCurrencyStringFallback ( ( string ) $ value , $ currency ) ; } if ( $ this -> _intlLoaded ) { $ currency = $ currency ? : $ this -> currencyCode ; if ( $ currency && ! isset ( $ textOptions [ NumberFormatter :: CURRENCY_CODE ] ) ) { $ textOptions [ NumberFormatter :: CURRENCY_CODE ] = $ currency ; } $ formatter = $ this -> createNumberFormatter ( NumberFormatter :: CURRENCY , null , $ options , $ textOptions ) ; if ( $ currency === null ) { $ result = $ formatter -> format ( $ normalizedValue ) ; } else { $ result = $ formatter -> formatCurrency ( $ normalizedValue , $ currency ) ; } if ( $ result === false ) { throw new InvalidArgumentException ( 'Formatting currency value failed: ' . $ formatter -> getErrorCode ( ) . ' ' . $ formatter -> getErrorMessage ( ) ) ; } return $ result ; } if ( $ currency === null ) { if ( $ this -> currencyCode === null ) { throw new InvalidConfigException ( 'The default currency code for the formatter is not defined and the php intl extension is not installed which could take the default currency from the locale.' ) ; } $ currency = $ this -> currencyCode ; } return $ currency . ' ' . $ this -> asDecimal ( $ normalizedValue , 2 , $ options , $ textOptions ) ; }
|
Formats the value as a currency number .
|
6,832
|
public function asSpellout ( $ value ) { if ( $ value === null ) { return $ this -> getNullDisplay ( ) ; } $ value = $ this -> normalizeNumericValue ( $ value ) ; if ( $ this -> _intlLoaded ) { $ f = $ this -> createNumberFormatter ( NumberFormatter :: SPELLOUT ) ; if ( ( $ result = $ f -> format ( $ value ) ) === false ) { throw new InvalidArgumentException ( 'Formatting number as spellout failed: ' . $ f -> getErrorCode ( ) . ' ' . $ f -> getErrorMessage ( ) ) ; } return $ result ; } throw new InvalidConfigException ( 'Format as Spellout is only supported when PHP intl extension is installed.' ) ; }
|
Formats the value as a number spellout .
|
6,833
|
protected function createNumberFormatter ( $ style , $ decimals = null , $ options = [ ] , $ textOptions = [ ] ) { $ formatter = new NumberFormatter ( $ this -> getLocale ( ) , $ style ) ; foreach ( $ this -> numberFormatterTextOptions as $ name => $ attribute ) { $ formatter -> setTextAttribute ( $ name , $ attribute ) ; } foreach ( $ textOptions as $ name => $ attribute ) { $ formatter -> setTextAttribute ( $ name , $ attribute ) ; } foreach ( $ this -> numberFormatterOptions as $ name => $ value ) { $ formatter -> setAttribute ( $ name , $ value ) ; } foreach ( $ options as $ name => $ value ) { $ formatter -> setAttribute ( $ name , $ value ) ; } if ( $ decimals !== null ) { $ formatter -> setAttribute ( NumberFormatter :: MAX_FRACTION_DIGITS , $ decimals ) ; $ formatter -> setAttribute ( NumberFormatter :: MIN_FRACTION_DIGITS , $ decimals ) ; } if ( $ this -> decimalSeparator !== null ) { $ formatter -> setSymbol ( NumberFormatter :: DECIMAL_SEPARATOR_SYMBOL , $ this -> decimalSeparator ) ; } if ( $ this -> thousandSeparator !== null ) { $ formatter -> setSymbol ( NumberFormatter :: GROUPING_SEPARATOR_SYMBOL , $ this -> thousandSeparator ) ; $ formatter -> setSymbol ( NumberFormatter :: MONETARY_GROUPING_SEPARATOR_SYMBOL , $ this -> thousandSeparator ) ; } foreach ( $ this -> numberFormatterSymbols as $ name => $ symbol ) { $ formatter -> setSymbol ( $ name , $ symbol ) ; } return $ formatter ; }
|
Creates a number formatter based on the given type and format .
|
6,834
|
protected function normalizeNumericStringValue ( $ value ) { $ separatorPosition = strrpos ( $ value , '.' ) ; if ( $ separatorPosition !== false ) { $ integerPart = substr ( $ value , 0 , $ separatorPosition ) ; $ fractionalPart = substr ( $ value , $ separatorPosition + 1 ) ; } else { $ integerPart = $ value ; $ fractionalPart = null ; } $ integerPart = preg_replace ( '/^\+?(-?)0*(\d+)$/' , '$1$2' , $ integerPart ) ; $ integerPart = preg_replace ( '/^\+?(-?)0*$/' , '${1}0' , $ integerPart ) ; if ( $ fractionalPart !== null ) { $ fractionalPart = rtrim ( $ fractionalPart , '0' ) ; } $ normalizedValue = $ integerPart ; if ( ! empty ( $ fractionalPart ) ) { $ normalizedValue .= '.' . $ fractionalPart ; } elseif ( $ normalizedValue === '-0' ) { $ normalizedValue = '0' ; } return $ normalizedValue ; }
|
Normalizes a numeric string value .
|
6,835
|
public function on ( $ name , $ handler , array $ params = [ ] , $ append = true ) { $ this -> ensureBehaviors ( ) ; if ( strpos ( $ name , '*' ) !== false ) { if ( $ append || empty ( $ this -> _eventWildcards [ $ name ] ) ) { $ this -> _eventWildcards [ $ name ] [ ] = [ $ handler , $ params ] ; } else { array_unshift ( $ this -> _eventWildcards [ $ name ] , [ $ handler , $ params ] ) ; } return ; } if ( $ append || empty ( $ this -> _events [ $ name ] ) ) { $ this -> _events [ $ name ] [ ] = [ $ handler , $ params ] ; } else { array_unshift ( $ this -> _events [ $ name ] , [ $ handler , $ params ] ) ; } }
|
Attaches an event handler to an event .
|
6,836
|
public function register ( ) { ini_set ( 'display_errors' , false ) ; set_exception_handler ( [ $ this , 'handleException' ] ) ; set_error_handler ( [ $ this , 'handleError' ] ) ; if ( $ this -> memoryReserveSize > 0 ) { $ this -> _memoryReserve = str_repeat ( 'x' , $ this -> memoryReserveSize ) ; } register_shutdown_function ( [ $ this , 'handleFatalError' ] ) ; }
|
Register this error handler .
|
6,837
|
protected function flushLogger ( ) { if ( $ this -> logger instanceof \ Yiisoft \ Log \ Logger ) { $ this -> logger -> flush ( true ) ; unset ( $ this -> logger ) ; } }
|
Attempts to flush logger messages .
|
6,838
|
public static function validateMultiple ( $ models , $ attributeNames = null , $ clearErrors = true ) { $ valid = true ; foreach ( $ models as $ model ) { $ valid = $ model -> validate ( $ attributeNames , $ clearErrors ) && $ valid ; } return $ valid ; }
|
Validates multiple models . This method will validate every model . The models being validated may be of the same or different types .
|
6,839
|
public function init ( ) { parent :: init ( ) ; if ( ! isset ( $ this -> translations [ 'yii' ] ) && ! isset ( $ this -> translations [ 'yii*' ] ) ) { $ this -> translations [ 'yii' ] = [ '__class' => PhpMessageSource :: class , 'sourceLanguage' => 'en-US' , 'basePath' => '@yii/messages' , ] ; } if ( ! isset ( $ this -> translations [ 'app' ] ) && ! isset ( $ this -> translations [ 'app*' ] ) ) { $ this -> translations [ 'app' ] = [ '__class' => PhpMessageSource :: class , 'sourceLanguage' => $ this -> app -> sourceLanguage , 'basePath' => '@app/messages' , ] ; } }
|
Initializes the component by configuring the default message categories .
|
6,840
|
public static function process ( string $ content , $ config = null ) : string { $ configInstance = static :: createConfig ( $ config ) ; $ configInstance -> autoFinalize = false ; return \ HTMLPurifier :: instance ( $ configInstance ) -> purify ( $ content ) ; }
|
Passes markup through HTMLPurifier making it safe to output to end user .
|
6,841
|
public static function truncateCharacters ( string $ content , int $ count , string $ suffix = '...' , string $ encoding = 'utf-8' , $ config = null ) : string { $ config = static :: createConfig ( $ config ) ; $ tokens = \ HTMLPurifier_Lexer :: create ( $ config ) -> tokenizeHTML ( $ content , $ config , new \ HTMLPurifier_Context ( ) ) ; $ openTokens = [ ] ; $ totalCount = 0 ; $ depth = 0 ; $ truncated = [ ] ; foreach ( $ tokens as $ token ) { if ( $ token instanceof \ HTMLPurifier_Token_Start ) { $ openTokens [ $ depth ] = $ token -> name ; $ truncated [ ] = $ token ; ++ $ depth ; } elseif ( $ token instanceof \ HTMLPurifier_Token_Text && $ totalCount <= $ count ) { $ token -> data = StringHelper :: truncateCharacters ( $ token -> data , $ count - $ totalCount , '' , $ encoding ) ; $ currentCount = mb_strlen ( $ token -> data , $ encoding ) ; $ totalCount += $ currentCount ; $ truncated [ ] = $ token ; } elseif ( $ token instanceof \ HTMLPurifier_Token_End ) { if ( $ token -> name === $ openTokens [ $ depth - 1 ] ) { -- $ depth ; unset ( $ openTokens [ $ depth ] ) ; $ truncated [ ] = $ token ; } } elseif ( $ token instanceof \ HTMLPurifier_Token_Empty ) { $ truncated [ ] = $ token ; } if ( $ totalCount >= $ count ) { if ( 0 < count ( $ openTokens ) ) { krsort ( $ openTokens ) ; foreach ( $ openTokens as $ name ) { $ truncated [ ] = new \ HTMLPurifier_Token_End ( $ name ) ; } } break ; } } $ context = new \ HTMLPurifier_Context ( ) ; $ generator = new \ HTMLPurifier_Generator ( $ config , $ context ) ; return $ generator -> generateFromTokens ( $ truncated ) . ( $ totalCount >= $ count ? $ suffix : '' ) ; }
|
Truncate a HTML string to count of characters specified .
|
6,842
|
protected function setComponent ( $ name , $ value ) { if ( $ this -> _string !== null ) { $ this -> _components = $ this -> parseUri ( $ this -> _string ) ; } $ this -> _components [ $ name ] = $ value ; $ this -> _string = null ; }
|
Sets up particular URI component .
|
6,843
|
protected function getComponents ( ) { if ( $ this -> _components === null ) { if ( $ this -> _string === null ) { return [ ] ; } $ this -> _components = $ this -> parseUri ( $ this -> _string ) ; } return $ this -> _components ; }
|
Returns URI components for this instance as an associative array .
|
6,844
|
protected function composeUri ( array $ components ) { $ uri = '' ; $ scheme = empty ( $ components [ 'scheme' ] ) ? 'http' : $ components [ 'scheme' ] ; if ( $ scheme !== '' ) { $ uri .= $ scheme . ':' ; } $ authority = $ this -> composeAuthority ( $ components ) ; if ( $ authority !== '' || $ scheme === 'file' ) { $ uri .= '//' . $ authority ; } if ( ! empty ( $ components [ 'path' ] ) ) { $ uri .= $ components [ 'path' ] ; } if ( ! empty ( $ components [ 'query' ] ) ) { $ uri .= '?' . $ components [ 'query' ] ; } if ( ! empty ( $ components [ 'fragment' ] ) ) { $ uri .= '#' . $ components [ 'fragment' ] ; } return $ uri ; }
|
Composes URI string from given components .
|
6,845
|
protected function isDefaultPort ( $ scheme , $ port ) { if ( ! isset ( self :: $ defaultPorts [ $ scheme ] ) ) { return false ; } return self :: $ defaultPorts [ $ scheme ] == $ port ; }
|
Checks whether specified port is default one for the specified scheme .
|
6,846
|
public function send ( MailerInterface $ mailer = null ) { if ( $ mailer === null && $ this -> mailer === null ) { $ mailer = Yii :: getApp ( ) -> getMailer ( ) ; } elseif ( $ mailer === null ) { $ mailer = $ this -> mailer ; } return $ mailer -> send ( $ this ) ; }
|
Sends this email message .
|
6,847
|
public function getFallbackLocale ( ) : self { if ( $ this -> variant !== null ) { return $ this -> withVariant ( null ) ; } if ( $ this -> region !== null ) { return $ this -> withRegion ( null ) ; } if ( $ this -> script !== null ) { return $ this -> withScript ( null ) ; } return $ this ; }
|
Returns fallback locale
|
6,848
|
public function createUrl ( $ page , $ pageSize = null , $ absolute = false ) { $ page = ( int ) $ page ; $ pageSize = ( int ) $ pageSize ; if ( ( $ params = $ this -> params ) === null ) { $ request = Yii :: getApp ( ) -> getRequest ( ) ; $ params = $ request instanceof Request ? $ request -> getQueryParams ( ) : [ ] ; } if ( $ page > 0 || $ page == 0 && $ this -> forcePageParam ) { $ params [ $ this -> pageParam ] = $ page + 1 ; } else { unset ( $ params [ $ this -> pageParam ] ) ; } if ( $ pageSize <= 0 ) { $ pageSize = $ this -> getPageSize ( ) ; } if ( $ pageSize != $ this -> defaultPageSize ) { $ params [ $ this -> pageSizeParam ] = $ pageSize ; } else { unset ( $ params [ $ this -> pageSizeParam ] ) ; } $ params [ 0 ] = $ this -> route ?? Yii :: getApp ( ) -> controller -> getRoute ( ) ; $ urlManager = $ this -> urlManager ?? Yii :: getApp ( ) -> getUrlManager ( ) ; if ( $ absolute ) { return $ urlManager -> createAbsoluteUrl ( $ params ) ; } return $ urlManager -> createUrl ( $ params ) ; }
|
Creates the URL suitable for pagination with the specified page number . This method is mainly called by pagers when creating URLs used to perform pagination .
|
6,849
|
public function __isset ( $ name ) { $ getter = 'get' . $ name ; if ( method_exists ( $ this , $ getter ) ) { return $ this -> $ getter ( ) !== null ; } return false ; }
|
Checks if a property is set i . e . defined and not null .
|
6,850
|
public function canGetProperty ( $ name , $ checkVars = true ) { return method_exists ( $ this , 'get' . $ name ) || $ checkVars && property_exists ( $ this , $ name ) ; }
|
Returns a value indicating whether a property can be read .
|
6,851
|
public function translate ( string $ category , string $ message , array $ params = [ ] , string $ language = null ) { return $ this -> translator -> translate ( $ category , $ message , $ params , $ language ? : ( string ) $ this -> locale ) ; }
|
Translates a message to the specified language . Drops in the current locale when language is not given .
|
6,852
|
public function getCurrencySymbol ( $ currencyCode = null ) : string { if ( ! extension_loaded ( 'intl' ) ) { throw new InvalidConfigException ( 'Locale component requires PHP intl extension to be installed.' ) ; } $ locale = $ this -> locale ; if ( $ currencyCode !== null ) { $ locale = $ locale -> withCurrency ( $ currencyCode ) ; } $ formatter = new NumberFormatter ( ( string ) $ locale , NumberFormatter :: CURRENCY ) ; return $ formatter -> getSymbol ( NumberFormatter :: CURRENCY_SYMBOL ) ; }
|
Returns a currency symbol
|
6,853
|
protected function loadMessagesFromFile ( $ messageFile ) { if ( is_file ( $ messageFile ) ) { $ messages = include $ messageFile ; if ( ! \ is_array ( $ messages ) ) { $ messages = [ ] ; } return $ messages ; } return null ; }
|
Loads the message translation for the specified language and category or returns null if file doesn t exist .
|
6,854
|
public function actionCreate ( $ root = null , $ mapFile = null ) { if ( $ root === null ) { $ root = YII_PATH ; } $ root = FileHelper :: normalizePath ( $ root ) ; if ( $ mapFile === null ) { $ mapFile = YII_PATH . '/classes.php' ; } $ options = [ 'filter' => function ( $ path ) { if ( is_file ( $ path ) ) { $ file = basename ( $ path ) ; if ( $ file [ 0 ] < 'A' || $ file [ 0 ] > 'Z' ) { return false ; } } return null ; } , 'only' => [ '*.php' ] , 'except' => [ '/Yii.php' , '/BaseYii.php' , '/console/' , '/requirements/' , ] , ] ; $ files = FileHelper :: findFiles ( $ root , $ options ) ; $ map = [ ] ; foreach ( $ files as $ file ) { if ( strpos ( $ file , $ root ) !== 0 ) { throw new Exception ( "Something wrong: $file\n" ) ; } $ path = str_replace ( '\\' , '/' , substr ( $ file , \ strlen ( $ root ) ) ) ; $ map [ $ path ] = " 'yii" . substr ( str_replace ( '/' , '\\' , $ path ) , 0 , - 4 ) . "' => YII_PATH . '$path'," ; } ksort ( $ map ) ; $ map = implode ( "\n" , $ map ) ; $ output = <<<EOD<?php/** * Yii core class map. * * This file is automatically generated by the "build classmap" command under the "build" folder. * Do not modify it directly. * * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */return [$map];EOD ; if ( is_file ( $ mapFile ) && file_get_contents ( $ mapFile ) === $ output ) { echo "Nothing changed.\n" ; } else { file_put_contents ( $ mapFile , $ output ) ; echo "Class map saved in $mapFile\n" ; } }
|
Creates a class map for the core Yii classes .
|
6,855
|
public function createSortParam ( $ attribute ) { if ( ! isset ( $ this -> attributes [ $ attribute ] ) ) { throw new InvalidConfigException ( "Unknown attribute: $attribute" ) ; } $ definition = $ this -> attributes [ $ attribute ] ; $ directions = $ this -> getAttributeOrders ( ) ; if ( isset ( $ directions [ $ attribute ] ) ) { $ direction = $ directions [ $ attribute ] === SORT_DESC ? SORT_ASC : SORT_DESC ; unset ( $ directions [ $ attribute ] ) ; } else { $ direction = $ definition [ 'default' ] ?? SORT_ASC ; } if ( $ this -> enableMultiSort ) { $ directions = array_merge ( [ $ attribute => $ direction ] , $ directions ) ; } else { $ directions = [ $ attribute => $ direction ] ; } $ sorts = [ ] ; foreach ( $ directions as $ attribute => $ direction ) { $ sorts [ ] = $ direction === SORT_DESC ? '-' . $ attribute : $ attribute ; } return implode ( $ this -> separator , $ sorts ) ; }
|
Creates the sort variable for the specified attribute . The newly created sort variable can be used to create a URL that will lead to sorting by the specified attribute .
|
6,856
|
public static function missing ( string $ category , $ message , string $ language ) { return new static ( static :: MISSING , $ category , $ message , $ language ) ; }
|
Create MISSING translation event .
|
6,857
|
public static function fromJson ( $ json ) { if ( ! is_object ( $ json ) ) { $ json = json_decode ( $ json ) ; } $ collection = new static ( ) ; foreach ( $ json -> patches as $ package => $ patches ) { foreach ( $ patches as $ patch_json ) { $ patch = Patch :: fromJson ( $ patch_json ) ; $ collection -> addPatch ( $ patch ) ; } } return $ collection ; }
|
Create a PatchCollection from a serialized representation .
|
6,858
|
public function getPatchResolvers ( ) { $ resolvers = [ ] ; $ plugin_manager = $ this -> composer -> getPluginManager ( ) ; foreach ( $ plugin_manager -> getPluginCapabilities ( 'cweagans\Composer\Capability\ResolverProvider' , [ 'composer' => $ this -> composer , 'io' => $ this -> io ] ) as $ capability ) { $ newResolvers = $ capability -> getResolvers ( ) ; if ( ! is_array ( $ newResolvers ) ) { throw new \ UnexpectedValueException ( 'Plugin capability ' . get_class ( $ capability ) . ' failed to return an array from getResolvers().' ) ; } foreach ( $ newResolvers as $ resolver ) { if ( ! $ resolver instanceof ResolverBase ) { throw new \ UnexpectedValueException ( 'Plugin capability ' . get_class ( $ capability ) . ' returned an invalid value.' ) ; } } $ resolvers = array_merge ( $ resolvers , $ newResolvers ) ; } return $ resolvers ; }
|
Gather a list of all patch resolvers from all enabled Composer plugins .
|
6,859
|
public function resolvePatches ( PackageEvent $ event ) { if ( $ this -> patchesResolved ) { return ; } foreach ( $ this -> getPatchResolvers ( ) as $ resolver ) { if ( ! in_array ( get_class ( $ resolver ) , $ this -> getConfig ( 'disable-resolvers' ) , true ) ) { $ resolver -> resolve ( $ this -> patchCollection , $ event ) ; } else { if ( $ this -> io -> isVerbose ( ) ) { $ this -> io -> write ( '<info> - Skipping resolver ' . get_class ( $ resolver ) . '</info>' ) ; } } } $ this -> patchesResolved = true ; }
|
Gather patches that need to be applied to the current set of packages .
|
6,860
|
public function checkPatches ( Event $ event ) { if ( ! $ this -> isPatchingEnabled ( ) ) { return ; } try { $ repositoryManager = $ this -> composer -> getRepositoryManager ( ) ; $ localRepository = $ repositoryManager -> getLocalRepository ( ) ; $ installationManager = $ this -> composer -> getInstallationManager ( ) ; $ packages = $ localRepository -> getPackages ( ) ; $ tmp_patches = $ this -> grabPatches ( ) ; foreach ( $ packages as $ package ) { $ extra = $ package -> getExtra ( ) ; if ( isset ( $ extra [ 'patches' ] ) ) { $ this -> installedPatches [ $ package -> getName ( ) ] = $ extra [ 'patches' ] ; } $ patches = isset ( $ extra [ 'patches' ] ) ? $ extra [ 'patches' ] : array ( ) ; $ tmp_patches = Util :: arrayMergeRecursiveDistinct ( $ tmp_patches , $ patches ) ; } if ( $ tmp_patches === false ) { $ this -> io -> write ( '<info>No patches supplied.</info>' ) ; return ; } foreach ( $ packages as $ package ) { if ( ! ( $ package instanceof AliasPackage ) ) { $ package_name = $ package -> getName ( ) ; $ extra = $ package -> getExtra ( ) ; $ has_patches = isset ( $ tmp_patches [ $ package_name ] ) ; $ has_applied_patches = isset ( $ extra [ 'patches_applied' ] ) ; if ( ( $ has_patches && ! $ has_applied_patches ) || ( ! $ has_patches && $ has_applied_patches ) || ( $ has_patches && $ has_applied_patches && $ tmp_patches [ $ package_name ] !== $ extra [ 'patches_applied' ] ) ) { $ uninstallOperation = new UninstallOperation ( $ package , 'Removing package so it can be re-installed and re-patched.' ) ; $ this -> io -> write ( '<info>Removing package ' . $ package_name . ' so that it can be re-installed and re-patched.</info>' ) ; $ installationManager -> uninstall ( $ localRepository , $ uninstallOperation ) ; } } } } catch ( \ LogicException $ e ) { return ; } }
|
Before running composer install
|
6,861
|
protected function getPackageFromOperation ( OperationInterface $ operation ) { if ( $ operation instanceof InstallOperation ) { $ package = $ operation -> getPackage ( ) ; } elseif ( $ operation instanceof UpdateOperation ) { $ package = $ operation -> getTargetPackage ( ) ; } else { throw new \ Exception ( 'Unknown operation: ' . get_class ( $ operation ) ) ; } return $ package ; }
|
Get a Package object from an OperationInterface object .
|
6,862
|
protected function getAndApplyPatch ( RemoteFilesystem $ downloader , $ install_path , $ patch_url ) { if ( file_exists ( $ patch_url ) ) { $ filename = realpath ( $ patch_url ) ; } else { $ filename = uniqid ( sys_get_temp_dir ( ) . '/' ) . ".patch" ; $ hostname = parse_url ( $ patch_url , PHP_URL_HOST ) ; $ downloader -> copy ( $ hostname , $ patch_url , $ filename , false ) ; } $ patched = false ; $ patch_levels = $ this -> getConfig ( 'patch-levels' ) ; foreach ( $ patch_levels as $ patch_level ) { if ( $ this -> io -> isVerbose ( ) ) { $ comment = 'Testing ability to patch with git apply.' ; $ comment .= ' This command may produce errors that can be safely ignored.' ; $ this -> io -> write ( '<comment>' . $ comment . '</comment>' ) ; } $ checked = $ this -> executeCommand ( 'git -C %s apply --check -v %s %s' , $ install_path , $ patch_level , $ filename ) ; $ output = $ this -> executor -> getErrorOutput ( ) ; if ( substr ( $ output , 0 , 7 ) === 'Skipped' ) { $ checked = false ; } if ( $ checked ) { $ patched = $ this -> executeCommand ( 'git -C %s apply %s %s' , $ install_path , $ patch_level , $ filename ) ; break ; } } if ( ! $ patched ) { foreach ( $ patch_levels as $ patch_level ) { if ( $ patched = $ this -> executeCommand ( "patch %s --no-backup-if-mismatch -d %s < %s" , $ patch_level , $ install_path , $ filename ) ) { break ; } } } if ( isset ( $ hostname ) ) { unlink ( $ filename ) ; } if ( ! $ patched ) { throw new \ Exception ( "Cannot apply patch $patch_url" ) ; } }
|
Apply a patch on code in the specified directory .
|
6,863
|
protected function isPatchingEnabled ( ) { $ enabled = true ; $ has_no_patches = empty ( $ extra [ 'patches' ] ) ; $ has_no_patches_file = ( $ this -> getConfig ( 'patches-file' ) === '' ) ; $ patching_disabled = $ this -> getConfig ( 'disable-patching' ) ; if ( $ patching_disabled || ! ( $ has_no_patches && $ has_no_patches_file ) ) { $ enabled = false ; } return $ enabled ; }
|
Checks if the root package enables patching .
|
6,864
|
public static function fromJson ( $ json ) { if ( ! is_object ( $ json ) ) { $ json = json_decode ( $ json ) ; } $ properties = [ 'package' , 'description' , 'url' , 'sha1' , 'depth' ] ; $ patch = new static ( ) ; foreach ( $ properties as $ property ) { if ( isset ( $ json -> { $ property } ) ) { $ patch -> { $ property } = $ json -> { $ property } ; } } return $ patch ; }
|
Create a Patch from a serialized representation .
|
6,865
|
public function findPatchesInJson ( $ patches ) { foreach ( $ patches as $ package => $ patch_defs ) { if ( isset ( $ patch_defs [ 0 ] ) && is_array ( $ patch_defs [ 0 ] ) ) { $ this -> io -> write ( "<info>Using expanded definition format for package {$package}</info>" ) ; foreach ( $ patch_defs as $ index => $ def ) { $ patch = new Patch ( ) ; $ patch -> package = $ package ; $ patch -> url = $ def [ "url" ] ; $ patch -> description = $ def [ "description" ] ; $ patches [ $ package ] [ $ index ] = $ patch ; } } else { $ this -> io -> write ( "<info>Using compact definition format for package {$package}</info>" ) ; $ temporary_patch_list = [ ] ; foreach ( $ patch_defs as $ description => $ url ) { $ patch = new Patch ( ) ; $ patch -> package = $ package ; $ patch -> url = $ url ; $ patch -> description = $ description ; $ temporary_patch_list [ ] = $ patch ; } $ patches [ $ package ] = $ temporary_patch_list ; } } return $ patches ; }
|
Handles the different patch definition formats and returns a list of Patches .
|
6,866
|
protected function readPatchesFile ( $ patches_file ) { $ patches = file_get_contents ( $ patches_file ) ; $ patches = json_decode ( $ patches , true ) ; $ json_error = json_last_error_msg ( ) ; if ( $ json_error !== "No error" ) { throw new \ InvalidArgumentException ( $ json_error ) ; } if ( ! array_key_exists ( 'patches' , $ patches ) ) { throw new \ InvalidArgumentException ( 'No patches found.' ) ; } return $ patches [ 'patches' ] ; }
|
Read a patches file .
|
6,867
|
public static function interval ( int $ interval , AsyncSchedulerInterface $ scheduler = null ) : IntervalObservable { return new IntervalObservable ( $ interval , $ scheduler ? : Scheduler :: getAsync ( ) ) ; }
|
Returns an Observable that emits an infinite sequence of ascending integers starting at 0 with a constant interval of time of your choosing between emissions .
|
6,868
|
public static function of ( $ value , SchedulerInterface $ scheduler = null ) : ReturnObservable { return new ReturnObservable ( $ value , $ scheduler ? : Scheduler :: getDefault ( ) ) ; }
|
Returns an observable sequence that contains a single element .
|
6,869
|
public static function error ( \ Throwable $ error , SchedulerInterface $ scheduler = null ) : ErrorObservable { return new ErrorObservable ( $ error , $ scheduler ? : Scheduler :: getImmediate ( ) ) ; }
|
Returns an observable sequence that terminates with an exception .
|
6,870
|
public function merge ( ObservableInterface $ otherObservable ) : Observable { return ( new AnonymousObservable ( function ( ObserverInterface $ observer ) use ( $ otherObservable ) { $ observer -> onNext ( $ this ) ; $ observer -> onNext ( $ otherObservable ) ; $ observer -> onCompleted ( ) ; } ) ) -> mergeAll ( ) ; }
|
Combine an Observable together with another Observable by merging their emissions into a single Observable .
|
6,871
|
public static function fromIterator ( \ Iterator $ iterator , SchedulerInterface $ scheduler = null ) : IteratorObservable { return new IteratorObservable ( $ iterator , $ scheduler ? : Scheduler :: getDefault ( ) ) ; }
|
Converts an Iterator into an observable sequence
|
6,872
|
public static function range ( int $ start , int $ count , SchedulerInterface $ scheduler = null ) : RangeObservable { return new RangeObservable ( $ start , $ count , $ scheduler ? : Scheduler :: getDefault ( ) ) ; }
|
Generates an observable sequence of integral numbers within a specified range using the specified scheduler to send out observer messages .
|
6,873
|
public function mapWithIndex ( callable $ selector ) : Observable { $ index = 0 ; return $ this -> map ( function ( $ value ) use ( $ selector , & $ index ) { return $ selector ( $ index ++ , $ value ) ; } ) ; }
|
Maps operator variant that calls the map selector with the index and value
|
6,874
|
public function skipWhileWithIndex ( callable $ predicate ) : Observable { $ index = 0 ; return $ this -> skipWhile ( function ( $ value ) use ( $ predicate , & $ index ) { return $ predicate ( $ index ++ , $ value ) ; } ) ; }
|
Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements . The element s index is used in the logic of the predicate function .
|
6,875
|
public function take ( int $ count ) : Observable { if ( $ count === 0 ) { return self :: empty ( ) ; } return $ this -> lift ( function ( ) use ( $ count ) { return new TakeOperator ( $ count ) ; } ) ; }
|
Returns a specified number of contiguous elements from the start of an observable sequence
|
6,876
|
public function takeWhileWithIndex ( callable $ predicate ) : Observable { $ index = 0 ; return $ this -> takeWhile ( function ( $ value ) use ( $ predicate , & $ index ) { return $ predicate ( $ index ++ , $ value ) ; } ) ; }
|
Returns elements from an observable sequence as long as a specified condition is true . It takes as a parameter a a callback to test each source element for a condition . The callback predicate is called with the index and the value of the element .
|
6,877
|
public function groupBy ( callable $ keySelector , callable $ elementSelector = null , callable $ keySerializer = null ) : Observable { return $ this -> groupByUntil ( $ keySelector , $ elementSelector , function ( ) { return static :: never ( ) ; } , $ keySerializer ) ; }
|
Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function .
|
6,878
|
public function reduce ( callable $ accumulator , $ seed = null ) : Observable { return $ this -> lift ( function ( ) use ( $ accumulator , $ seed ) { return new ReduceOperator ( $ accumulator , $ seed ) ; } ) ; }
|
Applies an accumulator function over an observable sequence returning the result of the aggregation as a single element in the result sequence . The specified seed value is used as the initial accumulator value .
|
6,879
|
public function distinct ( callable $ comparer = null ) : Observable { return $ this -> lift ( function ( ) use ( $ comparer ) { return new DistinctOperator ( null , $ comparer ) ; } ) ; }
|
Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer . Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large .
|
6,880
|
public function distinctKey ( callable $ keySelector , callable $ comparer = null ) : Observable { return $ this -> lift ( function ( ) use ( $ keySelector , $ comparer ) { return new DistinctOperator ( $ keySelector , $ comparer ) ; } ) ; }
|
Variant of distinct that takes a key selector
|
6,881
|
public function distinctUntilChanged ( callable $ comparer = null ) : Observable { return $ this -> lift ( function ( ) use ( $ comparer ) { return new DistinctUntilChangedOperator ( null , $ comparer ) ; } ) ; }
|
A variant of distinct that only compares emitted items from the source Observable against their immediate predecessors in order to determine whether or not they are distinct .
|
6,882
|
public function distinctUntilKeyChanged ( callable $ keySelector = null , callable $ comparer = null ) : Observable { return $ this -> lift ( function ( ) use ( $ keySelector , $ comparer ) { return new DistinctUntilChangedOperator ( $ keySelector , $ comparer ) ; } ) ; }
|
Variant of distinctUntilChanged that takes a key selector and the comparer .
|
6,883
|
public function do ( $ onNextOrObserver = null , callable $ onError = null , callable $ onCompleted = null ) : Observable { if ( $ onNextOrObserver instanceof ObserverInterface ) { $ observer = $ onNextOrObserver ; } elseif ( is_callable ( $ onNextOrObserver ) ) { $ observer = new DoObserver ( $ onNextOrObserver , $ onError , $ onCompleted ) ; } else { throw new \ InvalidArgumentException ( 'The first argument needs to be a "callable" or "Observer"' ) ; } return $ this -> lift ( function ( ) use ( $ observer ) { return new DoOnEachOperator ( $ observer ) ; } ) ; }
|
Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence . This method can be used for debugging logging etc . of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline .
|
6,884
|
public static function timer ( int $ dueTime , AsyncSchedulerInterface $ scheduler = null ) : TimerObservable { return new TimerObservable ( $ dueTime , $ scheduler ? : Scheduler :: getAsync ( ) ) ; }
|
Returns an observable sequence that produces a value after dueTime has elapsed .
|
6,885
|
public function concatMap ( callable $ selector , callable $ resultSelector = null ) : Observable { return $ this -> lift ( function ( ) use ( $ selector , $ resultSelector ) { return new ConcatMapOperator ( new ObservableFactoryWrapper ( $ selector ) , $ resultSelector ) ; } ) ; }
|
Projects each element of an observable sequence to an observable sequence and concatenates the resulting observable sequences into one observable sequence .
|
6,886
|
public function concatMapTo ( ObservableInterface $ observable , callable $ resultSelector = null ) : Observable { return $ this -> concatMap ( function ( ) use ( $ observable ) { return $ observable ; } , $ resultSelector ) ; }
|
Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence .
|
6,887
|
public function publishValue ( $ initialValue , callable $ selector = null ) : Observable { return $ this -> multicast ( new BehaviorSubject ( $ initialValue ) , $ selector ) ; }
|
Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue . This operator is a specialization of Multicast using a BehaviorSubject .
|
6,888
|
public function singleInstance ( ) : Observable { $ hasObservable = false ; $ observable = null ; $ source = $ this ; $ getObservable = function ( ) use ( & $ hasObservable , & $ observable , $ source ) : Observable { if ( ! $ hasObservable ) { $ hasObservable = true ; $ observable = $ source -> finally ( function ( ) use ( & $ hasObservable ) { $ hasObservable = false ; } ) -> publish ( ) -> refCount ( ) ; } return $ observable ; } ; return new Observable \ AnonymousObservable ( function ( ObserverInterface $ o ) use ( $ getObservable ) { return $ getObservable ( ) -> subscribe ( $ o ) ; } ) ; }
|
Returns an observable sequence that shares a single subscription to the underlying sequence . This observable sequence can be resubscribed to even if all prior subscriptions have ended .
|
6,889
|
public function shareReplay ( int $ bufferSize , int $ windowSize = null , SchedulerInterface $ scheduler = null ) : RefCountObservable { return $ this -> replay ( null , $ bufferSize , $ windowSize , $ scheduler ) -> refCount ( ) ; }
|
Returns an observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer .
|
6,890
|
public function repeat ( int $ count = - 1 ) : Observable { if ( $ count === 0 ) { return self :: empty ( ) ; } return $ this -> lift ( function ( ) use ( $ count ) { return new RepeatOperator ( $ count ) ; } ) ; }
|
Generates an observable sequence that repeats the given element the specified number of times .
|
6,891
|
public function timeout ( int $ timeout , ObservableInterface $ timeoutObservable = null , AsyncSchedulerInterface $ scheduler = null ) : Observable { return $ this -> lift ( function ( ) use ( $ timeout , $ timeoutObservable , $ scheduler ) { return new TimeoutOperator ( $ timeout , $ timeoutObservable , $ scheduler ? : Scheduler :: getAsync ( ) ) ; } ) ; }
|
Errors the observable sequence if no item is emitted in the specified time . When a timeout occurs this operator errors with an instance of Rx \ Exception \ TimeoutException
|
6,892
|
public function bufferWithCount ( int $ count , int $ skip = null ) : Observable { return $ this -> lift ( function ( ) use ( $ count , $ skip ) { return new BufferWithCountOperator ( $ count , $ skip ) ; } ) ; }
|
Projects each element of an observable sequence into zero or more buffers which are produced based on element count information .
|
6,893
|
public function startWith ( $ startValue , SchedulerInterface $ scheduler = null ) : Observable { return $ this -> startWithArray ( [ $ startValue ] , $ scheduler ) ; }
|
Prepends a value to an observable sequence with an argument of a signal value to prepend .
|
6,894
|
public function startWithArray ( array $ startArray , SchedulerInterface $ scheduler = null ) : Observable { return $ this -> lift ( function ( ) use ( $ startArray , $ scheduler ) { return new StartWithArrayOperator ( $ startArray , $ scheduler ? : Scheduler :: getDefault ( ) ) ; } ) ; }
|
Prepends a sequence of values to an observable sequence with an argument of an array of values to prepend .
|
6,895
|
public function timestamp ( SchedulerInterface $ scheduler = null ) : Observable { return $ this -> lift ( function ( ) use ( $ scheduler ) { return new TimestampOperator ( $ scheduler ? : Scheduler :: getDefault ( ) ) ; } ) ; }
|
Records the timestamp for each value in an observable sequence .
|
6,896
|
public function partition ( callable $ predicate ) : array { return [ $ this -> filter ( $ predicate ) , $ this -> filter ( function ( ) use ( $ predicate ) { return ! call_user_func_array ( $ predicate , func_get_args ( ) ) ; } ) ] ; }
|
Returns two observables which partition the observations of the source by the given function . The first will trigger observations for those values for which the predicate returns true . The second will trigger observations for those values where the predicate returns false . The predicate is executed once for each subscribed observer . Both also propagate all error observations arising from the source and each completes when the source completes .
|
6,897
|
public static function race ( array $ observables , SchedulerInterface $ scheduler = null ) : Observable { if ( count ( $ observables ) === 1 ) { return $ observables [ 0 ] ; } return static :: fromArray ( $ observables , $ scheduler ) -> lift ( function ( ) { return new RaceOperator ( ) ; } ) ; }
|
Propagates the observable sequence that reacts first . Also known as amb .
|
6,898
|
public function average ( ) : Observable { return $ this -> defaultIfEmpty ( Observable :: error ( new \ UnderflowException ( ) ) ) -> reduce ( function ( $ a , $ x ) { static $ count = 0 ; static $ total = 0 ; $ count ++ ; $ total += $ x ; return $ total / $ count ; } , 0 ) ; }
|
Computes the average of an observable sequence of values .
|
6,899
|
public function throttle ( int $ throttleDuration , SchedulerInterface $ scheduler = null ) : Observable { return $ this -> lift ( function ( ) use ( $ throttleDuration , $ scheduler ) { return new ThrottleOperator ( $ throttleDuration , $ scheduler ? : Scheduler :: getDefault ( ) ) ; } ) ; }
|
Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.