_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q17300
FindsAndCreatesAbilities.getEntityInstance
train
protected function getEntityInstance($model) { if ($model === '*') { return '*'; } if ( ! $model instanceof Model) { return new $model; } // Creating an ability for a non-existent model gives the authority that // ability on all instances of ...
php
{ "resource": "" }
q17301
FindsAndCreatesAbilities.abilitiesByName
train
protected function abilitiesByName($abilities, $attributes = []) { $abilities = array_unique(is_array($abilities) ? $abilities : [$abilities]); if (empty($abilities)) { return new Collection; } $existing =
php
{ "resource": "" }
q17302
FindsAndCreatesAbilities.createMissingAbilities
train
protected function createMissingAbilities($existing, array $abilities, $attributes = []) { $missing = array_diff($abilities, $existing->pluck('name')->all()); return array_map(function ($ability) use ($attributes) {
php
{ "resource": "" }
q17303
Factory.create
train
public function create() { $gate = $this->getGate(); $guard = $this->getGuard(); $bouncer = (new Bouncer($guard))->setGate($gate); if ($this->registerAtGate) { $guard->registerAt($gate); }
php
{ "resource": "" }
q17304
Factory.getGate
train
protected function getGate() { if ($this->gate) { return $this->gate; }
php
{ "resource": "" }
q17305
AbilitiesForModel.constrain
train
public function constrain($query, $model, $strict = false) { if ($model === '*') { return $this->constrainByWildcard($query); }
php
{ "resource": "" }
q17306
AbilitiesForModel.modelAbilityConstraint
train
protected function modelAbilityConstraint(Model $model, $strict) { return function ($query) use ($model, $strict) { $query->where("{$this->table}.entity_type", $model->getMorphClass());
php
{ "resource": "" }
q17307
AbilitiesForModel.abilitySubqueryConstraint
train
protected function abilitySubqueryConstraint(Model $model, $strict) { return function ($query) use ($model, $strict) { // If the model does not exist, we want to search for blanket abilities // that cover all instances of this model. If it does
php
{ "resource": "" }
q17308
BaseTenantScope.register
train
public static function register($model) { if (interface_exists(EloquentScope::class)) { $model::addGlobalScope(new TenantScope);
php
{ "resource": "" }
q17309
ForbidsAbilities.forbidAbilities
train
protected function forbidAbilities(array $ids, Model $authority = null) { $ids = array_diff($ids, $this->getAssociatedAbilityIds($authority, $ids, true)); if (is_null($authority)) {
php
{ "resource": "" }
q17310
ForbidsAbilities.forbidAbilitiesToAuthority
train
protected function forbidAbilitiesToAuthority(array $ids, Model $authority) { $attributes = Models::scope()->getAttachAttributes(get_class($authority));
php
{ "resource": "" }
q17311
ForbidsAbilities.forbidAbilitiesToEveryone
train
protected function forbidAbilitiesToEveryone(array $ids) { $attributes = Models::scope()->getAttachAttributes() + ['forbidden' => true]; $records = array_map(function ($id) use ($attributes) {
php
{ "resource": "" }
q17312
GrantFactory.getGrant
train
public function getGrant($name) { if (empty($this->registry[$name])) {
php
{ "resource": "" }
q17313
GrantFactory.registerDefaultGrant
train
protected function registerDefaultGrant($name) { // PascalCase the grant. E.g: 'authorization_code' becomes 'AuthorizationCode' $class = str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $name))); $class
php
{ "resource": "" }
q17314
ProviderRedirectTrait.followRequestRedirects
train
protected function followRequestRedirects(RequestInterface $request) { $response = null; $attempts = 0; while ($attempts < $this->redirectLimit) { $attempts++; $response = $this->getHttpClient()->send($request, [
php
{ "resource": "" }
q17315
ProviderRedirectTrait.isRedirect
train
protected function isRedirect(ResponseInterface $response) { $statusCode =
php
{ "resource": "" }
q17316
ProviderRedirectTrait.setRedirectLimit
train
public function setRedirectLimit($limit) { if (!is_int($limit)) { throw new InvalidArgumentException('redirectLimit must be an integer.'); } if ($limit < 1) { throw
php
{ "resource": "" }
q17317
ArrayAccessorTrait.getValueByKey
train
private function getValueByKey(array $data, $key, $default = null) { if (!is_string($key) || empty($key) || !count($data)) { return $default; } if (strpos($key, '.') !== false) { $keys = explode('.', $key);
php
{ "resource": "" }
q17318
MacAuthorizationTrait.getAuthorizationHeaders
train
protected function getAuthorizationHeaders($token = null) { if ($token === null) { return []; } $ts = time(); $id = $this->getTokenId($token); $nonce = $this->getRandomState(16); $mac = $this->getMacSignature($id, $ts, $nonce); $parts = [...
php
{ "resource": "" }
q17319
RequestFactory.getRequestWithOptions
train
public function getRequestWithOptions($method, $uri, array $options = []) { $options = $this->parseOptions($options); return $this->getRequest( $method,
php
{ "resource": "" }
q17320
AbstractGrant.prepareRequestParameters
train
public function prepareRequestParameters(array $defaults, array $options) { $defaults['grant_type'] = $this->getName(); $required = $this->getRequiredRequestParameters(); $provided = array_merge($defaults,
php
{ "resource": "" }
q17321
AbstractProvider.getAuthorizationUrl
train
public function getAuthorizationUrl(array $options = []) { $base = $this->getBaseAuthorizationUrl(); $params = $this->getAuthorizationParameters($options); $query
php
{ "resource": "" }
q17322
AbstractProvider.authorize
train
public function authorize( array $options = [], callable $redirectHandler = null ) { $url = $this->getAuthorizationUrl($options); if ($redirectHandler) { return $redirectHandler($url, $this); }
php
{ "resource": "" }
q17323
AbstractProvider.appendQuery
train
protected function appendQuery($url, $query) { $query = trim($query, '?&'); if ($query) { $glue = strstr($url, '?') ===
php
{ "resource": "" }
q17324
AbstractProvider.verifyGrant
train
protected function verifyGrant($grant) { if (is_string($grant)) { return $this->grantFactory->getGrant($grant); }
php
{ "resource": "" }
q17325
AbstractProvider.getAccessTokenUrl
train
protected function getAccessTokenUrl(array $params) { $url = $this->getBaseAccessTokenUrl($params); if ($this->getAccessTokenMethod() ===
php
{ "resource": "" }
q17326
AbstractProvider.getRequest
train
public function getRequest($method, $url, array $options =
php
{ "resource": "" }
q17327
AbstractProvider.getHeaders
train
public function getHeaders($token = null) { if ($token) { return array_merge( $this->getDefaultHeaders(),
php
{ "resource": "" }
q17328
RequiredParameterTrait.checkRequiredParameters
train
private function checkRequiredParameters(array $names, array $params) { foreach ($names as $name) {
php
{ "resource": "" }
q17329
GuardedPropertyTrait.fillProperties
train
protected function fillProperties(array $options = []) { if (isset($options['guarded'])) { unset($options['guarded']); } foreach ($options as $option => $value) {
php
{ "resource": "" }
q17330
TodoGenerator.load
train
private function load() { // Get English version $english = $this->getTranslations(__DIR__, 'en');
php
{ "resource": "" }
q17331
TodoGenerator.getTranslations
train
private function getTranslations($directory, $language) { $contentJson = ''; $directoryJson = ($language == 'en') ? '/en/' : '/../json/'; $fileJson = $directory.$directoryJson.$language.'.json'; if (file_exists($fileJson)) { $contentJson = json_decode(file_get_contents...
php
{ "resource": "" }
q17332
TodoGenerator.getLanguages
train
private function getLanguages() { $directories = glob($this->basePath.'/*', GLOB_ONLYDIR); $languages = array_map(function ($dir) {
php
{ "resource": "" }
q17333
TodoGenerator.compareTranslations
train
private function compareTranslations(array $default, array $languages) { // Return diff language by language foreach ($languages as $language) { $this->addOutput($language); $current = $this->getTranslations($this->basePath, $language); foreach ($default as $key ...
php
{ "resource": "" }
q17334
TodoGenerator.addOutput
train
private function addOutput(string $key, string $value = null) { if (!array_key_exists($key, $this->output)) {
php
{ "resource": "" }
q17335
TodoGenerator.getOutput
train
private function getOutput() { $output = "# Todo list\n\n"; // Make menu $columns = 12; $captions = implode('|', array_fill(0, $columns, ' ')); $subcaptions = implode('|', array_fill(0, $columns, ':---:')); $output .= "|$captions|\n"; $output .= "|$subcapti...
php
{ "resource": "" }
q17336
Environment.executeMigration
train
public function executeMigration(MigrationInterface $migration, $direction = MigrationInterface::UP, $fake = false) { $direction = ($direction === MigrationInterface::UP) ? MigrationInterface::UP : MigrationInterface::DOWN; $migration->setMigratingUp($direction === MigrationInterface::UP); ...
php
{ "resource": "" }
q17337
Environment.executeSeed
train
public function executeSeed(SeedInterface $seed) { $seed->setAdapter($this->getAdapter()); // begin the transaction if the adapter supports it if ($this->getAdapter()->hasTransactions()) { $this->getAdapter()->beginTransaction();
php
{ "resource": "" }
q17338
Environment.parseAgnosticDsn
train
protected function parseAgnosticDsn(array $options) { if (isset($options['dsn']) && is_string($options['dsn'])) { $regex = '#^(?P<adapter>[^\\:]+)\\://(?:(?P<user>[^\\:@]+)(?:\\:(?P<pass>[^@]*))?@)?' . '(?P<host>[^\\:@/]+)(?:\\:(?P<port>[1-9]\\d*))?/(?P<name>[^\?]+)(?:\?(?P<qu...
php
{ "resource": "" }
q17339
Environment.getCurrentVersion
train
public function getCurrentVersion() { // We don't cache this code as the current version is pretty volatile. // TODO - that means they're no point in a setter then? // maybe we should cache and call a reset() method every time a migration is run $versions = $this->getVersions(); ...
php
{ "resource": "" }
q17340
AddIndex.build
train
public static function build(Table $table, $columns, array $options = []) { // create a new index object if strings or an array of strings were supplied $index = $columns; if (!$columns instanceof Index) { $index = new Index(); if (is_string($columns)) {
php
{ "resource": "" }
q17341
PostgresAdapter.getDefaultValueDefinition
train
protected function getDefaultValueDefinition($default, $columnType = null) { if (is_string($default) && 'CURRENT_TIMESTAMP' !== $default) { $default = $this->getConnection()->quote($default); } elseif (is_bool($default)) { $default = $this->castToBool($default); }
php
{ "resource": "" }
q17342
PostgresAdapter.getColumnCommentSqlDefinition
train
protected function getColumnCommentSqlDefinition(Column $column, $tableName) { // passing 'null' is to remove column comment $comment = (strcasecmp($column->getComment(), 'NULL') !== 0)
php
{ "resource": "" }
q17343
PostgresAdapter.dropSchema
train
public function dropSchema($schemaName) { $sql = sprintf("DROP SCHEMA IF EXISTS %s
php
{ "resource": "" }
q17344
PostgresAdapter.getAllSchemas
train
public function getAllSchemas() { $sql = "SELECT schema_name FROM information_schema.schemata WHERE schema_name <> 'information_schema' AND schema_name
php
{ "resource": "" }
q17345
MysqlAdapter.getColumnSqlDefinition
train
protected function getColumnSqlDefinition(Column $column) { if ($column->getType() instanceof Literal) { $def = (string)$column->getType(); } else { $sqlType = $this->getSqlType($column->getType(), $column->getLimit()); $def = strtoupper($sqlType['name']); ...
php
{ "resource": "" }
q17346
MysqlAdapter.describeTable
train
public function describeTable($tableName) { $options = $this->getOptions(); // mysql specific $sql = sprintf( "SELECT * FROM information_schema.tables WHERE table_schema = '%s'
php
{ "resource": "" }
q17347
Manager.printMissingVersion
train
private function printMissingVersion($version, $maxNameLength) { $this->getOutput()->writeln(sprintf( ' <error>up</error> %14.0f %19s %19s <comment>%s</comment> <error>** MISSING **</error>', $version['version'], $version['start_time'],
php
{ "resource": "" }
q17348
Manager.migrateToDateTime
train
public function migrateToDateTime($environment, \DateTime $dateTime, $fake = false) { $versions = array_keys($this->getMigrations($environment)); $dateString = $dateTime->format('YmdHis'); $outstandingMigrations = array_filter($versions, function ($version) use ($dateString) { r...
php
{ "resource": "" }
q17349
Manager.executeMigration
train
public function executeMigration($name, MigrationInterface $migration, $direction = MigrationInterface::UP, $fake = false) { $this->getOutput()->writeln(''); $this->getOutput()->writeln( ' ==' . ' <info>' . $migration->getVersion() . ' ' . $migration->getName() . ':</info>' ....
php
{ "resource": "" }
q17350
Manager.executeSeed
train
public function executeSeed($name, SeedInterface $seed) { $this->getOutput()->writeln(''); $this->getOutput()->writeln( ' ==' . ' <info>' . $seed->getName() . ':</info>' . ' <comment>seeding</comment>' ); // Execute the seeder and log the time ela...
php
{ "resource": "" }
q17351
Manager.seed
train
public function seed($environment, $seed = null) { $seeds = $this->getSeeds(); if ($seed === null) { // run all seeders foreach ($seeds as $seeder) { if (array_key_exists($seeder->getName(), $seeds)) { $this->executeSeed($environment, $see...
php
{ "resource": "" }
q17352
Manager.getSeedFiles
train
protected function getSeedFiles() { $config = $this->getConfig(); $paths = $config->getSeedPaths(); $files = []; foreach ($paths as $path) { $files = array_merge( $files, Util::glob($path
php
{ "resource": "" }
q17353
Manager.toggleBreakpoint
train
public function toggleBreakpoint($environment, $version) { $migrations = $this->getMigrations($environment); $this->getMigrations($environment); $env = $this->getEnvironment($environment); $versions = $env->getVersionLog(); if (empty($versions) || empty($migrations)) { ...
php
{ "resource": "" }
q17354
Manager.removeBreakpoints
train
public function removeBreakpoints($environment) { $this->getOutput()->writeln(sprintf( ' %d breakpoints cleared.',
php
{ "resource": "" }
q17355
ForeignKey.normalizeAction
train
protected function normalizeAction($action) { $constantName = 'static::' . str_replace(' ', '_', strtoupper(trim($action))); if (!defined($constantName)) {
php
{ "resource": "" }
q17356
SqlServerAdapter.getColumnCommentSqlDefinition
train
protected function getColumnCommentSqlDefinition(Column $column, $tableName) { // passing 'null' is to remove column comment $currentComment = $this->getColumnComment($tableName, $column->getName()); $comment = (strcasecmp($column->getComment(), 'NULL') !== 0) ? $this->getConnection()->quot...
php
{ "resource": "" }
q17357
SqlServerAdapter.getChangeDefault
train
protected function getChangeDefault($tableName, Column $newColumn) { $constraintName = "DF_{$tableName}_{$newColumn->getName()}"; $default = $newColumn->getDefault(); $instructions = new AlterInstructions(); if ($default === null) { $default = 'DEFAULT NULL'; } e...
php
{ "resource": "" }
q17358
SqlServerAdapter.getColumnSqlDefinition
train
protected function getColumnSqlDefinition(Column $column, $create = true) { $buffer = []; if ($column->getType() instanceof Literal) { $buffer[] = (string)$column->getType(); } else { $sqlType = $this->getSqlType($column->getType()); $buffer[] = strtoupper...
php
{ "resource": "" }
q17359
SqlServerAdapter.getIndexSqlDefinition
train
protected function getIndexSqlDefinition(Index $index, $tableName) { if (is_string($index->getName())) { $indexName = $index->getName(); } else { $columnNames = $index->getColumns(); $indexName = sprintf('%s_%s', $tableName, implode('_', $columnNames)); } ...
php
{ "resource": "" }
q17360
SqlServerAdapter.getForeignKeySqlDefinition
train
protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) { $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); $def = ' CONSTRAINT ' . $this->quoteColumnName($constraintName); $def .= ' FOREIGN KEY ("' . implo...
php
{ "resource": "" }
q17361
AbstractAdapter.isDryRunEnabled
train
public function isDryRunEnabled() { $input = $this->getInput();
php
{ "resource": "" }
q17362
AlterInstructions.merge
train
public function merge(AlterInstructions $other) { $this->alterParts = array_merge($this->alterParts, $other->getAlterParts());
php
{ "resource": "" }
q17363
AlterInstructions.execute
train
public function execute($alterTemplate, callable $executor) { if ($this->alterParts) { $alter = sprintf($alterTemplate, implode(', ', $this->alterParts)); $executor($alter); } $state = []; foreach ($this->postSteps as $instruction) {
php
{ "resource": "" }
q17364
AddForeignKey.build
train
public static function build(Table $table, $columns, $referencedTable, $referencedColumns = ['id'], array $options = [], $name = null) { if (is_string($referencedColumns)) { $referencedColumns = [$referencedColumns]; // str to array } if (is_string($referencedTable)) { ...
php
{ "resource": "" }
q17365
Util.getExistingMigrationClassNames
train
public static function getExistingMigrationClassNames($path) { $classNames = []; if (!is_dir($path)) { return $classNames; } // filter the files to only get the ones that match our naming scheme $phpFiles = glob($path . DIRECTORY_SEPARATOR . '*.php'); f...
php
{ "resource": "" }
q17366
Util.mapClassNameToFileName
train
public static function mapClassNameToFileName($className) { $arr = preg_split('/(?=[A-Z])/', $className); unset($arr[0]); // remove the first element ('')
php
{ "resource": "" }
q17367
Util.mapFileNameToClassName
train
public static function mapFileNameToClassName($fileName) { $matches = []; if (preg_match(static::MIGRATION_FILE_NAME_PATTERN, $fileName, $matches)) { $fileName = $matches[1];
php
{ "resource": "" }
q17368
Util.loadPhpFile
train
public static function loadPhpFile($filename) { $filePath = realpath($filename); /** * I lifed this from phpunits FileLoader class * * @see https://github.com/sebastianbergmann/phpunit/pull/2751 */ $isReadable = @\fopen($filePath, 'r') !== false; ...
php
{ "resource": "" }
q17369
RenameColumn.build
train
public static function build(Table $table, $columnName, $newName) { $column = new Column();
php
{ "resource": "" }
q17370
Plan.createPlan
train
protected function createPlan($actions) { $this->gatherCreates($actions); $this->gatherUpdates($actions);
php
{ "resource": "" }
q17371
Plan.execute
train
public function execute(AdapterInterface $executor) { foreach ($this->tableCreates as $newTable) { $executor->createTable($newTable->getTable(), $newTable->getColumns(), $newTable->getIndexes()); } collection($this->updatesSequence()) ->unfold()
php
{ "resource": "" }
q17372
Plan.resolveConflicts
train
protected function resolveConflicts() { $moveActions = collection($this->tableMoves) ->unfold(function ($move) { return $move->getActions(); }); foreach ($moveActions as $action) { if ($action instanceof DropTable) { $this->tableUp...
php
{ "resource": "" }
q17373
Plan.forgetTable
train
protected function forgetTable(Table $table, $actions) { $result = []; foreach ($actions as $action) {
php
{ "resource": "" }
q17374
Plan.forgetDropIndex
train
protected function forgetDropIndex(Table $table, array $columns, array $actions) { $dropIndexActions = new ArrayObject(); $indexes = collection($actions) ->map(function ($alter) use ($table, $columns, $dropIndexActions) { if ($alter->getTable()->getName() !== $table->getN...
php
{ "resource": "" }
q17375
Plan.gatherCreates
train
protected function gatherCreates($actions) { collection($actions) ->filter(function ($action) { return $action instanceof CreateTable; }) ->map(function ($action) { return [$action->getTable()->getName(), new NewTable($action->getTable())];...
php
{ "resource": "" }
q17376
Plan.gatherUpdates
train
protected function gatherUpdates($actions) { collection($actions) ->filter(function ($action) { return $action instanceof AddColumn || $action instanceof ChangeColumn || $action instanceof RemoveColumn || $action instanc...
php
{ "resource": "" }
q17377
Plan.gatherTableMoves
train
protected function gatherTableMoves($actions) { collection($actions) ->filter(function ($action) { return $action instanceof DropTable || $action instanceof RenameTable || $action instanceof ChangePrimaryKey || $action i...
php
{ "resource": "" }
q17378
Plan.gatherIndexes
train
protected function gatherIndexes($actions) { collection($actions) ->filter(function ($action) { return $action instanceof AddIndex || $action instanceof DropIndex; }) ->reject(function ($action) { // Indexes for new tabl...
php
{ "resource": "" }
q17379
Plan.gatherConstraints
train
protected function gatherConstraints($actions) { collection($actions) ->filter(function ($action) { return $action instanceof AddForeignKey || $action instanceof DropForeignKey; }) ->each(function ($action) { $table = $a...
php
{ "resource": "" }
q17380
DropIndex.build
train
public static function build(Table $table, array $columns = []) {
php
{ "resource": "" }
q17381
DropIndex.buildFromName
train
public static function buildFromName(Table $table, $name) { $index = new Index();
php
{ "resource": "" }
q17382
AddColumn.build
train
public static function build(Table $table, $columnName, $type = null, $options = []) { $column = new Column(); $column->setName($columnName); $column->setType($type);
php
{ "resource": "" }
q17383
AdapterFactory.getClass
train
protected function getClass($name) { if (empty($this->adapters[$name])) { throw new \RuntimeException(sprintf( 'Adapter "%s"
php
{ "resource": "" }
q17384
AdapterFactory.getWrapperClass
train
protected function getWrapperClass($name) { if (empty($this->wrappers[$name])) { throw new \RuntimeException(sprintf( 'Wrapper "%s"
php
{ "resource": "" }
q17385
AbstractMigration.preFlightCheck
train
public function preFlightCheck($direction = null) { if (method_exists($this, MigrationInterface::CHANGE)) { if (method_exists($this, MigrationInterface::UP) || method_exists($this, MigrationInterface::DOWN) ) { $this->output->writeln(sprintf(
php
{ "resource": "" }
q17386
AbstractMigration.postFlightCheck
train
public function postFlightCheck($direction = null) { foreach ($this->tables as $table) { if ($table->hasPendingActions()) {
php
{ "resource": "" }
q17387
AbstractCommand.locateConfigFile
train
protected function locateConfigFile(InputInterface $input) { $configFile = $input->getOption('configuration'); $useDefault = false; if ($configFile === null || $configFile === false) { $useDefault = true; } $cwd = getcwd(); // locate the phinx config f...
php
{ "resource": "" }
q17388
AbstractCommand.verifyMigrationDirectory
train
protected function verifyMigrationDirectory($path) { if (!is_dir($path)) { throw new \InvalidArgumentException(sprintf( 'Migration directory "%s" does not exist',
php
{ "resource": "" }
q17389
AbstractCommand.verifySeedDirectory
train
protected function verifySeedDirectory($path) { if (!is_dir($path)) { throw new \InvalidArgumentException(sprintf( 'Seed directory "%s" does not exist',
php
{ "resource": "" }
q17390
SeedRun.execute
train
protected function execute(InputInterface $input, OutputInterface $output) { $this->bootstrap($input, $output); $seedSet = $input->getOption('seed'); $environment = $input->getOption('environment'); if ($environment === null) { $environment = $this->getConfig()->getDefa...
php
{ "resource": "" }
q17391
SQLiteAdapter.getDeclaringSql
train
protected function getDeclaringSql($tableName) { $rows = $this->fetchAll('select * from sqlite_master where `type` = \'table\''); $sql = ''; foreach ($rows as $table) {
php
{ "resource": "" }
q17392
SQLiteAdapter.copyDataToNewTable
train
protected function copyDataToNewTable($tableName, $tmpTableName, $writeColumns, $selectColumns) { $sql = sprintf( 'INSERT INTO %s(%s) SELECT %s FROM %s', $this->quoteTableName($tableName), implode(', ', $writeColumns),
php
{ "resource": "" }
q17393
SQLiteAdapter.copyAndDropTmpTable
train
protected function copyAndDropTmpTable($instructions, $tableName) { $instructions->addPostStep(function ($state) use ($tableName) { $this->copyDataToNewTable( $tableName, $state['tmpTableName'], $state['writeColumns'], $state['selec...
php
{ "resource": "" }
q17394
SQLiteAdapter.calculateNewTableColumns
train
protected function calculateNewTableColumns($tableName, $columnName, $newColumnName) { $columns = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName))); $selectColumns = []; $writeColumns = []; $columnType = null; $found = false; foreac...
php
{ "resource": "" }
q17395
SQLiteAdapter.beginAlterByCopyTable
train
protected function beginAlterByCopyTable($tableName) { $instructions = new AlterInstructions(); $instructions->addPostStep(function ($state) use ($tableName) { $createSQL = $this->getDeclaringSql($tableName); $tmpTableName = 'tmp_' . $tableName; $this->execute( ...
php
{ "resource": "" }
q17396
SQLiteAdapter.getIndexSqlDefinition
train
protected function getIndexSqlDefinition(Table $table, Index $index) { if ($index->getType() === Index::UNIQUE) { $def = 'UNIQUE INDEX'; } else { $def = 'INDEX'; } if (is_string($index->getName())) { $indexName = $index->getName(); } else {...
php
{ "resource": "" }
q17397
SQLiteAdapter.getForeignKeySqlDefinition
train
protected function getForeignKeySqlDefinition(ForeignKey $foreignKey) { $def = ''; if ($foreignKey->getConstraint()) { $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint()); } else { $columnNames = []; foreach ($foreignKey->getColum...
php
{ "resource": "" }
q17398
Init.execute
train
protected function execute(InputInterface $input, OutputInterface $output) { $path = $this->resolvePath($input); $format = strtolower($input->getOption('format'));
php
{ "resource": "" }
q17399
Rollback.getTargetFromDate
train
public function getTargetFromDate($date) { if (!preg_match('/^\d{4,14}$/', $date)) { throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].'); } // what we need to append to the date according to the possible date string lengths $dateStrle...
php
{ "resource": "" }