idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
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 ( $ mess...
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 ( $ throwExcept...
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 -> ciphe...
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 = $ ...
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 , ...
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\'.' , __MET...
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 ===...
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 ...
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 :: SCIEN...
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...
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 ) ) === fals...
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 ...
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 ; $ frac...
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...
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_f...
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 -...
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 \ HTMLPur...
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' ) { $ ...
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 ( ) : [ ] ...
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 ( $ cu...
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 = ...
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 [ $ attri...
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 ( $ p...
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 ) { $ newResol...
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 , $ ...
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 ( )...
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 o...
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 ) ; $ downloade...
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_p...
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 -> { $ proper...
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 ) ...
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 ( 'pat...
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 , $ on...
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 ( ) ...
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 ?...
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 sub...
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 .