idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
27,400 | protected static function _arrayToString ( $ data , $ options ) { if ( empty ( $ data ) ) { return '[]' ; } extract ( $ options [ 'array' ] ) ; $ comma = false ; $ tab = str_repeat ( $ char , $ indent * $ multiplier ) ; $ string = "[\n" ; foreach ( $ data as $ key => $ value ) { if ( $ comma ) { $ string .= ",\n" ; } $... | Generate a string representation of an array . |
27,401 | protected static function _objectToString ( $ value , $ options ) { if ( $ value instanceof Exception ) { $ msg = '`' . get_class ( $ value ) . '` Code(' . $ value -> getCode ( ) . ') with ' ; $ message = $ value -> getMessage ( ) ; if ( $ message ) { $ msg .= 'message ' . static :: dump ( $ value -> getMessage ( ) ) ;... | Generate a string representation of an object . |
27,402 | public static function dump ( $ value , $ quote = '"' ) { if ( is_bool ( $ value ) ) { return $ value ? 'true' : 'false' ; } if ( is_null ( $ value ) ) { return 'null' ; } if ( ! $ quote || ! is_string ( $ value ) ) { return ( string ) $ value ; } if ( $ quote === '"' ) { return $ quote . static :: _dump ( $ value ) . ... | Dump some scalar data using a string representation |
27,403 | protected static function _dump ( $ string ) { $ es = [ '0' , 'x07' , 'x08' , 't' , 'n' , 'v' , 'f' , 'r' ] ; $ unescaped = '' ; $ chars = str_split ( $ string ) ; foreach ( $ chars as $ char ) { if ( $ char === '' ) { continue ; } $ value = ord ( $ char ) ; if ( $ value >= 7 && $ value <= 13 ) { $ unescaped .= '\\' . ... | Expands escape sequences and escape special chars in a string . |
27,404 | public function add ( $ name , $ reporter ) { if ( ! is_object ( $ reporter ) ) { throw new Exception ( "Error, reporter must be an object." ) ; } $ this -> _reporters [ $ name ] = $ reporter ; } | Adds a reporter |
27,405 | public static function get ( $ name = null , $ target = '' ) { if ( ! func_num_args ( ) ) { return static :: $ _matchers ; } if ( $ target === true ) { return isset ( static :: $ _matchers [ $ name ] ) ? static :: $ _matchers [ $ name ] : [ ] ; } if ( $ target === '' ) { if ( isset ( static :: $ _matchers [ $ name ] [ ... | Returns registered matchers . |
27,406 | public static function exists ( $ name , $ target = '' ) { if ( $ target === true ) { return isset ( static :: $ _matchers [ $ name ] ) ; } return isset ( static :: $ _matchers [ $ name ] [ $ target ] ) ; } | Checks if a matcher is registered . |
27,407 | public static function _describeArg ( $ arg ) { if ( is_array ( $ arg ) ) { return sprintf ( 'array[%d]' , count ( $ arg ) ) ; } if ( is_object ( $ arg ) ) { return sprintf ( 'object[%s]' , get_class ( $ arg ) ) ; } return Text :: toString ( $ arg ) ; } | Generate an inline string representation of an argument . |
27,408 | public function findFile ( $ loader , $ class , $ file ) { $ args = func_get_args ( ) ; $ self = isset ( $ this ) ? $ this : get_called_class ( ) ; if ( $ pointcut = Pointcut :: before ( __METHOD__ , $ self , $ args ) ) { return $ pointcut ( $ args , $ self ) ; } return $ file ; } | The JIT find file patcher . |
27,409 | public function patchable ( $ class ) { $ args = func_get_args ( ) ; $ self = isset ( $ this ) ? $ this : get_called_class ( ) ; if ( $ pointcut = Pointcut :: before ( __METHOD__ , $ self , $ args ) ) { return $ pointcut ( $ args , $ self ) ; } return true ; } | The JIT patchable checker . |
27,410 | public function method ( $ path , $ closure = null ) { if ( $ this -> _needToBePatched ) { $ layer = Double :: classname ( ) ; Monkey :: patch ( $ this -> _reference , $ layer ) ; $ this -> _needToBePatched = false ; $ this -> _reference = $ layer ; } $ reference = $ this -> _reference ; if ( ! $ path ) { throw new Inv... | Stubs a method . |
27,411 | public function where ( $ requirements = [ ] ) { foreach ( $ requirements as $ name => $ args ) { if ( ! isset ( $ this -> _chain [ $ name ] ) ) { throw new InvalidArgumentException ( "Unexisting `{$name}` as method as part of the chain definition." ) ; } if ( ! is_array ( $ args ) ) { throw new InvalidArgumentExceptio... | Set arguments requirement indexed by method name . |
27,412 | public static function on ( $ reference ) { $ hash = Suite :: hash ( $ reference ) ; if ( isset ( static :: $ _registered [ $ hash ] ) ) { return static :: $ _registered [ $ hash ] ; } return static :: $ _registered [ $ hash ] = new static ( $ reference ) ; } | Stubs class methods . |
27,413 | public static function find ( $ references , $ method = null , $ args = null ) { $ references = ( array ) $ references ; $ stub = null ; foreach ( $ references as $ reference ) { $ hash = Suite :: hash ( $ reference ) ; if ( ! isset ( static :: $ _registered [ $ hash ] ) ) { continue ; } $ stubs = static :: $ _register... | Finds a stub . |
27,414 | public static function reset ( $ reference = null ) { if ( $ reference === null ) { static :: $ _registered = [ ] ; Suite :: reset ( ) ; return ; } unset ( static :: $ _registered [ Suite :: hash ( $ reference ) ] ) ; } | Clears the registered references . |
27,415 | protected function _progressBar ( ) { if ( $ this -> _current > $ this -> _total ) { return ; } $ percent = $ this -> _current / $ this -> _total ; $ nb = $ percent * $ this -> _size ; $ b = str_repeat ( $ this -> _chars [ 'bar' ] , floor ( $ nb ) ) ; $ i = '' ; if ( $ nb < $ this -> _size ) { $ i = str_pad ( $ this ->... | Ouputs the progress bar to STDOUT . |
27,416 | public static function trace ( $ options = [ ] ) { $ defaults = [ 'trace' => [ ] , 'array' => false ] ; $ options += $ defaults ; $ back = [ ] ; $ backtrace = static :: backtrace ( $ options ) ; foreach ( $ backtrace as $ trace ) { $ back [ ] = static :: _traceToString ( $ trace ) ; } return $ options [ 'array' ] ? $ b... | Gets a backtrace string or string array based on the supplied options . |
27,417 | protected static function _traceToString ( $ trace ) { $ loader = static :: loader ( ) ; if ( ! empty ( $ trace [ 'class' ] ) ) { $ trace [ 'function' ] = $ trace [ 'class' ] . '::' . $ trace [ 'function' ] . '()' ; } else { $ line = static :: _line ( $ trace ) ; $ trace [ 'line' ] = $ line !== $ trace [ 'line' ] ? $ l... | Gets a string representation of a trace . |
27,418 | public static function backtrace ( $ options = [ ] ) { $ defaults = [ 'trace' => [ ] , 'start' => 0 , 'depth' => 0 , 'object' => false , 'args' => false ] ; $ options += $ defaults ; $ mask = $ options [ 'args' ] ? 0 : DEBUG_BACKTRACE_IGNORE_ARGS ; $ mask = $ options [ 'object' ] ? $ mask | DEBUG_BACKTRACE_PROVIDE_OBJE... | Return a backtrace array based on the supplied options . |
27,419 | public static function normalize ( $ backtrace ) { if ( ! static :: isThrowable ( $ backtrace ) ) { return $ backtrace ; } return array_merge ( [ [ 'function' => '[NA]' , 'file' => $ backtrace -> getFile ( ) , 'line' => $ backtrace -> getLine ( ) , 'args' => [ ] ] ] , $ backtrace -> getTrace ( ) ) ; } | Normalises a backtrace . |
27,420 | public static function message ( $ backtrace ) { if ( static :: isThrowable ( $ backtrace ) ) { $ name = get_class ( $ backtrace ) ; $ code = $ backtrace -> getCode ( ) ; return "`{$name}` Code({$code}): " . $ backtrace -> getMessage ( ) ; } elseif ( isset ( $ backtrace [ 'message' ] ) ) { $ code = isset ( $ backtrace ... | Generates a string message from a backtrace array . |
27,421 | protected static function _line ( $ trace ) { $ path = $ trace [ 'file' ] ; $ callLine = $ trace [ 'line' ] ; if ( ! file_exists ( $ path ) ) { return ; } $ file = file_get_contents ( $ path ) ; if ( ( $ i = static :: _findPos ( $ file , $ callLine ) ) === null ) { return ; } $ line = $ callLine ; $ brackets = 0 ; whil... | Locates a line number from a trace . |
27,422 | protected static function _findPos ( $ file , $ callLine ) { $ len = strlen ( $ file ) ; $ line = 1 ; $ i = 0 ; while ( $ i < $ len ) { if ( $ file [ $ i ] === "\n" ) { $ line ++ ; } if ( $ line === $ callLine ) { return $ i ; } $ i ++ ; } } | Return the first character position of a specific line in a file . |
27,423 | public static function focus ( $ pattern , $ backtrace , $ depth = null , $ maxLookup = 10 ) { if ( ! $ pattern ) { return $ backtrace ; } $ i = 0 ; $ start = 0 ; $ found = false ; while ( $ i < $ maxLookup && isset ( $ backtrace [ $ i ] ) ) { if ( isset ( $ backtrace [ $ i ] [ 'file' ] ) ) { $ start = $ start ? : $ i ... | Unstack all traces up to a trace which match a filename regexp . |
27,424 | protected function _write ( $ string , $ options = null ) { $ this -> write ( $ string , $ options ) ; $ this -> _counter ++ ; if ( $ this -> _counter % $ this -> _dotWidth === 0 ) { $ counter = min ( $ this -> _counter , $ this -> _total ) ; $ percent = min ( floor ( ( $ counter * 100 ) / $ this -> _total ) , 100 ) . ... | Outputs the string message in the console . |
27,425 | protected function _errorHandler ( $ enable , $ options = [ ] ) { $ defaults = [ 'handler' => null ] ; $ options += $ defaults ; if ( ! $ enable ) { return restore_error_handler ( ) ; } $ handler = function ( $ code , $ message , $ file , $ line = 0 , $ args = [ ] ) { if ( error_reporting ( ) === 0 ) { return ; } $ tra... | Overrides the default error handler |
27,426 | public function run ( $ options = [ ] ) { $ defaults = [ 'reporters' => null , 'autoclear' => [ ] , 'ff' => 0 , 'part' => '1/1' ] ; $ options += $ defaults ; $ this -> _reporters = $ options [ 'reporters' ] ; $ this -> _autoclear = ( array ) $ options [ 'autoclear' ] ; $ this -> _ff = $ options [ 'ff' ] ; list ( $ inde... | Runs all specs . |
27,427 | public function runBlock ( $ block , $ closure , $ type ) { return Filters :: run ( $ this , 'runBlock' , [ $ block , $ closure , $ type ] , function ( $ next , $ block , $ closure , $ type ) { return call_user_func_array ( $ closure , [ ] ) ; } ) ; } | Run a block s closure . |
27,428 | public function active ( ) { $ stats = $ this -> root ( ) -> stats ( ) ; return $ this -> root ( ) -> focused ( ) ? $ stats [ 'focused' ] : $ stats [ 'normal' ] ; } | Gets number of active specs . |
27,429 | public function autoclear ( ) { foreach ( $ this -> _autoclear as $ plugin ) { if ( is_object ( $ plugin ) ) { if ( method_exists ( $ plugin , 'clear' ) ) { $ plugin -> clear ( ) ; } } elseif ( method_exists ( $ plugin , 'reset' ) ) { $ plugin :: reset ( ) ; } } } | Autoclears plugins . |
27,430 | public static function hash ( $ reference ) { if ( is_object ( $ reference ) ) { return spl_object_hash ( $ reference ) ; } if ( is_string ( $ reference ) ) { return $ reference ; } throw new InvalidArgumentException ( "Error, the passed argument is not hashable." ) ; } | Generates a hash from an instance or a string . |
27,431 | public function xcontext ( $ message , $ closure , $ timeout = null ) { return $ this -> _block -> context ( $ message , $ closure , $ timeout , 'exclude' ) ; } | Comments out a context related spec . |
27,432 | public function xit ( $ message , $ closure = null , $ timeout = null ) { return $ this -> _block -> it ( $ message , $ closure , $ timeout , 'exclude' ) ; } | Comments out a spec . |
27,433 | public function fcontext ( $ message , $ closure , $ timeout = null ) { return $ this -> _block -> context ( $ message , $ closure , $ timeout , 'focus' ) ; } | Adds an focused context related spec . |
27,434 | public function fit ( $ message , $ closure = null , $ timeout = null ) { return $ this -> _block -> it ( $ message , $ closure , $ timeout , 'focus' ) ; } | Adds an focused spec . |
27,435 | public function add ( $ name , $ patcher ) { if ( ! is_object ( $ patcher ) ) { return false ; } return $ this -> _patchers [ $ name ] = $ patcher ; } | Adds a patcher . |
27,436 | public function findFile ( $ loader , $ class , $ file ) { foreach ( $ this -> _patchers as $ patcher ) { $ file = $ patcher -> findFile ( $ loader , $ class , $ file ) ; } return $ file ; } | Runs file loader patchers . |
27,437 | public function process ( $ code , $ path = null ) { if ( ! $ code ) { return '' ; } $ nodes = Parser :: parse ( $ code , [ 'path' => $ path ] ) ; foreach ( $ this -> _patchers as $ patcher ) { $ patcher -> process ( $ nodes , $ path ) ; } return Parser :: unparse ( $ nodes ) ; } | Runs file patchers . |
27,438 | public function patch ( $ options = [ ] ) { $ defaults = [ 'patchers' => null , 'exclude' => [ ] , 'include' => [ '*' ] , 'watch' => [ ] , 'cachePath' => rtrim ( sys_get_temp_dir ( ) , DS ) . DS . 'jit' , 'clearCache' => false ] ; $ options += $ defaults ; $ this -> _patchers = new Patchers ( ) ; $ this -> _cachePath =... | Apply JIT code patching |
27,439 | public function watch ( $ files ) { $ files = ( array ) $ files ; foreach ( $ files as $ file ) { $ path = realpath ( $ file ) ; $ this -> _watched [ $ path ] = $ path ; } $ this -> refreshWatched ( ) ; } | Sets some file to watch . |
27,440 | public function refreshWatched ( ) { $ timestamps = [ 0 ] ; foreach ( $ this -> _watched as $ path ) { $ timestamps [ ] = filemtime ( $ path ) ; } $ this -> _watchedTimestamp = max ( $ timestamps ) ; } | Refresh watched file timestamps |
27,441 | public function allowed ( $ class ) { foreach ( $ this -> _exclude as $ namespace ) { if ( strpos ( $ class , $ namespace ) === 0 ) { return false ; } } if ( $ this -> _include === [ '*' ] ) { return true ; } foreach ( $ this -> _include as $ namespace ) { if ( strpos ( $ class , $ namespace ) === 0 ) { return true ; }... | Checks if a class is allowed to be patched . |
27,442 | public function cached ( $ file ) { if ( ! $ cachePath = $ this -> cachePath ( ) ) { return false ; } $ path = $ cachePath . DS . ltrim ( preg_replace ( '~:~' , '' , $ file ) , DS ) ; if ( ! @ file_exists ( $ path ) ) { return false ; } $ timestamp = filemtime ( $ path ) ; if ( $ timestamp > filemtime ( $ file ) && $ t... | Gets a cached file path . |
27,443 | public function findPath ( $ namespace , $ forceDir = false ) { $ paths = static :: prefixes ( ) ; $ logicalPath = trim ( strtr ( $ namespace , '\\' , DIRECTORY_SEPARATOR ) , DIRECTORY_SEPARATOR ) ; foreach ( $ paths as $ prefix => $ dirs ) { if ( strpos ( $ namespace , $ prefix ) !== 0 ) { continue ; } foreach ( $ dir... | Returns the path of a namespace or fully namespaced class name . |
27,444 | protected function _path ( $ path , $ forceDir ) { if ( $ forceDir ) { return is_dir ( $ path ) ? $ path : null ; } if ( file_exists ( $ file = $ path . '.php' ) ) { return $ file ; } if ( file_exists ( $ file = $ path . '.hh' ) ) { return $ file ; } if ( is_dir ( $ path ) ) { return $ path ; } } | Build full path according to a root path . |
27,445 | public function add ( $ prefix , $ paths , $ prepend = false ) { if ( ! $ prefix ) { if ( $ prepend ) { $ this -> _fallbackDirsPsr0 = array_merge ( ( array ) $ paths , $ this -> _fallbackDirsPsr0 ) ; } else { $ this -> _fallbackDirsPsr0 = array_merge ( $ this -> _fallbackDirsPsr0 , ( array ) $ paths ) ; } return ; } $ ... | Registers a set of PSR - 0 directories for a given prefix either appending or prepending to the ones previously set for this prefix . |
27,446 | public function addPsr4 ( $ prefix , $ paths , $ prepend = false ) { if ( ! $ prefix ) { if ( $ prepend ) { $ this -> _fallbackDirsPsr4 = array_merge ( ( array ) $ paths , $ this -> _fallbackDirsPsr4 ) ; } else { $ this -> _fallbackDirsPsr4 = array_merge ( $ this -> _fallbackDirsPsr4 , ( array ) $ paths ) ; } } elseif ... | Registers a set of PSR - 4 directories for a given namespace either appending or prepending to the ones previously set for this namespace . |
27,447 | public function set ( $ prefix , $ paths ) { if ( ! $ prefix ) { $ this -> _fallbackDirsPsr0 = ( array ) $ paths ; } else { $ this -> _prefixesPsr0 [ $ prefix [ 0 ] ] [ $ prefix ] = ( array ) $ paths ; } } | Registers a set of PSR - 0 directories for a given prefix replacing any others previously set for this prefix . |
27,448 | public function setPsr4 ( $ prefix , $ paths ) { if ( ! $ prefix ) { $ this -> _fallbackDirsPsr4 = ( array ) $ paths ; } else { $ length = strlen ( $ prefix ) ; if ( '\\' !== $ prefix [ $ length - 1 ] ) { throw new \ InvalidArgumentException ( "A non-empty PSR-4 prefix must end with a namespace separator." ) ; } $ this... | Registers a set of PSR - 4 directories for a given namespace replacing any others previously set for this namespace . |
27,449 | protected function _report ( $ log ) { $ type = $ log -> type ( ) ; $ this -> _reportSuiteMessages ( $ log ) ; $ this -> _reportSpecMessage ( $ log ) ; $ this -> _reportFailure ( $ log ) ; $ this -> _indent = 0 ; } | Print a spec report with its parents messages . |
27,450 | protected function _reportSuiteMessages ( $ log ) { $ this -> _indent = 0 ; $ messages = array_values ( array_filter ( $ log -> messages ( ) ) ) ; array_pop ( $ messages ) ; foreach ( $ messages as $ message ) { $ this -> write ( $ message ) ; $ this -> write ( "\n" ) ; $ this -> _indent ++ ; } } | Print an array of description messages to STDOUT |
27,451 | protected function _reportSpecMessage ( $ log ) { $ messages = $ log -> messages ( ) ; $ message = end ( $ messages ) ; switch ( $ log -> type ( ) ) { case 'passed' : $ this -> write ( $ this -> _symbols [ 'ok' ] , 'light-green' ) ; $ this -> write ( ' ' ) ; $ this -> write ( "{$message}\n" , 'dark-grey' ) ; break ; ca... | Print a spec message report . |
27,452 | protected function _reportFailure ( $ log ) { $ this -> _indent ++ ; $ type = $ log -> type ( ) ; switch ( $ type ) { case "failed" : foreach ( $ log -> children ( ) as $ expectation ) { if ( $ expectation -> type ( ) !== 'failed' ) { continue ; } $ data = $ expectation -> data ( ) ; $ isExternal = isset ( $ data [ 'ex... | Print an expectation report . |
27,453 | protected function _reportDiff ( $ log ) { $ data = $ log -> data ( ) ; $ this -> write ( "It expect actual " ) ; if ( $ log -> not ( ) ) { $ this -> write ( 'NOT ' , 'cyan' ) ; $ not = 'not ' ; } else { $ not = '' ; } $ this -> write ( "to {$log->description()}\n\n" ) ; foreach ( $ data as $ key => $ value ) { if ( pr... | Print diff of spec s data . |
27,454 | protected function _reportException ( $ exception ) { $ msg = '`' . get_class ( $ exception ) . '` Code(' . $ exception -> getCode ( ) . ') with ' ; $ message = $ exception -> getMessage ( ) ; if ( $ message ) { $ msg .= 'message ' . Text :: dump ( $ exception -> getMessage ( ) ) ; } else { $ msg .= 'no message' ; } $ ... | Print an exception to the outpout . |
27,455 | public function write ( $ string , $ options = null ) { $ indent = str_repeat ( $ this -> _indentValue , $ this -> indent ( ) ) . $ this -> prefix ( ) ; if ( $ newLine = ( $ string && $ string [ strlen ( $ string ) - 1 ] === "\n" ) ) { $ string = substr ( $ string , 0 , - 1 ) ; } $ string = str_replace ( "\n" , "\n" . ... | Print a string to output . |
27,456 | public function format ( $ string , $ options = null ) { return $ this -> _colors ? Cli :: color ( $ string , $ options ) : $ string ; } | Format a string to output . |
27,457 | public function readableSize ( $ value , $ precision = 0 , $ base = 1024 ) { $ i = 0 ; if ( $ value < 1 ) { return '0' ; } $ units = [ '' , 'K' , 'M' , 'G' , 'T' , 'P' , 'E' , 'Z' , 'Y' ] ; while ( ( $ value / $ base ) >= 1 ) { $ value = $ value / $ base ; $ i ++ ; } $ unit = isset ( $ units [ $ i ] ) ? $ units [ $ i ]... | Humanizes values using an appropriate unit . |
27,458 | public function _reportSummary ( $ summary ) { $ passed = $ summary -> passed ( ) ; $ skipped = $ summary -> skipped ( ) ; $ pending = $ summary -> pending ( ) ; $ excluded = $ summary -> excluded ( ) ; $ failed = $ summary -> failed ( ) ; $ errored = $ summary -> errored ( ) ; $ expectation = $ summary -> expectation ... | Print a summary of specs execution to STDOUT |
27,459 | public static function before ( $ method , $ self , & $ args ) { if ( ! Suite :: registered ( ) ) { return false ; } list ( $ class , $ name ) = explode ( '::' , $ method ) ; $ lsb = is_object ( $ self ) ? get_class ( $ self ) : $ self ; if ( ! Suite :: registered ( $ lsb ) && ! Suite :: registered ( $ class ) ) { retu... | Point cut called before method execution . |
27,460 | protected static function _stubbedMethod ( $ lsb , $ self , $ class , $ name , $ args ) { if ( is_object ( $ self ) ) { $ list = $ lsb === $ class ? [ $ self , $ lsb ] : [ $ self , $ lsb , $ class ] ; } else { $ list = $ lsb === $ class ? [ $ lsb ] : [ $ lsb , $ class ] ; $ name = '::' . $ name ; } $ stub = static :: $... | Checks if the called method has been stubbed . |
27,461 | public function exception ( $ exception = null ) { if ( ! func_num_args ( ) ) { return $ this -> _exception ; } $ this -> _exception = $ exception ; return $ this ; } | Gets the exception related to the report . |
27,462 | public function backtrace ( $ backtrace = [ ] ) { if ( ! func_num_args ( ) ) { return $ this -> _backtrace ; } if ( $ this -> _backtrace = $ backtrace ) { foreach ( $ this -> _backtrace as $ trace ) { if ( isset ( $ trace [ 'file' ] ) ) { $ this -> _file = preg_replace ( '~' . preg_quote ( getcwd ( ) , '~' ) . '~' , ''... | Gets the backtrace related to the report . |
27,463 | public function add ( $ type , $ data = [ ] ) { if ( $ this -> type ( ) === 'passed' && $ type === 'failed' ) { $ this -> type ( 'failed' ) ; } $ data [ 'type' ] = $ type ; if ( ! isset ( $ data [ 'backtrace' ] ) ) { $ data [ 'backtrace' ] = [ ] ; } else { $ data [ 'backtrace' ] = Debugger :: focus ( $ this -> block ( ... | Adds an expectation report and emits a report event . |
27,464 | public static function patch ( $ source , $ dest = null ) { $ source = ltrim ( $ source , '\\' ) ; if ( is_object ( $ source ) || class_exists ( $ source ) ) { $ reference = $ source ; } else { $ reference = null ; if ( MonkeyPatcher :: blacklisted ( $ source ) ) { throw new Exception ( "Monkey patching `{$source}()` i... | Setup a monkey patch . |
27,465 | public static function patched ( $ namespace , $ className , $ methodName , & $ substitute = null ) { $ name = $ className ? : $ methodName ; if ( $ namespace && ( $ className || function_exists ( "{$namespace}\\{$name}" ) ) ) { $ name = "{$namespace}\\{$name}" ; } $ method = isset ( static :: $ _registered [ $ name ] ... | Patches the string . |
27,466 | public function _matcher ( $ matcherName , $ actual ) { if ( ! Matcher :: exists ( $ matcherName , true ) ) { throw new Exception ( "Unexisting matcher attached to `'{$matcherName}'`." ) ; } $ matcher = null ; foreach ( Matcher :: get ( $ matcherName , true ) as $ target => $ value ) { if ( ! $ target ) { $ matcher = $... | Returns a compatible matcher class name according to a passed actual value . |
27,467 | protected function _spin ( $ closure ) { $ timeout = $ this -> timeout ( ) ; if ( $ timeout <= 0 ) { $ closure ( ) ; } else { Code :: spin ( $ closure , $ timeout ) ; } } | Runs the expectation . |
27,468 | protected function _resolve ( ) { if ( ! $ this -> _deferred ) { return ; } $ data = $ this -> _deferred ; $ instance = $ data [ 'instance' ] ; $ this -> _not = $ data [ 'not' ] ; $ boolean = $ instance -> resolve ( ) ; $ data [ 'description' ] = $ instance -> description ( ) ; $ data [ 'backtrace' ] = $ instance -> ba... | Resolves deferred matchers . |
27,469 | protected function _log ( $ boolean , $ data = [ ] ) { $ not = $ this -> _not ; $ pass = $ not ? ! $ boolean : $ boolean ; if ( $ pass ) { $ data [ 'type' ] = 'passed' ; } else { $ data [ 'type' ] = 'failed' ; $ this -> _passed = false ; } $ description = $ data [ 'description' ] ; if ( is_array ( $ description ) ) { $... | Logs a result . |
27,470 | public function process ( ) { if ( ! $ this -> _processed ) { $ this -> _process ( ) ; $ this -> _resolve ( ) ; } $ this -> _processed = true ; return $ this -> _passed !== false ; } | Run the expectation . |
27,471 | public function clear ( ) { $ this -> _actual = null ; $ this -> _passed = null ; $ this -> _processed = null ; $ this -> _not = false ; $ this -> _timeout = 0 ; $ this -> _logs = [ ] ; $ this -> _deferred = null ; } | Clears the instance . |
27,472 | public function reset ( ) { $ this -> _passed = null ; $ this -> _expectations = [ ] ; $ this -> _log = new Log ( [ 'block' => $ this , 'backtrace' => $ this -> _backtrace ] ) ; return $ this ; } | Reset the specification . |
27,473 | public function waitsFor ( $ actual , $ timeout = 0 ) { $ timeout = $ timeout ? : $ this -> timeout ( ) ; $ closure = $ actual instanceof Closure ? $ actual : function ( ) use ( $ actual ) { return $ actual ; } ; $ spec = new static ( [ 'closure' => $ closure ] ) ; return $ this -> expect ( $ spec , $ timeout ) ; } | The waitsFor statement . |
27,474 | protected function _execute ( ) { $ result = null ; $ spec = function ( ) { $ this -> _expectations = [ ] ; $ closure = $ this -> _closure ; $ result = $ this -> _suite -> runBlock ( $ this , $ closure , 'specification' ) ; foreach ( $ this -> _expectations as $ expectation ) { $ this -> _passed = $ expectation -> proc... | Spec execution helper . |
27,475 | protected function _blockEnd ( $ runAfterEach = true ) { $ type = $ this -> log ( ) -> type ( ) ; foreach ( $ this -> _expectations as $ expectation ) { if ( ! ( $ logs = $ expectation -> logs ( ) ) && $ type !== 'errored' ) { $ this -> log ( ) -> type ( 'pending' ) ; } foreach ( $ logs as $ log ) { $ this -> log ( $ l... | End spec execution helper . |
27,476 | public function logs ( ) { $ logs = [ ] ; foreach ( $ this -> _expectations as $ expectation ) { foreach ( $ expectation -> logs ( ) as $ log ) { $ logs [ ] = $ log ; } } return $ logs ; } | Returns execution log . |
27,477 | public function start ( ) { if ( $ collector = end ( static :: $ _collectors ) ) { $ collector -> add ( $ collector -> _driver -> stop ( ) ) ; } static :: $ _collectors [ ] = $ this ; $ this -> _driver -> start ( ) ; return true ; } | Starts collecting coverage data . |
27,478 | public function stop ( $ mergeToParent = true ) { $ collector = end ( static :: $ _collectors ) ; if ( $ collector !== $ this ) { return false ; } array_pop ( static :: $ _collectors ) ; $ collected = $ this -> _driver -> stop ( ) ; $ this -> add ( $ collected ) ; $ collector = end ( static :: $ _collectors ) ; if ( ! ... | Stops collecting coverage data . |
27,479 | public function collectable ( $ file ) { $ file = $ this -> realpath ( $ file ) ; if ( preg_match ( "/eval\(\)'d code$/" , $ file ) || ! isset ( $ this -> _coverage [ $ file ] ) ) { return false ; } return true ; } | Checks if a filename is collectable . |
27,480 | public function realpath ( $ file ) { $ prefix = preg_quote ( $ this -> _prefix , '~' ) ; $ file = preg_replace ( "~^{$prefix}~" , '' , $ file ) ; if ( ! $ this -> _hasVolume ) { return $ file ; } if ( preg_match ( '~^[A-Z]+:~' , $ file ) ) { return $ file ; } $ file = ltrim ( $ file , DS ) ; $ pos = strpos ( $ file , ... | Gets the real path in the original src directory . |
27,481 | public function export ( $ file = null ) { if ( $ file ) { return isset ( $ this -> _coverage [ $ file ] ) ? $ this -> _coverage ( $ file , $ this -> _coverage [ $ file ] ) : [ ] ; } $ result = [ ] ; $ base = preg_quote ( $ this -> base ( ) , '~' ) ; foreach ( $ this -> _coverage as $ file => $ rawCoverage ) { if ( $ c... | Exports coverage data . |
27,482 | public function metrics ( ) { $ this -> _metrics = new Metrics ( ) ; foreach ( $ this -> _coverage as $ file => $ rawCoverage ) { $ root = $ this -> parse ( $ file ) ; $ coverage = $ this -> export ( $ file ) ; $ this -> _processed = [ 'loc' => - 1 , 'nlloc' => - 1 , 'lloc' => - 1 , 'cloc' => - 1 , 'coverage' => - 1 ] ... | Gets the collected metrics from coverage data . |
27,483 | public function parse ( $ file ) { if ( isset ( $ this -> _tree [ $ file ] ) ) { return $ this -> _tree [ $ file ] ; } $ parser = $ this -> _classes [ 'parser' ] ; return $ this -> _tree [ $ file ] = $ parser :: parse ( file_get_contents ( $ file ) , [ 'lines' => true ] ) ; } | Retruns & cache the tree structure of a file . |
27,484 | public function closure ( ) { if ( $ this -> _closures ) { if ( isset ( $ this -> _closures [ $ this -> _returnIndex ] ) ) { $ closure = $ this -> _closures [ $ this -> _returnIndex ++ ] ; } else { $ closure = end ( $ this -> _closures ) ; } return $ closure ; } elseif ( array_key_exists ( $ this -> _returnIndex , $ th... | Return a compatible callable . |
27,485 | public function toBe ( ) { if ( $ this -> reference ( ) ) { $ this -> _substitutes = func_get_args ( ) ; } else { $ this -> _actsAsAReplacement = true ; if ( func_num_args ( ) !== 1 ) { throw new Exception ( "Only one hard method substitution is allowed through `toBe()`." ) ; } $ this -> _closures = func_get_args ( ) ;... | Set return values . |
27,486 | public function andRun ( ) { if ( $ this -> _returns ) { throw new Exception ( "Some return value(s) has already been set." ) ; } $ closures = func_get_args ( ) ; foreach ( $ closures as $ closure ) { if ( ! is_callable ( $ closure ) ) { throw new Exception ( "The passed parameter is not callable." ) ; } } $ this -> _c... | Set the stub logic . |
27,487 | public function substitute ( ) { if ( isset ( $ this -> _substitutes [ $ this -> _substituteIndex ] ) ) { return $ this -> _substitutes [ $ this -> _substituteIndex ++ ] ; } return $ this -> _substitutes ? end ( $ this -> _substitutes ) : null ; } | Get the method substitute . |
27,488 | public static function log ( $ reference , $ call ) { $ calls = [ ] ; if ( is_array ( $ reference ) ) { foreach ( $ reference as $ value ) { $ calls [ ] = static :: _call ( $ value , $ call ) ; } } else { $ calls [ ] = static :: _call ( $ reference , $ call ) ; } static :: $ _logs [ ] = $ calls ; } | Logs a call . |
27,489 | public static function logs ( $ reference = null , $ index = 0 ) { if ( ! func_num_args ( ) ) { return static :: $ _logs ; } $ result = [ ] ; $ count = count ( static :: $ _logs ) ; for ( $ i = $ index ; $ i < $ count ; $ i ++ ) { $ logs = static :: $ _logs [ $ i ] ; if ( $ log = static :: _matchReference ( $ reference... | Get all logs or all logs related to an instance or a fully - namespaced class name . |
27,490 | public static function find ( $ message , $ index = 0 , $ times = 0 , & $ args = [ ] ) { $ success = false ; $ messages = ! is_array ( $ message ) ? [ $ message ] : $ message ; $ message = reset ( $ messages ) ; $ reference = $ message -> reference ( ) ; $ reference = $ message -> isStatic ( ) && is_object ( $ referenc... | Finds a logged call . |
27,491 | public static function export ( $ options ) { $ defaults = [ 'collector' => null , 'base_path' => getcwd ( ) ] ; $ options += $ defaults ; $ collector = $ options [ 'collector' ] ; $ export = [ ] ; $ base = $ options [ 'base_path' ] ? rtrim ( $ options [ 'base_path' ] , DS ) . DS : '' ; foreach ( $ collector -> export ... | Exports a coverage to a Istanbul compatible JSON format . |
27,492 | private function returnAfterRemoval ( Error404 $ error404 ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ errorRepository = $ em -> getRepository ( 'VictoireSeoBundle:HttpError' ) ; $ errors = ( $ error404 -> getType ( ) == HttpError :: TYPE_ROUTE ) ? $ errorRepository -> getRouteErrors ( ) : $ errorReposito... | Remove error if there is more than one record else return _empty template . |
27,493 | protected function getPrefix ( $ locale ) { foreach ( $ this -> localeResolver -> getDomainConfig ( ) as $ _domain => $ _locale ) { if ( $ _locale === $ locale ) { $ urlPrefix = sprintf ( '%s://%s' , $ this -> request ? $ this -> request -> getScheme ( ) : 'http' , $ _domain ) ; if ( $ this -> request && $ this -> requ... | If victoire_i18n . locale_pattern == domain then we force the url rewrite with a valid host . |
27,494 | public function newAction ( Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ template = new Template ( ) ; $ form = $ this -> container -> get ( 'form.factory' ) -> create ( TemplateType :: class , $ template ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em -> ... | create a new Template . |
27,495 | public function editAction ( Request $ request , Template $ template ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ form = $ this -> container -> get ( 'form.factory' ) -> create ( TemplateType :: class , $ template ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em -> persist (... | edit a Template . |
27,496 | public function handleError ( $ redirection , $ error404 ) { if ( $ redirection ) { $ this -> increaseCounter ( $ redirection ) ; return $ redirection ; } elseif ( $ error404 ) { $ this -> increaseCounter ( $ error404 ) ; return $ error404 ; } throw new NoResultException ( ) ; } | Check if the Error and its associated Redirection exists then increase the counter of the Error|Redirection . |
27,497 | public function getLoggedStatus ( ) { if ( $ this -> authorizationChecker -> isGranted ( 'IS_AUTHENTICATED_FULLY' ) ) { return true ; } elseif ( $ this -> authorizationChecker -> isGranted ( 'IS_AUTHENTICATED_REMEMBERED' ) ) { return true ; } return false ; } | Check actual status of current user return true if logged false if not . |
27,498 | public function updateViewCss ( $ oldHash , View $ view , array $ widgets ) { $ this -> removeCssFile ( $ oldHash ) ; $ this -> generateViewCss ( $ view , $ widgets ) ; } | Update css by removing old file and writing new file . |
27,499 | public function generateViewCss ( View $ view , array $ widgets ) { $ css = '' ; foreach ( $ widgets as $ widget ) { $ style = $ this -> container -> get ( 'templating' ) -> render ( 'VictoireCoreBundle:Widget:style/style.html.twig' , [ 'widget' => $ widget , 'victoire_twig_responsive' => $ this -> victoireTwigResponsi... | Construct css file and write it . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.