_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q256100
Quickbooks_Payments._http
test
protected function _http($Context, $url_path, $raw_body = null, $operation = null) { if($operation !== null) { $method = $operation; } else { $method = 'GET'; if ($raw_body) { $method = 'POST'; } } $url = $this->_getBaseURL() . $url_path; $authcreds = $Context->authcreds(); $params = array(); $OAuth = new QuickBooks_IPP_OAuth($this->_oauth_consumer_key, $this->_oauth_consumer_secret); $signed = $OAuth->sign($method, $url, $authcreds['oauth_access_token'], $authcreds['oauth_access_token_secret'], $params); //print_r($signed); //$HTTP = new QuickBooks_HTTP($signed[2]); $HTTP = new QuickBooks_HTTP($url); $headers = array( 'Content-Type' => 'application/json', 'Request-Id' => QuickBooks_Utilities::GUID(), 'Authorization' => $signed[3], ); $HTTP->setHeaders($headers); // Turn on debugging for the HTTP object if it's been enabled in the payment processor $HTTP->useDebugMode($this->_debug); // $HTTP->setRawBody($raw_body); $HTTP->verifyHost(false); $HTTP->verifyPeer(false); if ($method == 'POST') { $return = $HTTP->POST(); } else if ($method == 'GET') { $return = $HTTP->GET(); } else if ($method == 'DELETE') { $return = $HTTP->DELETE(); } else { $return = null; // ERROR } $this->_last_request = $HTTP->lastRequest(); $this->_last_response = $HTTP->lastResponse(); // $this->log($HTTP->getLog(), QUICKBOOKS_LOG_DEBUG); $info = $HTTP->lastInfo(); $this->_last_httpinfo = $info; $errnum = $HTTP->errorNumber(); $errmsg = $HTTP->errorMessage(); if ($errnum) { // An error occurred! $this->_setError(QuickBooks_Payments::ERROR_HTTP, $errnum . ': ' . $errmsg); return false; } if ($info['http_code'] == 401) { $this->_setError(QuickBooks_Payments::ERROR_AUTH, 'Payments return a 401 Unauthorized status.'); return false; } // Everything is good, return the data! $this->_setError(QuickBooks_Payments::ERROR_OK, ''); return $return; }
php
{ "resource": "" }
q256101
QuickBooks_Callbacks_API_Callbacks._mapToQuickBooksID
test
protected static function _mapToQuickBooksID($func, $user, $type, $ID) { if (strlen($func)) { if (false === strpos($func, '::')) { return $func($type, $ID); } else { $tmp = explode('::', $func); return call_user_func(array( $tmp[0], $tmp[1] ), $type, $ID); } } else { $editsequence = ''; $extra = null; //print('mapping: ' . $user . ', ' . $type . ', ' . $ID . "\n"); $Driver = QuickBooks_Driver_Singleton::getInstance(); $ListID_or_TxnID = $Driver->identToQuickBooks($user, $type, $ID, $editsequence, $extra); //print('got back: ' . $ListID_or_TxnID . "\n"); return $ListID_or_TxnID; } }
php
{ "resource": "" }
q256102
QuickBooks_Callbacks_API_Callbacks._mapToApplicationID
test
static protected function _mapToApplicationID($func, $user, $type, $ListID_or_TxnID) { if (strlen($func)) { if (false === strpos($func, '::')) { return $func($type, $ListID_or_TxnID); } else { $tmp = explode('::', $func); return call_user_func(array( $tmp[0], $tmp[1] ), $type, $ListID_or_TxnID); } } else { $extra = null; $Driver = QuickBooks_Driver_Singleton::getInstance(); return $Driver->identToApplication($user, $type, $ListID_or_TxnID, $extra); } }
php
{ "resource": "" }
q256103
QuickBooks_Callbacks_API_Callbacks.ShipMethodAddRequest
test
public static function ShipMethodAddRequest($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale, $config = array(), $qbxml = null) { return QuickBooks_Callbacks_API_Callbacks::_doAddRequest($requestID, $user, $action, $ID, $extra, $err, $last_action_time, $last_actionident_time, $version, $locale, $config, $qbxml); }
php
{ "resource": "" }
q256104
QuickBooks_Callbacks_SQL_Callbacks._filterActions
test
static protected function _filterActions($action_to_priority, $only_do, $dont_do, $type) { $start = microtime(true); foreach ($action_to_priority as $action => $priority) { //print('stepping 1... [' . (microtime(true) - $start) . ']' . "\n"); $converted = QuickBooks_Utilities::actionToObject($action); //print('stepping 2... [' . (microtime(true) - $start) . ']' . "\n"); if (count($only_do) and (false === array_search($action, $only_do) and false === array_search($converted, $only_do))) { unset($action_to_priority[$action]); } if (count($dont_do) and (false !== array_search($action, $dont_do) or false !== array_search($converted, $dont_do))) { unset($action_to_priority[$action]); } } //print("\n" . 'ending... [' . (microtime(true) - $start) . ']' . "\n\n"); arsort($action_to_priority); //print_r($action_to_priority); return $action_to_priority; }
php
{ "resource": "" }
q256105
QuickBooks_Callbacks_SQL_Callbacks._requiredVersion
test
protected static function _requiredVersion($required, $current, $locale = QUICKBOOKS_LOCALE_US, $action = null) { if ($locale == QUICKBOOKS_LOCALE_US) { return $current >= $required; } return true; }
php
{ "resource": "" }
q256106
QuickBooks_Callbacks_SQL_Callbacks.ListDeletedQueryRequest
test
public static function ListDeletedQueryRequest($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale, $config = array()) { $xml = ''; if (!QuickBooks_Callbacks_SQL_Callbacks::_requiredVersion(2.0, $version, $locale, QUICKBOOKS_DEL_LIST)) { return QUICKBOOKS_SKIP; } $xml .= '<?xml version="1.0" encoding="utf-8"?> <?qbxml version="' . QuickBooks_Callbacks_SQL_Callbacks::_version($version, $locale) . '"?> <QBXML> <QBXMLMsgsRq onError="' . QUICKBOOKS_SERVER_SQL_ON_ERROR . '"> <ListDeletedQueryRq requestID="' . $requestID . '"> <ListDelType>Account</ListDelType> <ListDelType>BillingRate</ListDelType> <ListDelType>Class</ListDelType> <ListDelType>Customer</ListDelType> <ListDelType>CustomerMsg</ListDelType> <ListDelType>CustomerType</ListDelType> <ListDelType>DateDrivenTerms</ListDelType> <ListDelType>Employee</ListDelType> <ListDelType>ItemDiscount</ListDelType> <ListDelType>ItemFixedAsset</ListDelType> <ListDelType>ItemGroup</ListDelType> <ListDelType>ItemInventory</ListDelType> <ListDelType>ItemInventoryAssembly</ListDelType> <ListDelType>ItemNonInventory</ListDelType> <ListDelType>ItemOtherCharge</ListDelType> <ListDelType>ItemPayment</ListDelType> <ListDelType>ItemSalesTax</ListDelType> <ListDelType>ItemSalesTaxGroup</ListDelType> <ListDelType>ItemService</ListDelType> <ListDelType>ItemSubtotal</ListDelType> <ListDelType>JobType</ListDelType> <ListDelType>OtherName</ListDelType> <ListDelType>PaymentMethod</ListDelType> <ListDelType>PayrollItemNonWage</ListDelType> <ListDelType>PayrollItemWage</ListDelType> <ListDelType>PriceLevel</ListDelType> <ListDelType>SalesRep</ListDelType> <ListDelType>SalesTaxCode</ListDelType> <ListDelType>ShipMethod</ListDelType> <ListDelType>StandardTerms</ListDelType> <ListDelType>ToDo</ListDelType> <ListDelType>UnitOfMeasureSet</ListDelType> <ListDelType>Vehicle</ListDelType> <ListDelType>Vendor</ListDelType> <ListDelType>VendorType</ListDelType> ' . QuickBooks_Callbacks_SQL_Callbacks::_buildFilter($user, $action, $extra, true) . ' </ListDeletedQueryRq> </QBXMLMsgsRq> </QBXML>'; return $xml; }
php
{ "resource": "" }
q256107
QuickBooks_Callbacks_SQL_Callbacks.ListDeletedQueryResponse
test
public static function ListDeletedQueryResponse($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents, $config = array() ) { $Driver = QuickBooks_Driver_Singleton::getInstance(); $Parser = new QuickBooks_XML_Parser($xml); $errnum = 0; $errmsg = ''; $Doc = $Parser->parse($errnum, $errmsg); $Root = $Doc->getRoot(); $List = $Root->getChildAt('QBXML QBXMLMsgsRs ListDeletedQueryRs'); foreach ($List->children() as $Node) { $map = array(); $others = array(); QuickBooks_SQL_Schema::mapToSchema(trim(QuickBooks_Utilities::objectToXMLElement($Node->getChildDataAt('ListDeletedRet ListDelType'))), QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $map, $others); if (isset($map[0])) { $table = $map[0]; $data = array( 'qbsql_flag_deleted' => 1, ); $multipart = array( 'ListID' => $Node->getChildDataAt('ListDeletedRet ListID') ); $Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $data, array( $multipart )); } } return true; }
php
{ "resource": "" }
q256108
QuickBooks_Callbacks_SQL_Callbacks.TxnVoidRequest
test
public static function TxnVoidRequest($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale, $config = array()) { $Driver = QuickBooks_Driver_Singleton::getInstance(); if ($arr = $Driver->get(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . strtolower($extra['object']), array( QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ID ))) { $xml = ''; $xml .= '<?xml version="1.0" encoding="utf-8"?> <?qbxml version="' . QuickBooks_Callbacks_SQL_Callbacks::_version($version, $locale) . '"?> <QBXML> <QBXMLMsgsRq onError="stopOnError"> <TxnVoidRq requestID="' . $requestID . '"> <TxnVoidType>' . $extra['object'] . '</TxnVoidType> <TxnID>' . $arr['TxnID'] . '</TxnID> </TxnVoidRq> </QBXMLMsgsRq> </QBXML>'; return $xml; } return ''; }
php
{ "resource": "" }
q256109
QuickBooks_Callbacks_SQL_Callbacks.TxnVoidResponse
test
public static function TxnVoidResponse($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents, $config = array()) { $Driver = QuickBooks_Driver_Singleton::getInstance(); // Figure out what SQL table this object came from $map = array(); $others = array(); QuickBooks_SQL_Schema::mapToSchema(trim(QuickBooks_Utilities::objectToXMLElement($extra['object'])), QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $map, $others); $table = QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $map[0]; // We just need to set the voided flag on the transaction $update = array( QUICKBOOKS_DRIVER_SQL_FIELD_FLAG_VOIDED => 1, 'AmountDue' => 0.0, 'Amount' => 0.0, 'OpenAmount' => 0.0, 'Amount' => 0.0, 'Subtotal' => 0.0, 'TotalAmount' => 0.0, 'BalanceRemaining' => 0.0, 'SalesTaxTotal' => 0.0, ); $where = array( array( QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ID ), ); // Update the SQL table to indicate it was voided $Driver->update($table, $update, $where); return true; }
php
{ "resource": "" }
q256110
QuickBooks_Callbacks_SQL_Callbacks.SalesReceiptModRequest
test
public static function SalesReceiptModRequest($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale, $config = array()) { $Driver = QuickBooks_Driver_Singleton::getInstance(); if ($SalesReceipt = $Driver->get(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . 'salesreceipt', array( QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ID ))) { return QuickBooks_Callbacks_SQL_Callbacks::_AddRequest(QUICKBOOKS_OBJECT_SALESRECEIPT, $SalesReceipt, $requestID, $user, $action, $ID, $extra, $err, $last_action_time, $last_actionident_time, $version, $locale, $config); } return ''; }
php
{ "resource": "" }
q256111
QuickBooks_Callbacks_SQL_Callbacks.JobTypeAddRequest
test
public static function JobTypeAddRequest($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale, $config = array()) { $Driver = QuickBooks_Driver_Singleton::getInstance(); if ($JobType = $Driver->get(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . 'jobtype', array( QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ID ))) { return QuickBooks_Callbacks_SQL_Callbacks::_AddRequest(QUICKBOOKS_OBJECT_JOBTYPE, $JobType, $requestID, $user, $action, $ID, $extra, $err, $last_action_time, $last_actionident_time, $version, $locale, $config); } return ''; }
php
{ "resource": "" }
q256112
QuickBooks_Callbacks_SQL_Callbacks._buildFilter
test
protected static function _buildFilter($user, $action, $extra, $filter_wrap = false) { $Driver = QuickBooks_Driver_Singleton::getInstance(); $xml = ''; $type = ''; $key_prev = QuickBooks_Callbacks_SQL_Callbacks::_keySyncPrev($action); $key_curr = QuickBooks_Callbacks_SQL_Callbacks::_keySyncCurr($action); $module = __CLASS__; //$action = null; $type = null; $opts = null; // configRead($user, $module, $key, &$type, &$opts) $prev_sync_datetime = $Driver->configRead($user, $module, $key_prev, $type, $opts); // last sync started... if (!$prev_sync_datetime) { // If this query has *never* run before, let's get *all* of the records $timestamp = time() - (60 * 60 * 24 * 365 * 25); $prev_sync_datetime = date('Y-m-d', $timestamp) . 'T' . date('H:i:s', $timestamp); $extra = array(); // If an iterator exists, get rid of it (this should *never* happen... how could it?) // configWrite($user, $module, $key, $value, $type, $opts $Driver->configWrite($user, $module, $key_prev, $prev_sync_datetime, null); } // @TODO MAKE SURE THIS DOESN'T BREAK ANYTHING! $prev_sync_datetime = date('Y-m-d', strtotime($prev_sync_datetime) - 600) . 'T' . date('H:i:s', strtotime($prev_sync_datetime) - 600); if (!is_array($extra) or empty($extra['iteratorID'])) // Checks to see if this is the first iteration or not { // Start of a new iterator! // Store when we started to do this iterator (this will become the $prev_sync_datetime after we finish with this iterator) $curr_sync_datetime = date('Y-m-d') . 'T' . date('H:i:s'); $Driver->configWrite($user, $module, $key_curr, $curr_sync_datetime, null); if ($filter_wrap) { if ($action == QUICKBOOKS_QUERY_DELETEDLISTS or $action == QUICKBOOKS_QUERY_DELETEDTXNS) { $xml .= '<DeletedDateRangeFilter>' . "\n"; $xml .= ' <FromDeletedDate>' . $prev_sync_datetime . '</FromDeletedDate>' . "\n"; $xml .= '</DeletedDateRangeFilter>' . "\n"; } else { $xml .= '<ModifiedDateRangeFilter>' . "\n"; $xml .= ' <FromModifiedDate>' . $prev_sync_datetime . '</FromModifiedDate>' . "\n"; $xml .= '</ModifiedDateRangeFilter>' . "\n"; } } else { $xml .= '<FromModifiedDate>' . $prev_sync_datetime . '</FromModifiedDate>'; } } else // ... otherwise use what we found in previous time stamp { if ($filter_wrap) { if ($action == QUICKBOOKS_QUERY_DELETEDLISTS or $action == QUICKBOOKS_QUERY_DELETEDTXNS) { $xml .= '<DeletedDateRangeFilter>' . "\n"; $xml .= ' <FromDeletedDate>' . $prev_sync_datetime . '</FromDeletedDate>' . "\n"; $xml .= '</DeletedDateRangeFilter>' . "\n"; } else { $xml .= '<ModifiedDateRangeFilter>' . "\n"; $xml .= ' <FromModifiedDate>' . $prev_sync_datetime . '</FromModifiedDate>' . "\n"; $xml .= '</ModifiedDateRangeFilter>' . "\n"; } } else { $xml .= '<FromModifiedDate>' . $prev_sync_datetime . '</FromModifiedDate>'; } } return $xml; }
php
{ "resource": "" }
q256113
CacheService.flushGroups
test
public function flushGroups(array $groups) { $this->ensureCacheGroupsExist($groups); foreach ($groups as $group) { $this->cacheManager->flushCachesInGroup($group); } }
php
{ "resource": "" }
q256114
CacheService.flushByTagsAndGroups
test
public function flushByTagsAndGroups(array $tags, array $groups = null) { if ($groups === null) { $this->flushByTags($tags); } else { $this->ensureCacheGroupsExist($groups); foreach ($groups as $group) { $this->flushByTags($tags, $group); } } }
php
{ "resource": "" }
q256115
CommandCollection.find
test
public function find(string $possibleName): string { $allCommands = $this->getNames(); $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1], '/') . '[^:]*'; }, $possibleName); $commands = preg_grep('{^' . $expr . '}', $allCommands); if (empty($commands)) { $commands = preg_grep('{^' . $expr . '}i', $allCommands); } // filter out aliases for commands which are already on the list if (count($commands) > 1) { $commandList = $this->commands; $commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands) { $commandName = $commandList[$nameOrAlias]['name']; return $commandName === $nameOrAlias || !in_array($commandName, $commands, true); })); } return !empty($commands) && count($commands) === 1 ? $this->commands[reset($commands)]['name'] : $possibleName; }
php
{ "resource": "" }
q256116
PopulateCommandConfiguration.run
test
public function run(ScriptEvent $event): bool { $composer = $event->getComposer(); $composerConfig = $composer->getConfig(); $basePath = realpath(substr($composerConfig->get('vendor-dir'), 0, -strlen($composerConfig->get('vendor-dir', $composerConfig::RELATIVE_PATHS)))); $commandConfiguration = []; foreach ($this->extractPackageMapFromComposer($composer) as $item) { /** @var \Composer\Package\PackageInterface $package */ list($package, $installPath) = $item; $installPath = ($installPath ?: $basePath); $packageName = $package->getName(); $packageType = $package->getType(); if (in_array($packageType, ['metapackage', 'typo3-cms-extension', 'typo3-cms-framework'], true)) { // Commands in TYPO3 extensions are scanned for anyway at a later point. // With that we ensure not showing commands for extensions that aren't active. // Since meta packages have no code, thus cannot include any commands, we ignore them as well. continue; } $packageConfig = $this->getConfigFromPackage($installPath, $packageName); if ($packageConfig !== []) { $commandConfiguration[] = $packageConfig; } } $success = file_put_contents( __DIR__ . '/../../../../Configuration/ComposerPackagesCommands.php', '<?php' . chr(10) . 'return ' . var_export($commandConfiguration, true) . ';' ); return $success !== false; }
php
{ "resource": "" }
q256117
ExtensionCompatibilityCheck.canLoadExtLocalconfFile
test
private function canLoadExtLocalconfFile($extensionKey) { $activePackages = $this->packageManager->getActivePackages(); foreach ($activePackages as $package) { $this->loadExtLocalconfForExtension($package->getPackageKey()); if ($package->getPackageKey() === $extensionKey) { break; } } return true; }
php
{ "resource": "" }
q256118
ExtensionCompatibilityCheck.canLoadExtTablesFile
test
private function canLoadExtTablesFile($extensionKey) { $activePackages = $this->packageManager->getActivePackages(); foreach ($activePackages as $package) { // Load all ext_localconf files first $this->loadExtLocalconfForExtension($package->getPackageKey()); } foreach ($activePackages as $package) { $this->loadExtTablesForExtension($package->getPackageKey()); if ($package->getPackageKey() === $extensionKey) { break; } } return true; }
php
{ "resource": "" }
q256119
ExtensionCompatibilityCheck.loadExtLocalconfForExtension
test
private function loadExtLocalconfForExtension($extensionKey) { $extensionInfo = $GLOBALS['TYPO3_LOADED_EXT'][$extensionKey]; // This is the main array meant to be manipulated in the ext_localconf.php files // In general it is recommended to not rely on it to be globally defined in that // scope but to use $GLOBALS['TYPO3_CONF_VARS'] instead. // Nevertheless we define it here as global for backwards compatibility. global $TYPO3_CONF_VARS; $_EXTKEY = $extensionKey; if (isset($extensionInfo['ext_localconf.php']) && $extensionInfo['ext_localconf.php']) { // $_EXTKEY and $_EXTCONF are available in ext_localconf.php // and are explicitly set in cached file as well $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]; require $extensionInfo['ext_localconf.php']; } }
php
{ "resource": "" }
q256120
ExtensionCompatibilityCheck.loadExtTablesForExtension
test
private function loadExtTablesForExtension($extensionKey) { $extensionInfo = $GLOBALS['TYPO3_LOADED_EXT'][$extensionKey]; // In general it is recommended to not rely on it to be globally defined in that // scope, but we can not prohibit this without breaking backwards compatibility global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS; global $TBE_MODULES, $TBE_MODULES_EXT, $TCA; global $PAGES_TYPES, $TBE_STYLES; global $_EXTKEY; // Load each ext_tables.php file of loaded extensions $_EXTKEY = $extensionKey; if (isset($extensionInfo['ext_tables.php']) && $extensionInfo['ext_tables.php']) { // $_EXTKEY and $_EXTCONF are available in ext_tables.php // and are explicitly set in cached file as well $_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]; require $extensionInfo['ext_tables.php']; } }
php
{ "resource": "" }
q256121
PrepareInstallAction.ensureInstallationIsPossible
test
private function ensureInstallationIsPossible(array $options) { $integrityCheck = $options['integrityCheck'] ?? false; if (!$integrityCheck) { return; } $isInteractive = $options['interactive'] ?? $this->output->getSymfonyConsoleInput()->isInteractive(); $forceInstall = $options['forceInstall'] ?? false; $localConfFile = PATH_typo3conf . 'LocalConfiguration.php'; $packageStatesFile = PATH_typo3conf . 'PackageStates.php'; if (!$forceInstall && file_exists($localConfFile)) { $this->output->outputLine(); $this->output->outputLine('<error>TYPO3 seems to be already set up!</error>'); $proceed = $isInteractive; if ($isInteractive) { $this->output->outputLine(); $this->output->outputLine('<info>If you continue, your <code>typo3conf/LocalConfiguration.php</code></info>'); $this->output->outputLine('<info>and <code>typo3conf/PackageStates.php</code> files will be deleted!</info>'); $this->output->outputLine(); $proceed = $this->output->askConfirmation('<info>Do you really want to proceed?</info> (<comment>no</comment>) ', false); } if (!$proceed) { $this->output->outputLine('<error>Installation aborted!</error>'); throw new InstallationFailedException('Installation aborted by user', 1529926774); } } @unlink($localConfFile); @unlink($packageStatesFile); clearstatcache(); if (file_exists($localConfFile)) { $this->output->outputLine(); $this->output->outputLine('<error>Unable to delete configuration file!</error>'); $this->output->outputLine('<error>Installation aborted!</error>'); throw new InstallationFailedException('Installation aborted because of insufficient premissions', 1529926810); } }
php
{ "resource": "" }
q256122
SchedulerCommandController.executeScheduledTasks
test
protected function executeScheduledTasks() { // Loop as long as there are tasks do { // Try getting the next task and execute it // If there are no more tasks to execute, an exception is thrown by \TYPO3\CMS\Scheduler\Scheduler::fetchTask() try { /** @var $task \TYPO3\CMS\Scheduler\Task\AbstractTask */ $task = $this->scheduler->fetchTask(); $hasTask = true; try { $this->scheduler->executeTask($task); } catch (\Exception $e) { // We ignore any exception that may have been thrown during execution, // as this is a background process. // The exception message has been recorded to the database anyway continue; } } catch (\OutOfBoundsException $e) { $hasTask = false; } catch (\UnexpectedValueException $e) { continue; } } while ($hasTask); // Record the run in the system registry $this->scheduler->recordLastRun(); }
php
{ "resource": "" }
q256123
SchedulerCommandController.executeSingleTask
test
protected function executeSingleTask($taskId, $forceExecution) { // Force the execution of the task even if it is disabled or no execution scheduled if ($forceExecution) { $task = $this->scheduler->fetchTask($taskId); } else { $whereClause = 'uid = ' . (int)$taskId . ' AND nextexecution != 0 AND nextexecution <= ' . (int)$GLOBALS['EXEC_TIME']; list($task) = $this->scheduler->fetchTasksWithCondition($whereClause); } if ($this->scheduler->isValidTaskObject($task)) { try { $this->scheduler->executeTask($task); } finally { // Record the run in the system registry $this->scheduler->recordLastRun('cli-by-id'); } } }
php
{ "resource": "" }
q256124
SchemaUpdate.migrate
test
public function migrate(array $statements, array $selectedStatements) { return $this->schemaMigrator->migrate($this->sqlReader->getCreateTableStatementArray($this->sqlReader->getTablesDefinitionString()), $selectedStatements); }
php
{ "resource": "" }
q256125
BackendCommandController.lockForEditorsCommand
test
public function lockForEditorsCommand() { $this->ensureConfigValueModifiable(); $lockedForEditors = $this->configurationService->getLocal('BE/adminOnly') !== self::LOCK_TYPE_UNLOCKED; if (!$lockedForEditors) { $this->configurationService->setLocal('BE/adminOnly', self::LOCK_TYPE_ADMIN); $this->outputLine('<info>Locked backend for editor access.</info>'); } else { $this->outputLine('<warning>The backend was already locked for editors, hence nothing was done.</warning>'); } }
php
{ "resource": "" }
q256126
BackendCommandController.unlockForEditorsCommand
test
public function unlockForEditorsCommand() { $this->ensureConfigValueModifiable(); $lockedForEditors = $this->configurationService->getLocal('BE/adminOnly') !== self::LOCK_TYPE_UNLOCKED; if ($lockedForEditors) { $this->configurationService->setLocal('BE/adminOnly', self::LOCK_TYPE_UNLOCKED); $this->outputLine('<info>Unlocked backend for editors.</info>'); } else { $this->outputLine('<warning>The backend was not locked for editors.</warning>'); } }
php
{ "resource": "" }
q256127
BackendCommandController.createAdminCommand
test
public function createAdminCommand(string $username, string $password) { $givenUsername = $username; $username = strtolower(preg_replace('/\\s/i', '', $username)); if ($givenUsername !== $username) { $this->outputLine('<warning>Given username "%s" contains invalid characters. Using "%s" instead.</warning>', [$givenUsername, $username]); } if (strlen($username) < 4) { $this->outputLine('<error>Username must be at least 4 characters.</error>'); $this->quit(1); } if (strlen($password) < 8) { $this->outputLine('<error>Password must be at least 8 characters.</error>'); $this->quit(1); } $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $userExists = $connectionPool->getConnectionForTable('be_users') ->count( 'uid', 'be_users', ['username' => $username] ); if ($userExists) { $this->outputLine('<error>A user with username "%s" already exists.</error>', [$username]); $this->quit(1); } $adminUserFields = [ 'username' => $username, 'password' => $this->salt->getHashedPassword($password), 'admin' => 1, 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], ]; $connectionPool->getConnectionForTable('be_users') ->insert('be_users', $adminUserFields); $this->outputLine('<info>Created admin user with username "%s".</info>', [$username]); }
php
{ "resource": "" }
q256128
UpgradeWizardList.listWizards
test
public function listWizards($includeDone = false) { if (empty($this->listCache)) { $availableUpgradeWizards = []; foreach ($this->wizardRegistry as $identifier => $className) { $updateObject = $this->factory->create($identifier); $shortIdentifier = $this->factory->getShortIdentifier($identifier); $availableUpgradeWizards[$shortIdentifier] = [ 'className' => $className, 'title' => $updateObject->getTitle(), 'done' => false, ]; $explanation = ''; $wizardImplementsInterface = $updateObject instanceof UpgradeWizardInterface && !$updateObject instanceof AbstractUpdate; $markedAsDone = $this->registry->get('installUpdate', $className, false) || $this->registry->get('installUpdate', $identifier, false); if ($wizardImplementsInterface) { $explanation = $updateObject->getDescription(); $wizardClaimsExecution = $updateObject->updateNecessary(); } else { $wizardClaimsExecution = $updateObject->checkForUpdate($explanation); } if ($markedAsDone || !$wizardClaimsExecution) { $availableUpgradeWizards[$shortIdentifier]['done'] = true; } $availableUpgradeWizards[$shortIdentifier]['explanation'] = html_entity_decode(strip_tags($explanation)); } $this->listCache = $availableUpgradeWizards; } return array_filter( $this->listCache, function ($info) use ($includeDone) { return $includeDone || !$info['done']; } ); }
php
{ "resource": "" }
q256129
InstallCommandController.generatePackageStatesCommand
test
public function generatePackageStatesCommand(array $frameworkExtensions = [], array $excludedExtensions = [], $activateDefault = false) { if ($activateDefault && CompatibilityScripts::isComposerMode()) { // @deprecated for composer usage in 5.0 will be removed with 6.0 $this->outputLine('<warning>Using --activate-default is deprecated in composer managed TYPO3 installations.</warning>'); $this->outputLine('<warning>Instead of requiring typo3/cms in your project, you should consider only requiring individual packages you need.</warning>'); } $frameworkExtensions = $frameworkExtensions ?: explode(',', (string)getenv('TYPO3_ACTIVE_FRAMEWORK_EXTENSIONS')); $packageStatesGenerator = new PackageStatesGenerator($this->packageManager); $activatedExtensions = $packageStatesGenerator->generate($frameworkExtensions, $excludedExtensions, $activateDefault); try { // Make sure file caches are empty after generating package states file CommandDispatcher::createFromCommandRun()->executeCommand('cache:flush', ['--files-only']); } catch (FailedSubProcessCommandException $e) { // Ignore errors here. // They might be triggered from extensions accessing db or having other things // broken in ext_tables or ext_localconf // In such case we cannot do much about it other than ignoring it for // generating packages states } $this->outputLine( '<info>The following extensions have been added to the generated PackageStates.php file:</info> %s', [ implode(', ', array_map(function (PackageInterface $package) { return $package->getPackageKey(); }, $activatedExtensions)), ] ); if (!empty($excludedExtensions)) { $this->outputLine( '<info>The following third party extensions were excluded during this process:</info> %s', [ implode(', ', $excludedExtensions), ] ); } }
php
{ "resource": "" }
q256130
InstallCommandController.fixFolderStructureCommand
test
public function fixFolderStructureCommand() { $folderStructureFactory = new ExtensionFactory($this->packageManager); $fixedStatusObjects = $folderStructureFactory ->getStructure() ->fix(); if (empty($fixedStatusObjects)) { $this->outputLine('<info>No action performed!</info>'); } else { $this->outputLine('<info>The following directory structure has been fixed:</info>'); foreach ($fixedStatusObjects as $fixedStatusObject) { $this->outputLine($fixedStatusObject->getTitle()); } } }
php
{ "resource": "" }
q256131
InstallCommandController.extensionSetupIfPossibleCommand
test
public function extensionSetupIfPossibleCommand() { $commandDispatcher = CommandDispatcher::createFromCommandRun(); try { $this->outputLine($commandDispatcher->executeCommand('database:updateschema')); $this->outputLine($commandDispatcher->executeCommand('cache:flush')); $this->outputLine($commandDispatcher->executeCommand('extension:setupactive')); } catch (FailedSubProcessCommandException $e) { $this->outputLine('<warning>Extension setup skipped.</warning>'); } }
php
{ "resource": "" }
q256132
InstallCommandController.executeActionWithArguments
test
private function executeActionWithArguments($actionName, array $arguments = [], $dryRun = false) { $this->outputLine(serialize($this->installStepActionExecutor->executeActionWithArguments($actionName, $arguments, $dryRun))); }
php
{ "resource": "" }
q256133
CommandDispatcher.createFromComposerRun
test
public static function createFromComposerRun(...$arguments): self { if (isset($arguments[0]) && $arguments[0] instanceof ScriptEvent) { // Calling createFromComposerRun with ScriptEvent as first argument is deprecated and will be removed with 6.0 array_shift($arguments); } $commandLine = $arguments[0] ?? []; $environmentVars = $arguments[1] ?? []; $phpFinder = $arguments[2] ?? null; // should be Application::COMMAND_NAME, but our Application class currently conflicts with symfony/console 2.7, which is used by Composer $typo3CommandPath = dirname(__DIR__, 4) . '/typo3cms'; $environmentVars['TYPO3_CONSOLE_PLUGIN_RUN'] = true; return self::create($typo3CommandPath, $commandLine, $environmentVars, $phpFinder); }
php
{ "resource": "" }
q256134
CommandDispatcher.createFromCommandRun
test
public static function createFromCommandRun(array $commandLine = [], array $environmentVars = [], PhpExecutableFinder $phpFinder = null): self { if (!isset($_SERVER['argv'][0]) && strpos($_SERVER['argv'][0], Application::COMMAND_NAME) === false) { throw new RuntimeException('Tried to create typo3 command runner from wrong context', 1484945065); } $typo3CommandPath = $_SERVER['argv'][0]; return self::create($typo3CommandPath, $commandLine, $environmentVars, $phpFinder); }
php
{ "resource": "" }
q256135
CommandDispatcher.create
test
public static function create($typo3CommandPath, array $commandLine = [], array $environmentVars = [], PhpExecutableFinder $phpFinder = null): self { $environmentVars['TYPO3_CONSOLE_SUB_PROCESS'] = true; $phpFinder = $phpFinder ?: new PhpExecutableFinder(); if (!($php = $phpFinder->find(false))) { throw new RuntimeException('The "php" binary could not be found.', 1485128615); } array_unshift($commandLine, $typo3CommandPath); $phpArguments = $phpFinder->findArguments(); if (getenv('PHP_INI_PATH')) { $phpArguments[] = '-c'; $phpArguments[] = getenv('PHP_INI_PATH'); } // Ensure we do not output PHP startup errors for sub-processes to not have them interfere with process output // Later, very early in booting the error reporting is set to an appropriate value anyway $phpArguments[] = '-d'; $phpArguments[] = 'error_reporting=0'; array_unshift($commandLine, ...$phpArguments); array_unshift($commandLine, $php); return new self($commandLine, $environmentVars); }
php
{ "resource": "" }
q256136
CommandDispatcher.executeCommand
test
public function executeCommand($command, array $arguments = [], array $envVars = [], $input = null): string { $envVars = array_replace($this->environmentVars, $envVars); $commandLine = $this->commandLinePrefix; $commandLine[] = $command; foreach ($arguments as $argumentName => $argumentValue) { if (is_int($argumentName)) { $commandLine[] = $argumentValue; } else { $commandLine[] = $this->getDashedArgumentName($argumentName); $commandLine[] = is_array($argumentValue) ? implode(',', $argumentValue) : $argumentValue; } } $process = $this->getProcess($commandLine, $envVars, $input); $process->run(); $output = str_replace("\r\n", "\n", trim($process->getOutput())); if (!$process->isSuccessful()) { throw FailedSubProcessCommandException::forProcess($command, $process); } return $output; }
php
{ "resource": "" }
q256137
ExceptionHandler.handleException
test
public function handleException(\Throwable $exception) { $this->exceptionRenderer->render($exception, $this->output->getErrorOutput()); echo PHP_EOL; exit(1); }
php
{ "resource": "" }
q256138
UpgradeWizardFactory.create
test
public function create(string $identifier) { /** @var AbstractUpdate|UpgradeWizardInterface $upgradeWizard */ $upgradeWizard = $this->objectManager->get($this->getClassNameFromIdentifier($identifier)); if ($upgradeWizard instanceof AbstractUpdate) { $upgradeWizard->setIdentifier($identifier); } if ($upgradeWizard instanceof ChattyInterface) { $output = new BufferedOutput(); $upgradeWizard->setOutput($output); } return $upgradeWizard; }
php
{ "resource": "" }
q256139
TextDescriptor.wordWrap
test
private function wordWrap(string $stringToWrap, int $indent, $maxWidth): string { $wrapped = $maxWidth === null ? $stringToWrap : wordwrap($stringToWrap, $maxWidth, "\n", true); return preg_replace('/\s*[\r\n]\s*/', "\n" . str_repeat(' ', $indent), $wrapped); }
php
{ "resource": "" }
q256140
FrontendCommandController.requestCommand
test
public function requestCommand($requestUrl) { // TODO: this needs heavy cleanup! $template = file_get_contents(__DIR__ . '/../../../Resources/Private/Templates/request.tpl'); $arguments = [ 'documentRoot' => getenv('TYPO3_PATH_WEB') ?: PATH_site, 'requestUrl' => $this->makeAbsolute($requestUrl), ]; // No other solution atm than to fake a CLI request type $code = str_replace('{arguments}', var_export($arguments, true), $template); $process = new PhpProcess($code, null, null, 0); $process->mustRun(); $rawResponse = json_decode($process->getOutput()); if ($rawResponse === null || $rawResponse->status === 'failure') { $this->outputLine('<error>An error occurred while trying to request the specified URL.</error>'); $this->outputLine(sprintf('<error>Error: %s</error>', !empty($rawResponse->error) ? $rawResponse->error : 'Could not decode response. Please check your error log!')); $this->outputLine(sprintf('<error>Content: %s</error>', $process->getOutput())); $this->quit(1); } $this->output($rawResponse->content); }
php
{ "resource": "" }
q256141
FrontendCommandController.makeAbsolute
test
protected function makeAbsolute($url) { $parsedUrl = parse_url($url); $scheme = isset($parsedUrl['scheme']) ? $parsedUrl['scheme'] : 'http'; $host = isset($parsedUrl['host']) ? $parsedUrl['host'] : 'localhost'; $path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '/'; $query = isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : ''; return $scheme . '://' . $host . '/' . ltrim($path, '/') . $query; }
php
{ "resource": "" }
q256142
UpgradeCommandController.checkExtensionConstraintsCommand
test
public function checkExtensionConstraintsCommand(array $extensionKeys = [], $typo3Version = TYPO3_version) { if (empty($extensionKeys)) { $failedPackageMessages = $this->upgradeHandling->matchAllExtensionConstraints($typo3Version); } else { $failedPackageMessages = []; foreach ($extensionKeys as $extensionKey) { try { if (!empty($result = $this->upgradeHandling->matchExtensionConstraints($extensionKey, $typo3Version))) { $failedPackageMessages[$extensionKey] = $result; } } catch (UnknownPackageException $e) { $this->outputLine('<warning>Extension "%s" is not found in the system</warning>', [$extensionKey]); } } } foreach ($failedPackageMessages as $constraintMessage) { $this->outputLine('<error>%s</error>', [$constraintMessage]); } if (empty($failedPackageMessages)) { $this->outputLine('<info>All third party extensions claim to be compatible with TYPO3 version %s</info>', [$typo3Version]); } else { $this->quit(1); } }
php
{ "resource": "" }
q256143
UpgradeCommandController.listCommand
test
public function listCommand($all = false) { $verbose = $this->output->getSymfonyConsoleOutput()->isVerbose(); $messages = []; $wizards = $this->upgradeHandling->executeInSubProcess('listWizards', [], $messages); $listRenderer = new UpgradeWizardListRenderer(); $this->outputLine('<comment>Wizards scheduled for execution:</comment>'); $listRenderer->render($wizards['scheduled'], $this->output, $verbose); if ($all) { $this->outputLine(PHP_EOL . '<comment>Wizards marked as done:</comment>'); $listRenderer->render($wizards['done'], $this->output, $verbose); } $this->outputLine(); foreach ($messages as $message) { $this->outputLine($message); } }
php
{ "resource": "" }
q256144
UpgradeCommandController.wizardCommand
test
public function wizardCommand($identifier, array $arguments = [], $force = false) { $messages = []; $result = $this->upgradeHandling->executeInSubProcess('executeWizard', [$identifier, $arguments, $force], $messages); (new UpgradeWizardResultRenderer())->render([$identifier => $result], $this->output); $this->outputLine(); foreach ($messages as $message) { $this->outputLine($message); } }
php
{ "resource": "" }
q256145
UpgradeCommandController.allCommand
test
public function allCommand(array $arguments = []) { $verbose = $this->output->getSymfonyConsoleOutput()->isVerbose(); $this->outputLine(PHP_EOL . '<i>Initiating TYPO3 upgrade</i>' . PHP_EOL); $messages = []; $results = $this->upgradeHandling->executeAll($arguments, $this->output, $messages); $this->outputLine(PHP_EOL . PHP_EOL . '<i>Successfully upgraded TYPO3 to version %s</i>', [TYPO3_version]); if ($verbose) { $this->outputLine(); $this->outputLine('<comment>Upgrade report:</comment>'); (new UpgradeWizardResultRenderer())->render($results, $this->output); } $this->outputLine(); foreach ($messages as $message) { $this->outputLine($message); } }
php
{ "resource": "" }
q256146
UpgradeCommandController.subProcessCommand
test
public function subProcessCommand($upgradeCommand, $arguments) { $arguments = unserialize($arguments, ['allowed_classes' => false]); $result = $this->upgradeHandling->$upgradeCommand(...$arguments); $this->output(serialize($result)); }
php
{ "resource": "" }
q256147
UpgradeCommandController.checkExtensionCompatibilityCommand
test
public function checkExtensionCompatibilityCommand($extensionKey, $configOnly = false) { $this->output(\json_encode($this->upgradeHandling->isCompatible($extensionKey, $configOnly))); }
php
{ "resource": "" }
q256148
ExtensionSetup.setupExtensions
test
public function setupExtensions(array $packages) { foreach ($packages as $package) { $this->extensionFactory->getExtensionStructure($package)->fix(); $this->callInstaller('importInitialFiles', [PathUtility::stripPathSitePrefix($package->getPackagePath()), $package->getPackageKey()]); $this->extensionConfiguration->saveDefaultConfiguration($package->getPackageKey()); } $this->schemaService->updateSchema(SchemaUpdateType::expandSchemaUpdateTypes(['safe'])); foreach ($packages as $package) { $relativeExtensionPath = PathUtility::stripPathSitePrefix($package->getPackagePath()); $extensionKey = $package->getPackageKey(); $this->callInstaller('importStaticSqlFile', [$relativeExtensionPath]); $this->callInstaller('importT3DFile', [$relativeExtensionPath]); $this->callInstaller('emitAfterExtensionInstallSignal', [$extensionKey]); } }
php
{ "resource": "" }
q256149
ExtensionFactory.getStructure
test
public function getStructure() { $structure = $this->getDefaultStructureDefinition(); $structure['children'] = $this->appendStructureDefinition($structure['children'], $this->createExtensionStructureDefinition($this->packageManager->getActivePackages())); return new StructureFacade(new RootNode($structure)); }
php
{ "resource": "" }
q256150
ExtensionFactory.getExtensionStructure
test
public function getExtensionStructure(PackageInterface $package) { $structure = [ 'name' => substr(PATH_site, 0, -1), 'targetPermission' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'], 'children' => $this->appendStructureDefinition([], $this->createExtensionStructureDefinition([$package])), ]; return new StructureFacade(new RootNode($structure)); }
php
{ "resource": "" }
q256151
ExtensionFactory.createExtensionStructureDefinition
test
private function createExtensionStructureDefinition(array $packages) { $structureBase = []; foreach ($packages as $package) { $extensionConfiguration = $this->packageManager->getExtensionConfiguration($package); if (isset($extensionConfiguration['uploadfolder']) && (bool)$extensionConfiguration['uploadfolder']) { $structureBase[] = $this->getExtensionUploadDirectory($package->getPackageKey()); } if (!empty($extensionConfiguration['createDirs'])) { foreach (explode(',', $extensionConfiguration['createDirs']) as $directoryToCreate) { $absolutePath = GeneralUtility::getFileAbsFileName(trim($directoryToCreate)); // Only create valid paths. if (!empty($absolutePath)) { $structureBase[] = $this->getDirectoryNodeByPath(PathUtility::stripPathSitePrefix($absolutePath)); } } } } return $structureBase; }
php
{ "resource": "" }
q256152
XsdGenerator.generateXmlForClassName
test
protected function generateXmlForClassName($className, \SimpleXMLElement $xmlRootNode) { $reflectionClass = new \ReflectionClass($className); $tagName = $this->getTagNameForClass($className); $xsdElement = $xmlRootNode->addChild('xsd:element'); $xsdElement['name'] = $tagName; $this->docCommentParser->parseDocComment($reflectionClass->getDocComment()); $this->addDocumentation($this->docCommentParser->getDescription(), $xsdElement); $xsdComplexType = $xsdElement->addChild('xsd:complexType'); $xsdComplexType['mixed'] = 'true'; $xsdSequence = $xsdComplexType->addChild('xsd:sequence'); $xsdAny = $xsdSequence->addChild('xsd:any'); $xsdAny['minOccurs'] = '0'; $xsdAny['maxOccurs'] = 'unbounded'; $this->addAttributes($className, $xsdComplexType); }
php
{ "resource": "" }
q256153
XsdGenerator.addAttributes
test
protected function addAttributes($className, \SimpleXMLElement $xsdElement) { /** @var AbstractViewHelper $viewHelper */ $viewHelper = $this->objectManager->get($className); $argumentDefinitions = $viewHelper->prepareArguments(); /** @var $argumentDefinition ArgumentDefinition */ foreach ($argumentDefinitions as $argumentDefinition) { $xsdAttribute = $xsdElement->addChild('xsd:attribute'); $xsdAttribute['type'] = 'xsd:string'; $xsdAttribute['name'] = $argumentDefinition->getName(); $this->addDocumentation($argumentDefinition->getDescription(), $xsdAttribute); if ($argumentDefinition->isRequired()) { $xsdAttribute['use'] = 'required'; } } }
php
{ "resource": "" }
q256154
XsdGenerator.addDocumentation
test
protected function addDocumentation($documentation, \SimpleXMLElement $xsdParentNode) { $xsdAnnotation = $xsdParentNode->addChild('xsd:annotation'); $this->addChildWithCData($xsdAnnotation, 'xsd:documentation', $documentation); }
php
{ "resource": "" }
q256155
CommandController.resolveCommandMethodName
test
protected function resolveCommandMethodName() { $commandMethodName = $this->request->getControllerCommandName() . 'Command'; if (!is_callable([$this, $commandMethodName])) { throw new NoSuchCommandException(sprintf('A command method "%s()" does not exist in controller "%s".', $commandMethodName, get_class($this)), 1300902143); } return $commandMethodName; }
php
{ "resource": "" }
q256156
CommandController.mapRequestArgumentsToControllerArguments
test
protected function mapRequestArgumentsToControllerArguments() { /** @var Argument $argument */ foreach ($this->arguments as $argument) { $argumentName = $argument->getName(); if ($this->request->hasArgument($argumentName)) { $argument->setValue($this->request->getArgument($argumentName)); continue; } if (!$argument->isRequired()) { continue; } $argumentValue = null; $commandArgumentDefinition = $this->objectManager->get(CommandArgumentDefinition::class, $argumentName, true, null); while ($argumentValue === null) { $argumentValue = $this->output->ask(sprintf('<comment>Please specify the required argument "%s":</comment> ', $commandArgumentDefinition->getDashedName())); } $argument->setValue($argumentValue); } }
php
{ "resource": "" }
q256157
CommandController.callCommandMethod
test
protected function callCommandMethod() { $preparedArguments = []; foreach ($this->arguments as $argument) { $preparedArguments[] = $argument->getValue(); } $commandResult = $this->{$this->commandMethodName}(...$preparedArguments); if ($commandResult !== null) { $this->outputLine((string)$commandResult); $this->output->getSymfonyConsoleOutput()->getErrorOutput()->writeln('<warning>Returning a string from a command method is deprecated.</warning>'); $this->output->getSymfonyConsoleOutput()->getErrorOutput()->writeln('<warning>Please use $this->outputLine() instead.</warning>'); } }
php
{ "resource": "" }
q256158
CommandController.createDefaultLogger
test
protected function createDefaultLogger($minimumLevel = LogLevel::DEBUG, $options = []) { $options['output'] = $this->output->getSymfonyConsoleOutput(); $logger = new Logger(get_class($this)); $logger->addWriter($minimumLevel, new ConsoleWriter($options)); return $logger; }
php
{ "resource": "" }
q256159
Command.getShortDescription
test
public function getShortDescription(): string { $lines = explode(LF, $this->commandReflection->getDescription()); return !empty($lines) ? trim($lines[0]) : '<no description available>'; }
php
{ "resource": "" }
q256160
Command.parseDefinitions
test
private function parseDefinitions(): array { $definitions = []; $reader = new AnnotationReader(); $method = new \ReflectionMethod($this->controllerClassName, $this->controllerCommandMethod); foreach ($reader->getMethodAnnotations($method) as $annotation) { if ($annotation instanceof Option) { $definitions['Option'][] = $annotation; } if ($annotation instanceof Argument) { $definitions['Argument'][] = $annotation; } if ($annotation instanceof Validate) { $definitions['Validate'] = $annotation; } } return $definitions; }
php
{ "resource": "" }
q256161
Command.getSynopsis
test
public function getSynopsis($short = false): string { $key = $short ? 'short' : 'long'; if (isset($this->synopsis[$key])) { return $this->synopsis[$key]; } $elements = []; if ($short && $this->hasOptions()) { $elements[] = '[options]'; } elseif (!$short) { foreach ($this->getOptions() as $argumentDefinition) { $value = ''; if ($argumentDefinition->acceptsValue()) { $value = ' ' . strtoupper($argumentDefinition->getOptionName()); } $elements[] = sprintf('[%s%s]', $argumentDefinition->getDashedName(), $value); } } if (count($elements) && $this->hasRequiredArguments()) { $elements[] = '[--]'; } foreach ($this->getArguments() as $argumentDefinition) { $elements[] = '<' . $argumentDefinition->getName() . '>'; } return $this->synopsis[$key] = implode(' ', $elements); }
php
{ "resource": "" }
q256162
Sequence.removeStep
test
public function removeStep($stepIdentifier) { $removedOccurrences = 0; foreach ($this->steps as $previousStepIdentifier => $steps) { foreach ($steps as $index => $step) { if ($step->getIdentifier() === $stepIdentifier) { unset($this->steps[$previousStepIdentifier][$index]); $removedOccurrences ++; } } } if ($removedOccurrences === 0) { throw new Exception(sprintf('Cannot remove sequence step with identifier "%s" because no such step exists in the given sequence.', $stepIdentifier), 1322591669); } }
php
{ "resource": "" }
q256163
Sequence.invoke
test
public function invoke(Bootstrap $bootstrap) { if (isset($this->steps['start'])) { foreach ($this->steps['start'] as $step) { $this->invokeStep($step, $bootstrap); } } }
php
{ "resource": "" }
q256164
Sequence.invokeStep
test
protected function invokeStep(Step $step, Bootstrap $bootstrap) { $identifier = $step->getIdentifier(); try { $step($bootstrap); } catch (\Throwable $e) { throw new StepFailedException($step, $e); } if (isset($this->steps[$identifier])) { foreach ($this->steps[$identifier] as $followingStep) { $this->invokeStep($followingStep, $bootstrap); } } }
php
{ "resource": "" }
q256165
ExtensionCommandController.setupExtensions
test
private function setupExtensions(array $packages, $verbose = false) { $extensionSetupResultRenderer = new ExtensionSetupResultRenderer($this->signalSlotDispatcher); $extensionSetup = new ExtensionSetup( new ExtensionFactory($this->packageManager), $this->getExtensionInstaller() ); $extensionSetup->setupExtensions($packages); $extensionKeysAsString = implode('", "', array_map(function (PackageInterface $package) { return $package->getPackageKey(); }, $packages)); if (count($packages) === 1) { $this->outputLine('<info>Extension "%s" is now set up.</info>', [$extensionKeysAsString]); } else { $this->outputLine('<info>Extensions "%s" are now set up.</info>', [$extensionKeysAsString]); } if ($verbose) { $this->outputLine(); $extensionSetupResultRenderer->renderSchemaResult($this->output); $extensionSetupResultRenderer->renderExtensionDataImportResult($this->output); $extensionSetupResultRenderer->renderExtensionFileImportResult($this->output); $extensionSetupResultRenderer->renderImportedStaticDataResult($this->output); } }
php
{ "resource": "" }
q256166
ExtensionCommandController.setupActiveCommand
test
public function setupActiveCommand() { $verbose = $this->output->getSymfonyConsoleOutput()->isVerbose(); $this->setupExtensions($this->packageManager->getActivePackages(), $verbose); }
php
{ "resource": "" }
q256167
ExtensionCommandController.removeInactiveCommand
test
public function removeInactiveCommand($force = false) { $this->outputLine('<warning>This command is deprecated and will be removed with TYPO3 Console 6.0</warning>'); if ($force) { $activePackages = $this->packageManager->getActivePackages(); $this->packageManager->scanAvailablePackages(); foreach ($this->packageManager->getAvailablePackages() as $package) { if (empty($activePackages[$package->getPackageKey()])) { $this->packageManager->unregisterPackage($package); if (is_dir($package->getPackagePath())) { GeneralUtility::flushDirectory($package->getPackagePath()); $removedPaths[] = PathUtility::stripPathSitePrefix($package->getPackagePath()); } } } $this->packageManager->forceSortAndSavePackageStates(); if (!empty($removedPaths)) { $this->outputLine('<info>The following directories have been removed:</info>' . chr(10) . implode(chr(10), $removedPaths)); } else { $this->outputLine('<info>Nothing was removed</info>'); } } else { $this->outputLine('<warning>Operation not confirmed and has been skipped</warning>'); $this->quit(1); } }
php
{ "resource": "" }
q256168
ExtensionCommandController.listCommand
test
public function listCommand($active = false, $inactive = false, $raw = false) { $extensionInformation = []; if (!$active || $inactive) { $this->emitPackagesMayHaveChangedSignal(); $packages = $this->packageManager->getAvailablePackages(); } else { $packages = $this->packageManager->getActivePackages(); } foreach ($packages as $package) { if ($inactive && $this->packageManager->isPackageActive($package->getPackageKey())) { continue; } $metaData = $package->getPackageMetaData(); $extensionInformation[] = [ 'package_key' => $package->getPackageKey(), 'version' => $metaData->getVersion(), 'description' => $metaData->getDescription(), ]; } if ($raw) { $this->outputLine('%s', [implode(PHP_EOL, array_column($extensionInformation, 'package_key'))]); } else { $this->output->outputTable( $extensionInformation, ['Extension key', 'Version', 'Description'] ); } }
php
{ "resource": "" }
q256169
CacheLowLevelCleaner.forceFlushDatabaseCacheTables
test
public function forceFlushDatabaseCacheTables() { // Get all table names from Default connection starting with 'cf_' and truncate them $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); $connection = $connectionPool->getConnectionByName('Default'); $tableNames = $connection->getSchemaManager()->listTableNames(); foreach ($tableNames as $tableName) { if ($tableName === 'cache_treelist' || strpos($tableName, 'cf_') === 0) { $connection->truncate($tableName); } } // Check tables on other connections $remappedTables = isset($GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping']) ? array_keys((array)$GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping']) : []; foreach ($remappedTables as $tableName) { if ($tableName === 'cache_treelist' || strpos($tableName, 'cf_') === 0) { $connectionPool->getConnectionForTable($tableName)->truncate($tableName); } } }
php
{ "resource": "" }
q256170
ErrorHandler.handleError
test
public function handleError($errorLevel, $errorMessage, $errorFile, $errorLine) { if (error_reporting() === 0) { return; } $errorLevels = [ E_WARNING => 'Warning', E_NOTICE => 'Notice', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error', ]; if (in_array($errorLevel, (array)$this->exceptionalErrors, true)) { throw new \TYPO3\CMS\Core\Error\Exception($errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine, 1); } }
php
{ "resource": "" }
q256171
InstallerScripts.register
test
public static function register(Event $event, ScriptDispatcher $scriptDispatcher) { $scriptDispatcher->addInstallerScript(new PopulateCommandConfiguration(), 70); if (!class_exists(\TYPO3\CMS\Core\Composer\InstallerScripts::class) && !class_exists(\Helhum\Typo3ComposerSetup\Composer\InstallerScripts::class) && $event->getComposer()->getRepositoryManager()->getLocalRepository()->findPackage('typo3/cms', new EmptyConstraint()) !== null ) { // @deprecated can be removed once TYPO3 8 support is removed $scriptDispatcher->addInstallerScript(new WebDirectory()); $scriptDispatcher->addInstallerScript(new AutoloadConnector()); } }
php
{ "resource": "" }
q256172
ConsoleOutput.select
test
public function select($question, $choices, $default = null, $multiSelect = false, $attempts = false) { $question = (new ChoiceQuestion($question, $choices, $default)) ->setMultiselect($multiSelect) ->setMaxAttempts($attempts) ->setErrorMessage('Value "%s" is invalid'); return $this->getQuestionHelper()->ask($this->getInput(), $this->output, $question); }
php
{ "resource": "" }
q256173
ConsoleOutput.ask
test
public function ask($question, $default = null, array $autocomplete = null) { $question = (new Question($question, $default)) ->setAutocompleterValues($autocomplete); return $this->getQuestionHelper()->ask($this->getInput(), $this->output, $question); }
php
{ "resource": "" }
q256174
ConsoleOutput.askConfirmation
test
public function askConfirmation($question, $default = true) { $question = new ConfirmationQuestion($question, $default); return $this->getQuestionHelper()->ask($this->getInput(), $this->output, $question); }
php
{ "resource": "" }
q256175
ConsoleOutput.askHiddenResponse
test
public function askHiddenResponse($question, $fallback = true) { $question = (new Question($question)) ->setHidden(true) ->setHiddenFallback($fallback); return $this->getQuestionHelper()->ask($this->getInput(), $this->output, $question); }
php
{ "resource": "" }
q256176
ConsoleOutput.askAndValidate
test
public function askAndValidate($question, $validator, $attempts = false, $default = null, array $autocomplete = null) { $question = (new Question($question, $default)) ->setValidator($validator) ->setMaxAttempts($attempts) ->setAutocompleterValues($autocomplete); return $this->getQuestionHelper()->ask($this->getInput(), $this->output, $question); }
php
{ "resource": "" }
q256177
ConsoleOutput.askHiddenResponseAndValidate
test
public function askHiddenResponseAndValidate($question, $validator, $attempts = false, $fallback = true) { $question = (new Question($question)) ->setValidator($validator) ->setMaxAttempts($attempts) ->setHidden(true) ->setHiddenFallback($fallback); return $this->getQuestionHelper()->ask($this->getInput(), $this->output, $question); }
php
{ "resource": "" }
q256178
ListCommand.execute
test
protected function execute(InputInterface $input, OutputInterface $output) { $helper = new DescriptorHelper(); $helper->register('txt', new TextDescriptor()); $helper->describe($output, $this->getApplication(), [ 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'show_unavailable' => $input->getOption('all'), 'namespace' => $input->getArgument('namespace'), 'screen_width' => (new Terminal())->getWidth() - 4, ]); $application = $this->getApplication(); if (!$application instanceof Application) { return 0; } if (!$input->getArgument('namespace') && !$application->isFullyCapable() && !$input->getOption('all')) { $outputHelper = new SymfonyStyle($input, $output); $messages = [ '', sprintf( '<comment>TYPO3 %s.</comment>', $application->hasErrors() ? 'has errors' : 'is not fully set up' ), '<comment>Command list is reduced to only show low level commands.</comment>', sprintf( '<comment>Not listed commands will not work until %s.</comment>', $application->hasErrors() ? 'the errors are fixed' : 'TYPO3 is set up' ), sprintf( '<comment>Run "%s --all" to list all commands.</comment>', $_SERVER['PHP_SELF'] ), ]; $outputHelper->getErrorStyle()->writeln($messages); } return null; }
php
{ "resource": "" }
q256179
ConsoleWriter.writeLog
test
public function writeLog(\TYPO3\CMS\Core\Log\LogRecord $record) { $this->output->write( $this->wrapMessage(vsprintf($record->getMessage(), $record->getData()), $record->getLevel()), true ); return $this; }
php
{ "resource": "" }
q256180
SchemaUpdateResult.getPerformedUpdateTypes
test
public function getPerformedUpdateTypes() { $typesCount = []; foreach ($this->performedUpdates as $type => $performedUpdates) { $typesCount[$type] = count($performedUpdates); } return $typesCount; }
php
{ "resource": "" }
q256181
SchemaUpdateResult.addPerformedUpdates
test
public function addPerformedUpdates(SchemaUpdateType $schemaUpdateType, array $updates) { $this->performedUpdates[(string)$schemaUpdateType] = array_merge((array)$this->performedUpdates[(string)$schemaUpdateType], $updates); }
php
{ "resource": "" }
q256182
SchemaUpdateResult.addErrors
test
public function addErrors(SchemaUpdateType $schemaUpdateType, array $errors, array $statements = []) { $collectedErrors = []; foreach ($errors as $id => $error) { $collectedErrors[] = [ 'message' => $error, 'statement' => $statements[$id], ]; } $this->errors[(string)$schemaUpdateType] = array_merge((array)$this->errors[(string)$schemaUpdateType], $collectedErrors); }
php
{ "resource": "" }
q256183
ConfigurationCommandController.removeCommand
test
public function removeCommand(array $paths, $force = false) { foreach ($paths as $path) { if (!$this->configurationService->localIsActive($path)) { $this->outputLine('<warning>It seems that configuration for path "%s" is overridden.</warning>', [$path]); $this->outputLine('<warning>Removing the new value might have no effect.</warning>'); } if (!$force && $this->configurationService->hasLocal($path)) { $reallyDelete = $this->output->askConfirmation('Remove ' . $path . ' from system configuration (TYPO3_CONF_VARS)? (yes/<b>no</b>): ', false); if (!$reallyDelete) { continue; } } $removed = $this->configurationService->removeLocal($path); if ($removed) { $this->outputLine('<info>Removed "%s" from system configuration.</info>', [$path]); } else { $this->outputLine('<warning>Path "%s" seems invalid or empty. Nothing done!</warning>', [$path]); } } }
php
{ "resource": "" }
q256184
ConfigurationCommandController.showCommand
test
public function showCommand($path) { $hasActive = $this->configurationService->hasActive($path); $hasLocal = $this->configurationService->hasLocal($path); if (!$hasActive && !$hasLocal) { $this->outputLine('<error>No configuration found for path "%s"</error>', [$path]); $this->quit(1); } $active = null; if ($hasActive) { $active = $this->configurationService->getActive($path); } if ($this->configurationService->localIsActive($path) && $hasActive) { $this->outputLine($this->consoleRenderer->render($active)); } else { $local = null; if ($hasLocal) { $local = $this->configurationService->getLocal($path); } $this->outputLine($this->consoleRenderer->renderDiff($local, $active)); } }
php
{ "resource": "" }
q256185
ConfigurationCommandController.showActiveCommand
test
public function showActiveCommand($path, $json = false) { if (!$this->configurationService->hasActive($path)) { $this->outputLine('<error>No configuration found for path "%s"</error>', [$path]); $this->quit(1); } $active = $this->configurationService->getActive($path); $this->outputLine($this->consoleRenderer->render($active, $json)); }
php
{ "resource": "" }
q256186
ConfigurationCommandController.showLocalCommand
test
public function showLocalCommand($path, $json = false) { if (!$this->configurationService->hasLocal($path)) { $this->outputLine('<error>No configuration found for path "%s"</error>', [$path]); $this->quit(1); } $active = $this->configurationService->getLocal($path); $this->outputLine($this->consoleRenderer->render($active, $json)); }
php
{ "resource": "" }
q256187
ConfigurationCommandController.setCommand
test
public function setCommand($path, $value, $json = false) { if (!$this->configurationService->localIsActive($path)) { $this->outputLine('<warning>It seems that configuration for path "%s" is overridden.</warning>', [$path]); $this->outputLine('<warning>Writing the new value might have no effect.</warning>'); } $encodedValue = $value; if ($json) { $encodedValue = @json_decode($value, true); } if ($encodedValue === null && strtolower($value) !== 'null') { $this->outputLine('<error>Could not decode value "%s" as json.</error>', [$value]); $this->quit(2); } $setWasAllowed = $this->configurationService->setLocal($path, $encodedValue); $isApplied = $this->configurationService->hasLocal($path); if (!$setWasAllowed) { $this->outputLine('<warning>Could not set value "%s" for configuration path "%s".</warning>', [$value, $path]); $this->outputLine('<warning>Possible reasons: configuration path is not allowed, configuration is not writable or type of value does not match given type.</warning>', [$value, $path]); $this->quit(1); } if ($isApplied) { $this->outputLine('<info>Successfully set value for path "%s".</info>', [$path]); } else { $this->outputLine('<warning>Value "%s" for configuration path "%s" seems not applied.</warning>', [$value, $path]); $this->outputLine('<warning>Possible reasons: changed value in AdditionalConfiguration.php or extension ext_localconf.php</warning>'); } }
php
{ "resource": "" }
q256188
ExtensionInstallation.afterInstallation
test
public function afterInstallation($keyOfInstalledExtension) { if (self::EXTKEY !== $keyOfInstalledExtension) { return; } $scriptName = $this->isWindowsOs() ? 'Scripts/' . Application::COMMAND_NAME . '.bat' : Application::COMMAND_NAME; $success = $this->safeCopy(PATH_site . self::BINARY_PATH . $scriptName, PATH_site . basename($scriptName)); if (!$success) { self::addFlashMessage(sprintf(self::COPY_FAILED_MESSAGE, $scriptName), sprintf(self::COPY_FAILED_MESSAGE_TITLE, $scriptName, PATH_site), AbstractMessage::WARNING); } else { self::addFlashMessage(sprintf(self::COPY_SUCCESS_MESSAGE, $scriptName)); } }
php
{ "resource": "" }
q256189
ExtensionInstallation.addFlashMessage
test
protected function addFlashMessage($messageBody, $messageTitle = '', $severity = AbstractMessage::OK, $storeInSession = true) { if (PHP_SAPI === 'cli') { return; } if (!is_string($messageBody)) { throw new \InvalidArgumentException('The message body must be of type string, "' . gettype($messageBody) . '" given.', 1418250286); } $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $messageBody, $messageTitle, $severity, $storeInSession); $queue = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageQueue::class, self::EM_FLASH_MESSAGE_QUEUE_ID); $queue->enqueue($flashMessage); }
php
{ "resource": "" }
q256190
ExtensionInstallation.safeCopy
test
private function safeCopy($fullSourcePath, $fullTargetPath, $relativeWebDir = '') { if (file_exists($fullTargetPath)) { if (!is_file($fullTargetPath)) { // Seems to be a directory: ignore return false; } if (!self::isTypo3CmsBinary($fullTargetPath)) { // File is there but does not seem to be a previous version of our script: better ignore return false; } } if ($this->isWindowsOs()) { $success = @copy($fullSourcePath, $fullTargetPath); } else { $proxyFileContent = file_get_contents($fullSourcePath); $proxyFileContent = str_replace( 'require __DIR__ . \'/Scripts/typo3-console.php\';', '// In non Composer mode we\'re copied into TYPO3 web root require __DIR__ . \'/typo3conf/ext/typo3_console/Scripts/typo3-console.php\';', $proxyFileContent ); $success = file_put_contents($fullTargetPath, $proxyFileContent); } if ($success && !$this->isWindowsOs()) { $success = @chmod($fullTargetPath, 0755); } if ($success) { $success = @file_put_contents( $fullTargetPath, str_replace( '{$relative-web-dir}', $relativeWebDir, file_get_contents($fullTargetPath) ) ); } return $success; }
php
{ "resource": "" }
q256191
DocumentationCommandController.generateXsdCommand
test
public function generateXsdCommand($phpNamespace, $xsdNamespace = null, $targetFile = null) { if ($xsdNamespace === null) { $phpNamespace = rtrim($phpNamespace, '_\\'); if (strpos($phpNamespace, '\\') === false) { $search = ['Tx_', '_']; $replace = ['', '/']; } else { $search = '\\'; $replace = '/'; } $xsdNamespace = sprintf('http://typo3.org/ns/%s', str_replace($search, $replace, $phpNamespace)); } $xsdSchema = ''; try { $xsdSchema = $this->xsdGenerator->generateXsd($phpNamespace, $xsdNamespace); } catch (Service\Exception $exception) { $this->outputLine('An error occurred while trying to generate the XSD schema:'); $this->outputLine('%s', [$exception->getMessage()]); $this->quit(1); } if ($targetFile === null) { echo $xsdSchema; } else { file_put_contents($targetFile, $xsdSchema); } }
php
{ "resource": "" }
q256192
Scripts.initializePackageManagement
test
private static function initializePackageManagement(Bootstrap $bootstrap) { $packageManager = CompatibilityScripts::createPackageManager(); $bootstrap->setEarlyInstance(PackageManager::class, $packageManager); GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager); ExtensionManagementUtility::setPackageManager($packageManager); $packageManager->init(); }
php
{ "resource": "" }
q256193
Scripts.overrideImplementation
test
public static function overrideImplementation($originalClassName, $overrideClassName) { self::registerImplementation($originalClassName, $overrideClassName); $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][$originalClassName]['className'] = $overrideClassName; class_alias($overrideClassName, $originalClassName); }
php
{ "resource": "" }
q256194
Scripts.registerImplementation
test
private static function registerImplementation($className, $alternativeClassName) { /** @var $extbaseObjectContainer \TYPO3\CMS\Extbase\Object\Container\Container */ $extbaseObjectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class); $extbaseObjectContainer->registerImplementation($className, $alternativeClassName); }
php
{ "resource": "" }
q256195
ConfigurationService.setLocal
test
public function setLocal($path, $value, $targetType = '') { try { $value = $this->convertToTargetType($path, $value, $targetType); return $this->configurationManager->setLocalConfigurationValueByPath($path, $value); } catch (TypesAreNotConvertibleException $e) { return false; } }
php
{ "resource": "" }
q256196
ConfigurationService.convertToTargetType
test
public function convertToTargetType($path, $value, $targetType = '') { $targetType = $targetType ?: $this->getType($path); $actualType = gettype($value); if ($actualType !== $targetType && $targetType !== 'NULL') { if ($this->isTypeConvertible($targetType, $actualType)) { switch ($targetType) { case 'integer': $value = (int)$value; break; case 'float': case 'double': $value = (float)$value; break; case 'boolean': $value = (bool)$value; break; case 'string': $value = (string)$value; break; default: // We don't know any type conversion, so we better exit throw new TypesAreNotConvertibleException(sprintf('Unknown target type "%s"', $targetType), 1477778705); } } else { // We cannot convert from or to non scalar types, so we better exit throw new TypesAreNotConvertibleException(sprintf('Cannot convert type from "%s" to "%s"', $actualType, $targetType), 1477778754); } } return $value; }
php
{ "resource": "" }
q256197
ConfigurationService.getType
test
private function getType($path) { $value = null; if ($this->hasActive($path)) { $value = $this->getActive($path); } if ($this->hasLocal($path)) { $value = $this->getLocal($path); } if ($this->hasDefault($path)) { $value = $this->getDefault($path); } return gettype($value); }
php
{ "resource": "" }
q256198
ConfigurationService.isTypeConvertible
test
private function isTypeConvertible($targetType, $actualType) { if (in_array($targetType, ['array', 'object', 'resource'], true)) { return false; } if (in_array($actualType, ['array', 'object', 'resource'], true)) { return false; } return true; }
php
{ "resource": "" }
q256199
Application.isCommandAvailable
test
public function isCommandAvailable(Command $command): bool { if (!$this->isFullyCapable() && in_array($command->getName(), [ // Although these commands are technically available // they call other hidden commands in sub processes // that need all capabilities. Therefore we disable these commands here. // This can be removed, once they implement Symfony commands directly. 'upgrade:all', 'upgrade:list', 'upgrade:wizard', ], true) ) { return false; } if ($command->getName() === 'cache:flushcomplete') { return true; } return $this->runLevel->isCommandAvailable($command->getName()); }
php
{ "resource": "" }