idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
3,100
public function add ( $ key , $ value ) { if ( ! is_null ( $ key ) ) { $ currentValue = Arr :: get ( $ this -> payload , $ key , [ ] ) ; if ( ! is_array ( $ currentValue ) ) { $ currentValue = Arr :: wrap ( $ currentValue ) ; } $ currentValue [ ] = $ value ; Arr :: set ( $ this -> payload , $ key , $ currentValue ) ; }...
Add a value .
3,101
public function addIfNotEmpty ( $ key , $ value ) { if ( empty ( $ value ) ) { return $ this ; } return $ this -> add ( $ key , $ value ) ; }
Add a value if it s not empty .
3,102
public function getName ( ) { $ name = $ this -> name ?? Str :: snake ( str_replace ( 'IndexConfigurator' , '' , class_basename ( $ this ) ) ) ; return config ( 'scout.prefix' ) . $ name ; }
Get th name .
3,103
protected function createWriteAlias ( ) { $ configurator = $ this -> getIndexConfigurator ( ) ; if ( ! in_array ( Migratable :: class , class_uses_recursive ( $ configurator ) ) ) { return ; } $ payload = ( new IndexPayload ( $ configurator ) ) -> set ( 'name' , $ configurator -> getWriteAlias ( ) ) -> get ( ) ; Elasti...
Create an write alias .
3,104
protected function isTargetIndexExists ( ) { $ targetIndex = $ this -> argument ( 'target-index' ) ; $ payload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> get ( ) ; return ElasticClient :: indices ( ) -> exists ( $ payload ) ; }
Checks if the target index exists .
3,105
protected function createTargetIndex ( ) { $ targetIndex = $ this -> argument ( 'target-index' ) ; $ sourceIndexConfigurator = $ this -> getModel ( ) -> getIndexConfigurator ( ) ; $ payload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> setIfNotEmpty ( 'body.settings' , $ sourceIndexConfigurator -> getS...
Create a target index .
3,106
protected function updateTargetIndex ( ) { $ targetIndex = $ this -> argument ( 'target-index' ) ; $ sourceIndexConfigurator = $ this -> getModel ( ) -> getIndexConfigurator ( ) ; $ targetIndexPayload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> get ( ) ; $ indices = ElasticClient :: indices ( ) ; try...
Update the target index .
3,107
protected function updateTargetIndexMapping ( ) { $ sourceModel = $ this -> getModel ( ) ; $ sourceIndexConfigurator = $ sourceModel -> getIndexConfigurator ( ) ; $ targetIndex = $ this -> argument ( 'target-index' ) ; $ targetType = $ sourceModel -> searchableAs ( ) ; $ mapping = array_merge_recursive ( $ sourceIndexC...
Update the target index mapping .
3,108
protected function isAliasExists ( $ name ) { $ payload = ( new RawPayload ( ) ) -> set ( 'name' , $ name ) -> get ( ) ; return ElasticClient :: indices ( ) -> existsAlias ( $ payload ) ; }
Check if an alias exists .
3,109
protected function deleteAlias ( $ name ) { $ aliases = $ this -> getAlias ( $ name ) ; if ( empty ( $ aliases ) ) { return ; } foreach ( $ aliases as $ index => $ alias ) { $ deletePayload = ( new RawPayload ( ) ) -> set ( 'index' , $ index ) -> set ( 'name' , $ name ) -> get ( ) ; ElasticClient :: indices ( ) -> dele...
Delete an alias .
3,110
protected function createAliasForTargetIndex ( $ name ) { $ targetIndex = $ this -> argument ( 'target-index' ) ; if ( $ this -> isAliasExists ( $ name ) ) { $ this -> deleteAlias ( $ name ) ; } $ payload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> set ( 'name' , $ name ) -> get ( ) ; ElasticClient :...
Create an alias for the target index .
3,111
protected function deleteSourceIndex ( ) { $ sourceIndexConfigurator = $ this -> getModel ( ) -> getIndexConfigurator ( ) ; if ( $ this -> isAliasExists ( $ sourceIndexConfigurator -> getName ( ) ) ) { $ aliases = $ this -> getAlias ( $ sourceIndexConfigurator -> getName ( ) ) ; foreach ( $ aliases as $ index => $ alia...
Delete the source index .
3,112
protected function updateIndex ( ) { $ configurator = $ this -> getIndexConfigurator ( ) ; $ indexPayload = ( new IndexPayload ( $ configurator ) ) -> get ( ) ; $ indices = ElasticClient :: indices ( ) ; if ( ! $ indices -> exists ( $ indexPayload ) ) { throw new LogicException ( sprintf ( 'Index %s doesn\'t exist' , $...
Update the index .
3,113
protected function createWriteAlias ( ) { $ configurator = $ this -> getIndexConfigurator ( ) ; if ( ! in_array ( Migratable :: class , class_uses_recursive ( $ configurator ) ) ) { return ; } $ indices = ElasticClient :: indices ( ) ; $ existsPayload = ( new RawPayload ( ) ) -> set ( 'name' , $ configurator -> getWrit...
Create a write alias .
3,114
public function useAlias ( $ alias ) { $ aliasGetter = 'get' . ucfirst ( $ alias ) . 'Alias' ; if ( ! method_exists ( $ this -> indexConfigurator , $ aliasGetter ) ) { throw new Exception ( sprintf ( 'The index configurator %s doesn\'t have getter for the %s alias.' , get_class ( $ this -> indexConfigurator ) , $ alias...
Use an alias .
3,115
public function getMapping ( ) { $ mapping = $ this -> mapping ?? [ ] ; if ( $ this :: usesSoftDelete ( ) && config ( 'scout.soft_delete' , false ) ) { Arr :: set ( $ mapping , 'properties.__soft_deleted' , [ 'type' => 'integer' ] ) ; } return $ mapping ; }
Get the mapping .
3,116
public function getSearchRules ( ) { return isset ( $ this -> searchRules ) && count ( $ this -> searchRules ) > 0 ? $ this -> searchRules : [ SearchRule :: class ] ; }
Get the search rules .
3,117
public static function search ( $ query , $ callback = null ) { $ softDelete = static :: usesSoftDelete ( ) && config ( 'scout.soft_delete' , false ) ; if ( $ query == '*' ) { return new FilterBuilder ( new static , $ callback , $ softDelete ) ; } else { return new SearchBuilder ( new static , $ query , $ callback , $ ...
Execute the search .
3,118
public function whereRegexp ( $ field , $ value , $ flags = 'ALL' ) { $ this -> wheres [ 'must' ] [ ] = [ 'regexp' => [ $ field => [ 'value' => $ value , 'flags' => $ flags , ] , ] , ] ; return $ this ; }
Add a whereRegexp condition .
3,119
public function whereGeoDistance ( $ field , $ value , $ distance ) { $ this -> wheres [ 'must' ] [ ] = [ 'geo_distance' => [ 'distance' => $ distance , $ field => $ value , ] , ] ; return $ this ; }
Add a whereGeoDistance condition .
3,120
public function select ( $ fields ) { $ this -> select = array_merge ( $ this -> select , Arr :: wrap ( $ fields ) ) ; return $ this ; }
Select one or many fields .
3,121
public static function formatExceptionAsDataArray ( Inspector $ inspector , $ shouldAddTrace ) { $ exception = $ inspector -> getException ( ) ; $ response = [ 'type' => get_class ( $ exception ) , 'message' => $ exception -> getMessage ( ) , 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) ,...
Returns all basic information about the exception in a simple array for further convertion to other languages
3,122
public function breakOnDelimiter ( $ delimiter , $ s ) { $ parts = explode ( $ delimiter , $ s ) ; foreach ( $ parts as & $ part ) { $ part = '<div class="delimiter">' . $ part . '</div>' ; } return implode ( $ delimiter , $ parts ) ; }
Makes sure that the given string breaks on the delimiter .
3,123
public function shorten ( $ path ) { if ( $ this -> applicationRootPath != "/" ) { $ path = str_replace ( $ this -> applicationRootPath , '&hellip;' , $ path ) ; } return $ path ; }
Replace the part of the path that all files have in common .
3,124
public function dumpArgs ( Frame $ frame ) { if ( ! $ this -> getDumper ( ) ) { return '' ; } $ html = '' ; $ numFrames = count ( $ frame -> getArgs ( ) ) ; if ( $ numFrames > 0 ) { $ html = '<ol class="linenums">' ; foreach ( $ frame -> getArgs ( ) as $ j => $ frameArg ) { $ html .= '<li>' . $ this -> dump ( $ frameAr...
Format the args of the given Frame as a human readable html string
3,125
public function slug ( $ original ) { $ slug = str_replace ( " " , "-" , $ original ) ; $ slug = preg_replace ( '/[^\w\d\-\_]/i' , '' , $ slug ) ; return strtolower ( $ slug ) ; }
Convert a string to a slug version of itself
3,126
public function render ( $ template , array $ additionalVariables = null ) { $ variables = $ this -> getVariables ( ) ; $ variables [ "tpl" ] = $ this ; if ( $ additionalVariables !== null ) { $ variables = array_replace ( $ variables , $ additionalVariables ) ; } call_user_func ( function ( ) { extract ( func_get_arg ...
Given a template path render it within its own scope . This method also accepts an array of additional variables to be passed to the template .
3,127
public function pushHandler ( $ handler ) { if ( is_callable ( $ handler ) ) { $ handler = new CallbackHandler ( $ handler ) ; } if ( ! $ handler instanceof HandlerInterface ) { throw new InvalidArgumentException ( "Argument to " . __METHOD__ . " must be a callable, or instance of " . "Whoops\\Handler\\HandlerInterface...
Pushes a handler to the end of the stack
3,128
public function unregister ( ) { if ( $ this -> isRegistered ) { $ this -> system -> restoreExceptionHandler ( ) ; $ this -> system -> restoreErrorHandler ( ) ; $ this -> isRegistered = false ; } return $ this ; }
Unregisters all handlers registered by this Whoops \ Run instance
3,129
public function allowQuit ( $ exit = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> allowQuit ; } return $ this -> allowQuit = ( bool ) $ exit ; }
Should Whoops allow Handlers to force the script to quit?
3,130
public function silenceErrorsInPaths ( $ patterns , $ levels = 10240 ) { $ this -> silencedPatterns = array_merge ( $ this -> silencedPatterns , array_map ( function ( $ pattern ) use ( $ levels ) { return [ "pattern" => $ pattern , "levels" => $ levels , ] ; } , ( array ) $ patterns ) ) ; return $ this ; }
Silence particular errors in particular files
3,131
public function writeToOutput ( $ send = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> sendOutput ; } return $ this -> sendOutput = ( bool ) $ send ; }
Should Whoops push output directly to the client? If this is false output will be returned by handleException
3,132
public static function translateErrorCode ( $ error_code ) { $ constants = get_defined_constants ( true ) ; if ( array_key_exists ( 'Core' , $ constants ) ) { foreach ( $ constants [ 'Core' ] as $ constant => $ value ) { if ( substr ( $ constant , 0 , 2 ) == 'E_' && $ value == $ error_code ) { return $ constant ; } } }...
Translate ErrorException code into the represented constant .
3,133
public function getPreviousExceptionInspector ( ) { if ( $ this -> previousExceptionInspector === null ) { $ previousException = $ this -> exception -> getPrevious ( ) ; if ( $ previousException ) { $ this -> previousExceptionInspector = new Inspector ( $ previousException ) ; } } return $ this -> previousExceptionInsp...
Returns an Inspector for a previous Exception if any .
3,134
public function getPreviousExceptions ( ) { if ( $ this -> previousExceptions === null ) { $ this -> previousExceptions = [ ] ; $ prev = $ this -> exception -> getPrevious ( ) ; while ( $ prev !== null ) { $ this -> previousExceptions [ ] = $ prev ; $ prev = $ prev -> getPrevious ( ) ; } } return $ this -> previousExce...
Returns an array of all previous exceptions for this inspector s exception
3,135
protected function getTrace ( $ e ) { $ traces = $ e -> getTrace ( ) ; if ( ! $ e instanceof \ ErrorException ) { return $ traces ; } if ( ! Misc :: isLevelFatal ( $ e -> getSeverity ( ) ) ) { return $ traces ; } if ( ! extension_loaded ( 'xdebug' ) || ! xdebug_is_enabled ( ) ) { return [ ] ; } $ stack = array_reverse ...
Gets the backtrace from an exception .
3,136
protected function getExceptionFrames ( ) { $ frames = $ this -> getInspector ( ) -> getFrames ( ) ; if ( $ this -> getApplicationPaths ( ) ) { foreach ( $ frames as $ frame ) { foreach ( $ this -> getApplicationPaths ( ) as $ path ) { if ( strpos ( $ frame -> getFile ( ) , $ path ) === 0 ) { $ frame -> setApplication ...
Get the stack trace frames of the exception that is currently being handled .
3,137
protected function getExceptionCode ( ) { $ exception = $ this -> getException ( ) ; $ code = $ exception -> getCode ( ) ; if ( $ exception instanceof \ ErrorException ) { $ code = Misc :: translateErrorCode ( $ exception -> getSeverity ( ) ) ; } return ( string ) $ code ; }
Get the code of the exception that is currently being handled .
3,138
public function handleUnconditionally ( $ value = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> handleUnconditionally ; } $ this -> handleUnconditionally = ( bool ) $ value ; }
Allows to disable all attempts to dynamically decide whether to handle or return prematurely . Set this to ensure that the handler will perform no matter what .
3,139
public function getEditorHref ( $ filePath , $ line ) { $ editor = $ this -> getEditor ( $ filePath , $ line ) ; if ( empty ( $ editor ) ) { return false ; } if ( ! isset ( $ editor [ 'url' ] ) || ! is_string ( $ editor [ 'url' ] ) ) { throw new UnexpectedValueException ( __METHOD__ . " should always resolve to a strin...
Given a string file path and an integer file line executes the editor resolver and returns if available a string that may be used as the href property for that file reference .
3,140
protected function getResource ( $ resource ) { if ( isset ( $ this -> resourceCache [ $ resource ] ) ) { return $ this -> resourceCache [ $ resource ] ; } foreach ( $ this -> searchPaths as $ path ) { $ fullPath = $ path . "/$resource" ; if ( is_file ( $ fullPath ) ) { $ this -> resourceCache [ $ resource ] = $ fullPa...
Finds a resource by its relative path in all available search paths . The search is performed starting at the last search path and all the way back to the first enabling a cascading - type system of overrides for all resources .
3,141
public function setLogger ( $ logger = null ) { if ( ! ( is_null ( $ logger ) || $ logger instanceof LoggerInterface ) ) { throw new InvalidArgumentException ( 'Argument to ' . __METHOD__ . " must be a valid Logger Interface (aka. Monolog), " . get_class ( $ logger ) . ' given.' ) ; } $ this -> logger = $ logger ; }
Set the output logger interface .
3,142
public function addTraceToOutput ( $ addTraceToOutput = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> addTraceToOutput ; } $ this -> addTraceToOutput = ( bool ) $ addTraceToOutput ; return $ this ; }
Add error trace to output .
3,143
public function addTraceFunctionArgsToOutput ( $ addTraceFunctionArgsToOutput = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> addTraceFunctionArgsToOutput ; } if ( ! is_integer ( $ addTraceFunctionArgsToOutput ) ) { $ this -> addTraceFunctionArgsToOutput = ( bool ) $ addTraceFunctionArgsToOutput ; } else { ...
Add error trace function arguments to output . Set to True for all frame args or integer for the n first frame args .
3,144
public function generateResponse ( ) { $ exception = $ this -> getException ( ) ; return sprintf ( "%s: %s in file %s on line %d%s\n" , get_class ( $ exception ) , $ exception -> getMessage ( ) , $ exception -> getFile ( ) , $ exception -> getLine ( ) , $ this -> getTraceOutput ( ) ) ; }
Create plain text response and return it as a string
3,145
public function loggerOnly ( $ loggerOnly = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> loggerOnly ; } $ this -> loggerOnly = ( bool ) $ loggerOnly ; }
Only output to logger .
3,146
private function getTraceOutput ( ) { if ( ! $ this -> addTraceToOutput ( ) ) { return '' ; } $ inspector = $ this -> getInspector ( ) ; $ frames = $ inspector -> getFrames ( ) ; $ response = "\nStack trace:" ; $ line = 1 ; foreach ( $ frames as $ frame ) { $ class = $ frame -> getClass ( ) ; $ template = "\n%3d. %s->%...
Get the exception trace as plain text .
3,147
public function map ( $ callable ) { $ this -> frames = array_map ( function ( $ frame ) use ( $ callable ) { $ frame = call_user_func ( $ callable , $ frame ) ; if ( ! $ frame instanceof Frame ) { throw new UnexpectedValueException ( "Callable to " . __METHOD__ . " must return a Frame object" ) ; } return $ frame ; } ...
Map the collection of frames
3,148
public function topDiff ( FrameCollection $ parentFrames ) { $ diff = $ this -> frames ; $ parentFrames = $ parentFrames -> getArray ( ) ; $ p = count ( $ parentFrames ) - 1 ; for ( $ i = count ( $ diff ) - 1 ; $ i >= 0 && $ p >= 0 ; $ i -- ) { $ tailFrame = $ diff [ $ i ] ; if ( $ tailFrame -> equals ( $ parentFrames ...
Gets the innermost part of stack trace that is not the same as that of outer exception
3,149
public function getComments ( $ filter = null ) { $ comments = $ this -> comments ; if ( $ filter !== null ) { $ comments = array_filter ( $ comments , function ( $ c ) use ( $ filter ) { return $ c [ 'context' ] == $ filter ; } ) ; } return $ comments ; }
Returns all comments for this frame . Optionally allows a filter to only retrieve comments from a specific context .
3,150
public function getFileLines ( $ start = 0 , $ length = null ) { if ( null !== ( $ contents = $ this -> getFileContents ( ) ) ) { $ lines = explode ( "\n" , $ contents ) ; if ( $ length !== null ) { $ start = ( int ) $ start ; $ length = ( int ) $ length ; if ( $ start < 0 ) { $ start = 0 ; } if ( $ length <= 0 ) { thr...
Returns the contents of the file for this frame as an array of lines and optionally as a clamped range of lines .
3,151
public function serialize ( ) { $ frame = $ this -> frame ; if ( ! empty ( $ this -> comments ) ) { $ frame [ '_comments' ] = $ this -> comments ; } return serialize ( $ frame ) ; }
Implements the Serializable interface with special steps to also save the existing comments .
3,152
public function unserialize ( $ serializedFrame ) { $ frame = unserialize ( $ serializedFrame ) ; if ( ! empty ( $ frame [ '_comments' ] ) ) { $ this -> comments = $ frame [ '_comments' ] ; unset ( $ frame [ '_comments' ] ) ; } $ this -> frame = $ frame ; }
Unserializes the frame data while also preserving any existing comment data .
3,153
public function equals ( Frame $ frame ) { if ( ! $ this -> getFile ( ) || $ this -> getFile ( ) === 'Unknown' || ! $ this -> getLine ( ) ) { return false ; } return $ frame -> getFile ( ) === $ this -> getFile ( ) && $ frame -> getLine ( ) === $ this -> getLine ( ) ; }
Compares Frame against one another
3,154
private function getColumnConstraintSQL ( $ table , $ column ) { return "SELECT SysObjects.[Name] FROM SysObjects INNER JOIN (SELECT [Name],[ID] FROM SysObjects WHERE XType = 'U') AS Tab ON Tab.[ID] = Sysobjects.[Parent_Obj] INNER JOIN sys.default_constraints DefCons ON DefCons.[object_...
Returns the SQL to retrieve the constraints for a given column .
3,155
private function closeActiveDatabaseConnections ( $ database ) { $ database = new Identifier ( $ database ) ; $ this -> _execSql ( sprintf ( 'ALTER DATABASE %s SET SINGLE_USER WITH ROLLBACK IMMEDIATE' , $ database -> getQuotedName ( $ this -> _platform ) ) ) ; }
Closes currently active connections on the given database .
3,156
public function getSQL ( ) { if ( $ this -> sql !== null && $ this -> state === self :: STATE_CLEAN ) { return $ this -> sql ; } switch ( $ this -> type ) { case self :: INSERT : $ sql = $ this -> getSQLForInsert ( ) ; break ; case self :: DELETE : $ sql = $ this -> getSQLForDelete ( ) ; break ; case self :: UPDATE : $...
Gets the complete SQL string formed by the current specifications of this QueryBuilder .
3,157
public function setParameter ( $ key , $ value , $ type = null ) { if ( $ type !== null ) { $ this -> paramTypes [ $ key ] = $ type ; } $ this -> params [ $ key ] = $ value ; return $ this ; }
Sets a query parameter for the query being constructed .
3,158
public function setParameters ( array $ params , array $ types = [ ] ) { $ this -> paramTypes = $ types ; $ this -> params = $ params ; return $ this ; }
Sets a collection of query parameters for the query being constructed .
3,159
public function groupBy ( $ groupBy ) { if ( empty ( $ groupBy ) ) { return $ this ; } $ groupBy = is_array ( $ groupBy ) ? $ groupBy : func_get_args ( ) ; return $ this -> add ( 'groupBy' , $ groupBy , false ) ; }
Specifies a grouping over the results of the query . Replaces any previously specified groupings if any .
3,160
private function getSQLForInsert ( ) { return 'INSERT INTO ' . $ this -> sqlParts [ 'from' ] [ 'table' ] . ' (' . implode ( ', ' , array_keys ( $ this -> sqlParts [ 'values' ] ) ) . ')' . ' VALUES(' . implode ( ', ' , $ this -> sqlParts [ 'values' ] ) . ')' ; }
Converts this instance into an INSERT string in SQL .
3,161
public function createPositionalParameter ( $ value , $ type = ParameterType :: STRING ) { $ this -> boundCounter ++ ; $ this -> setParameter ( $ this -> boundCounter , $ value , $ type ) ; return '?' ; }
Creates a new positional parameter and bind the given value to it .
3,162
protected function _constructPdoDsn ( array $ params ) { $ dsn = 'sqlite:' ; if ( isset ( $ params [ 'path' ] ) ) { $ dsn .= $ params [ 'path' ] ; } elseif ( isset ( $ params [ 'memory' ] ) ) { $ dsn .= ':memory:' ; } return $ dsn ; }
Constructs the Sqlite PDO DSN .
3,163
public static function getPlaceholderPositions ( $ statement , $ isPositional = true ) { return $ isPositional ? self :: getPositionalPlaceholderPositions ( $ statement ) : self :: getNamedPlaceholderPositions ( $ statement ) ; }
Gets an array of the placeholders in an sql statements as keys and their positions in the query string .
3,164
private static function getPositionalPlaceholderPositions ( string $ statement ) : array { return self :: collectPlaceholders ( $ statement , '?' , self :: POSITIONAL_TOKEN , static function ( string $ _ , int $ placeholderPosition , int $ fragmentPosition , array & $ carry ) : void { $ carry [ ] = $ placeholderPositio...
Returns a zero - indexed list of placeholder position .
3,165
private static function getNamedPlaceholderPositions ( string $ statement ) : array { return self :: collectPlaceholders ( $ statement , ':' , self :: NAMED_TOKEN , static function ( string $ placeholder , int $ placeholderPosition , int $ fragmentPosition , array & $ carry ) : void { $ carry [ $ placeholderPosition + ...
Returns a map of placeholder positions to their parameter names .
3,166
private function isUnchangedBinaryColumn ( ColumnDiff $ columnDiff ) { $ columnType = $ columnDiff -> column -> getType ( ) ; if ( ! $ columnType instanceof BinaryType && ! $ columnType instanceof BlobType ) { return false ; } $ fromColumn = $ columnDiff -> fromColumn instanceof Column ? $ columnDiff -> fromColumn : nu...
Checks whether a given column diff is a logically unchanged binary type column .
3,167
private function convertSingleBooleanValue ( $ value , $ callback ) { if ( $ value === null ) { return $ callback ( null ) ; } if ( is_bool ( $ value ) || is_numeric ( $ value ) ) { return $ callback ( ( bool ) $ value ) ; } if ( ! is_string ( $ value ) ) { return $ callback ( true ) ; } if ( in_array ( strtolower ( tr...
Converts a single boolean value .
3,168
private function doConvertBooleans ( $ item , $ callback ) { if ( is_array ( $ item ) ) { foreach ( $ item as $ key => $ value ) { $ item [ $ key ] = $ this -> convertSingleBooleanValue ( $ value , $ callback ) ; } return $ item ; } return $ this -> convertSingleBooleanValue ( $ item , $ callback ) ; }
Converts one or multiple boolean values .
3,169
private function typeChangeBreaksDefaultValue ( ColumnDiff $ columnDiff ) : bool { if ( ! $ columnDiff -> fromColumn ) { return $ columnDiff -> hasChanged ( 'type' ) ; } $ oldTypeIsNumeric = $ this -> isNumericType ( $ columnDiff -> fromColumn -> getType ( ) ) ; $ newTypeIsNumeric = $ this -> isNumericType ( $ columnDi...
Check whether the type of a column is changed in a way that invalidates the default value for the column
3,170
private static function findPlaceholderOrOpeningQuote ( $ statement , & $ tokenOffset , & $ fragmentOffset , & $ fragments , & $ currentLiteralDelimiter , & $ paramMap ) { $ token = self :: findToken ( $ statement , $ tokenOffset , '/[?\'"]/' ) ; if ( ! $ token ) { return false ; } if ( $ token === '?' ) { $ position =...
Finds next placeholder or opening quote .
3,171
private static function findClosingQuote ( $ statement , & $ tokenOffset , & $ currentLiteralDelimiter ) { $ token = self :: findToken ( $ statement , $ tokenOffset , '/' . preg_quote ( $ currentLiteralDelimiter , '/' ) . '/' ) ; if ( ! $ token ) { return false ; } $ currentLiteralDelimiter = false ; ++ $ tokenOffset ;...
Finds closing quote
3,172
private static function findToken ( $ statement , & $ offset , $ regex ) { if ( preg_match ( $ regex , $ statement , $ matches , PREG_OFFSET_CAPTURE , $ offset ) ) { $ offset = $ matches [ 0 ] [ 1 ] ; return $ matches [ 0 ] [ 0 ] ; } return null ; }
Finds the token described by regex starting from the given offset . Updates the offset with the position where the token was found .
3,173
private function convertParameterType ( int $ type ) : int { switch ( $ type ) { case ParameterType :: BINARY : return OCI_B_BIN ; case ParameterType :: LARGE_OBJECT : return OCI_B_BLOB ; default : return SQLT_CHR ; } }
Converts DBAL parameter type to oci8 parameter type
3,174
public function getQuotedLocalColumns ( AbstractPlatform $ platform ) { $ columns = [ ] ; foreach ( $ this -> _localColumnNames as $ column ) { $ columns [ ] = $ column -> getQuotedName ( $ platform ) ; } return $ columns ; }
Returns the quoted representation of the referencing table column names the foreign key constraint is associated with .
3,175
public function getUnqualifiedForeignTableName ( ) { $ name = $ this -> _foreignTableName -> getName ( ) ; $ position = strrpos ( $ name , '.' ) ; if ( $ position !== false ) { $ name = substr ( $ name , $ position ) ; } return strtolower ( $ name ) ; }
Returns the non - schema qualified foreign table name .
3,176
public function getQuotedForeignColumns ( AbstractPlatform $ platform ) { $ columns = [ ] ; foreach ( $ this -> _foreignColumnNames as $ column ) { $ columns [ ] = $ column -> getQuotedName ( $ platform ) ; } return $ columns ; }
Returns the quoted representation of the referenced table column names the foreign key constraint is associated with .
3,177
private function onEvent ( $ event ) { if ( isset ( $ this -> _options [ $ event ] ) ) { $ onEvent = strtoupper ( $ this -> _options [ $ event ] ) ; if ( ! in_array ( $ onEvent , [ 'NO ACTION' , 'RESTRICT' ] ) ) { return $ onEvent ; } } return false ; }
Returns the referential action for a given database operation on the referenced table the foreign key constraint is associated with .
3,178
public function intersectsIndexColumns ( Index $ index ) { foreach ( $ index -> getColumns ( ) as $ indexColumn ) { foreach ( $ this -> _localColumnNames as $ localColumn ) { if ( strtolower ( $ indexColumn ) === strtolower ( $ localColumn -> getName ( ) ) ) { return true ; } } } return false ; }
Checks whether this foreign key constraint intersects the given index columns .
3,179
public function startDatabase ( $ database ) { assert ( $ this -> _platform instanceof SQLAnywherePlatform ) ; $ this -> _execSql ( $ this -> _platform -> getStartDatabaseSQL ( $ database ) ) ; }
Starts a database .
3,180
public function stopDatabase ( $ database ) { assert ( $ this -> _platform instanceof SQLAnywherePlatform ) ; $ this -> _execSql ( $ this -> _platform -> getStopDatabaseSQL ( $ database ) ) ; }
Stops a database .
3,181
private function constructPdoDsn ( array $ params ) { $ dsn = 'oci:dbname=' . $ this -> getEasyConnectString ( $ params ) ; if ( isset ( $ params [ 'charset' ] ) ) { $ dsn .= ';charset=' . $ params [ 'charset' ] ; } return $ dsn ; }
Constructs the Oracle PDO DSN .
3,182
private function getOracleMysqlVersionNumber ( string $ versionString ) : string { if ( ! preg_match ( '/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/' , $ versionString , $ versionParts ) ) { throw DBALException :: invalidPlatformVersionSpecified ( $ versionString , '<major_version>.<minor_version>.<patch...
Get a normalized version number from the server string returned by Oracle MySQL servers .
3,183
private function getMariaDbMysqlVersionNumber ( string $ versionString ) : string { if ( ! preg_match ( '/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i' , $ versionString , $ versionParts ) ) { throw DBALException :: invalidPlatformVersionSpecified ( $ versionString , '^(?:5\.5\.5-)?(mariadb...
Detect MariaDB server version including hack for some mariadb distributions that starts with the prefix 5 . 5 . 5 -
3,184
private function getNonAutoincrementPrimaryKeyDefinition ( array $ columns , array $ options ) : string { if ( empty ( $ options [ 'primary' ] ) ) { return '' ; } $ keyColumns = array_unique ( array_values ( $ options [ 'primary' ] ) ) ; foreach ( $ keyColumns as $ keyColumn ) { if ( ! empty ( $ columns [ $ keyColumn ]...
Generate a PRIMARY KEY definition if no autoincrement value is used
3,185
public function bindValue ( $ name , $ value , $ type = ParameterType :: STRING ) { $ this -> params [ $ name ] = $ value ; $ this -> types [ $ name ] = $ type ; if ( $ type !== null ) { if ( is_string ( $ type ) ) { $ type = Type :: getType ( $ type ) ; } if ( $ type instanceof Type ) { $ value = $ type -> convertToDa...
Binds a parameter value to the statement .
3,186
public function bindParam ( $ name , & $ var , $ type = ParameterType :: STRING , $ length = null ) { $ this -> params [ $ name ] = $ var ; $ this -> types [ $ name ] = $ type ; return $ this -> stmt -> bindParam ( $ name , $ var , $ type , $ length ) ; }
Binds a parameter to a value by reference .
3,187
public function execute ( $ params = null ) { if ( is_array ( $ params ) ) { $ this -> params = $ params ; } $ logger = $ this -> conn -> getConfiguration ( ) -> getSQLLogger ( ) ; if ( $ logger ) { $ logger -> startQuery ( $ this -> sql , $ this -> params , $ this -> types ) ; } try { $ stmt = $ this -> stmt -> execut...
Executes the statement with the currently bound parameters .
3,188
protected function getAlterTableAddColumnClause ( Column $ column ) { return 'ADD ' . $ this -> getColumnDeclarationSQL ( $ column -> getQuotedName ( $ this ) , $ column -> toArray ( ) ) ; }
Returns the SQL clause for creating a column in a table alteration .
3,189
protected function getAlterTableRenameColumnClause ( $ oldColumnName , Column $ column ) { $ oldColumnName = new Identifier ( $ oldColumnName ) ; return 'RENAME ' . $ oldColumnName -> getQuotedName ( $ this ) . ' TO ' . $ column -> getQuotedName ( $ this ) ; }
Returns the SQL clause for renaming a column in a table alteration .
3,190
protected function getAlterTableChangeColumnClause ( ColumnDiff $ columnDiff ) { $ column = $ columnDiff -> column ; if ( ! ( $ columnDiff -> hasChanged ( 'comment' ) && count ( $ columnDiff -> changedProperties ) === 1 ) ) { $ columnAlterationClause = 'ALTER ' . $ this -> getColumnDeclarationSQL ( $ column -> getQuote...
Returns the SQL clause for altering a column in a table alteration .
3,191
public function getForeignKeyMatchClauseSQL ( $ type ) { switch ( ( int ) $ type ) { case self :: FOREIGN_KEY_MATCH_SIMPLE : return 'SIMPLE' ; break ; case self :: FOREIGN_KEY_MATCH_FULL : return 'FULL' ; break ; case self :: FOREIGN_KEY_MATCH_SIMPLE_UNIQUE : return 'UNIQUE SIMPLE' ; break ; case self :: FOREIGN_KEY_MA...
Returns foreign key MATCH clause for given type .
3,192
public function getPrimaryKeyDeclarationSQL ( Index $ index , $ name = null ) { if ( ! $ index -> isPrimary ( ) ) { throw new InvalidArgumentException ( 'Can only create primary key declarations with getPrimaryKeyDeclarationSQL()' ) ; } return $ this -> getTableConstraintDeclarationSQL ( $ index , $ name ) ; }
Obtain DBMS specific SQL code portion needed to set a primary key declaration to be used in statements like ALTER TABLE .
3,193
protected function getAdvancedIndexOptionsSQL ( Index $ index ) { $ sql = '' ; if ( ! $ index -> isPrimary ( ) && $ index -> hasFlag ( 'for_olap_workload' ) ) { $ sql .= ' FOR OLAP WORKLOAD' ; } return $ sql ; }
Return the INDEX query section dealing with non - standard SQL Anywhere options .
3,194
protected function getTableConstraintDeclarationSQL ( Constraint $ constraint , $ name = null ) { if ( $ constraint instanceof ForeignKeyConstraint ) { return $ this -> getForeignKeyDeclarationSQL ( $ constraint ) ; } if ( ! $ constraint instanceof Index ) { throw new InvalidArgumentException ( 'Unsupported constraint ...
Returns the SQL snippet for creating a table constraint .
3,195
public function splitFederation ( $ splitDistributionValue ) { $ type = Type :: getType ( $ this -> distributionType ) ; $ sql = 'ALTER FEDERATION ' . $ this -> getFederationName ( ) . ' ' . 'SPLIT AT (' . $ this -> getDistributionKey ( ) . ' = ' . $ this -> conn -> quote ( $ splitDistributionValue , $ type -> getBindi...
Splits Federation at a given distribution value .
3,196
public static function compare ( $ version ) { $ currentVersion = str_replace ( ' ' , '' , strtolower ( self :: VERSION ) ) ; $ version = str_replace ( ' ' , '' , $ version ) ; return version_compare ( $ version , $ currentVersion ) ; }
Compares a Doctrine version with the current one .
3,197
public function connect ( $ shardId = null ) { if ( $ shardId === null && $ this -> _conn ) { return false ; } if ( $ shardId !== null && $ shardId === $ this -> activeShardId ) { return false ; } if ( $ this -> getTransactionNestingLevel ( ) > 0 ) { throw new ShardingException ( 'Cannot switch shard when transaction i...
Connects to a given shard .
3,198
public function connect ( ) { if ( $ this -> isConnected ) { return false ; } $ driverOptions = $ this -> params [ 'driverOptions' ] ?? [ ] ; $ user = $ this -> params [ 'user' ] ?? null ; $ password = $ this -> params [ 'password' ] ?? null ; $ this -> _conn = $ this -> _driver -> connect ( $ this -> params , $ user ,...
Establishes the connection with the database .
3,199
private function detectDatabasePlatform ( ) { $ version = $ this -> getDatabasePlatformVersion ( ) ; if ( $ version !== null ) { assert ( $ this -> _driver instanceof VersionAwarePlatformDriver ) ; $ this -> platform = $ this -> _driver -> createDatabasePlatformForVersion ( $ version ) ; } else { $ this -> platform = $...
Detects and sets the database platform .