Commit 6e5de2b5 authored by catch's avatar catch

Issue #2664290 by tstoeckler: Remove array typehints from batch callbacks

parent 74d7b55b
...@@ -544,10 +544,10 @@ public function initialize() { ...@@ -544,10 +544,10 @@ public function initialize() {
/** /**
* Processes extensions as a batch operation. * Processes extensions as a batch operation.
* *
* @param array $context. * @param array|\ArrayAccess $context.
* The batch context. * The batch context.
*/ */
protected function processExtensions(array &$context) { protected function processExtensions(&$context) {
$operation = $this->getNextExtensionOperation(); $operation = $this->getNextExtensionOperation();
if (!empty($operation)) { if (!empty($operation)) {
$this->processExtension($operation['type'], $operation['op'], $operation['name']); $this->processExtension($operation['type'], $operation['op'], $operation['name']);
...@@ -564,10 +564,10 @@ protected function processExtensions(array &$context) { ...@@ -564,10 +564,10 @@ protected function processExtensions(array &$context) {
/** /**
* Processes configuration as a batch operation. * Processes configuration as a batch operation.
* *
* @param array $context. * @param array|\ArrayAccess $context.
* The batch context. * The batch context.
*/ */
protected function processConfigurations(array &$context) { protected function processConfigurations(&$context) {
// The first time this is called we need to calculate the total to process. // The first time this is called we need to calculate the total to process.
// This involves recalculating the changelist which will ensure that if // This involves recalculating the changelist which will ensure that if
// extensions have been processed any configuration affected will be taken // extensions have been processed any configuration affected will be taken
...@@ -607,10 +607,10 @@ protected function processConfigurations(array &$context) { ...@@ -607,10 +607,10 @@ protected function processConfigurations(array &$context) {
/** /**
* Handles processing of missing content. * Handles processing of missing content.
* *
* @param array $context * @param array|\ArrayAccess $context.
* Standard batch context. * Standard batch context.
*/ */
protected function processMissingContent(array &$context) { protected function processMissingContent(&$context) {
$sandbox = &$context['sandbox']['config']; $sandbox = &$context['sandbox']['config'];
if (!isset($sandbox['missing_content'])) { if (!isset($sandbox['missing_content'])) {
$missing_content = $this->configManager->findMissingContentDependencies(); $missing_content = $this->configManager->findMissingContentDependencies();
...@@ -639,10 +639,10 @@ protected function processMissingContent(array &$context) { ...@@ -639,10 +639,10 @@ protected function processMissingContent(array &$context) {
/** /**
* Finishes the batch. * Finishes the batch.
* *
* @param array $context. * @param array|\ArrayAccess $context.
* The batch context. * The batch context.
*/ */
protected function finish(array &$context) { protected function finish(&$context) {
$this->eventDispatcher->dispatch(ConfigEvents::IMPORT, new ConfigImporterEvent($this)); $this->eventDispatcher->dispatch(ConfigEvents::IMPORT, new ConfigImporterEvent($this));
// The import is now complete. // The import is now complete.
$this->lock->release(static::LOCK_NAME); $this->lock->release(static::LOCK_NAME);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* @param $MULTIPLE_PARAMS * @param $MULTIPLE_PARAMS
* Additional parameters specific to the batch. These are specified in the * Additional parameters specific to the batch. These are specified in the
* array passed to batch_set(). * array passed to batch_set().
* @param $context * @param array|\ArrayAccess $context.
* The batch context array, passed by reference. This contains the following * The batch context array, passed by reference. This contains the following
* properties: * properties:
* - 'finished': A float number between 0 and 1 informing the processing * - 'finished': A float number between 0 and 1 informing the processing
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
* all operations have finished, this is passed to callback_batch_finished() * all operations have finished, this is passed to callback_batch_finished()
* where results may be referenced to display information to the end-user, * where results may be referenced to display information to the end-user,
* such as how many total items were processed. * such as how many total items were processed.
* It is discouraged to typehint this parameter as an array, to allow an
* object implement \ArrayAccess to be passed.
*/ */
function callback_batch_operation($MULTIPLE_PARAMS, &$context) { function callback_batch_operation($MULTIPLE_PARAMS, &$context) {
$node_storage = \Drupal::entityTypeManager()->getStorage('node'); $node_storage = \Drupal::entityTypeManager()->getStorage('node');
......
...@@ -33,10 +33,10 @@ ...@@ -33,10 +33,10 @@
* batch is finished. Optional, defaults to TRUE. * batch is finished. Optional, defaults to TRUE.
* - 'use_remote': Whether or not to check the remote translation file. * - 'use_remote': Whether or not to check the remote translation file.
* Optional, defaults to TRUE. * Optional, defaults to TRUE.
* @param array $context * @param array|\ArrayAccess $context.
* The batch context. * The batch context.
*/ */
function locale_translation_batch_status_check($project, $langcode, array $options, array &$context) { function locale_translation_batch_status_check($project, $langcode, array $options, &$context) {
$failure = $checked = FALSE; $failure = $checked = FALSE;
$options += array( $options += array(
'finish_feedback' => TRUE, 'finish_feedback' => TRUE,
......
...@@ -185,10 +185,10 @@ function locale_translate_batch_build(array $files, array $options) { ...@@ -185,10 +185,10 @@ function locale_translate_batch_build(array $files, array $options) {
* LOCALE_NOT_CUSTOMIZED. * LOCALE_NOT_CUSTOMIZED.
* - 'message': Alternative message to display during import. Note, this must * - 'message': Alternative message to display during import. Note, this must
* be sanitized text. * be sanitized text.
* @param array $context * @param array|\ArrayAccess $context.
* Contains a list of files imported. * Contains a list of files imported.
*/ */
function locale_translate_batch_import($file, array $options, array &$context) { function locale_translate_batch_import($file, array $options, &$context) {
// Merge the default values in the $options array. // Merge the default values in the $options array.
$options += array( $options += array(
'overwrite_options' => array(), 'overwrite_options' => array(),
...@@ -268,10 +268,10 @@ function locale_translate_batch_import($file, array $options, array &$context) { ...@@ -268,10 +268,10 @@ function locale_translate_batch_import($file, array $options, array &$context) {
* *
* Save data of imported files. * Save data of imported files.
* *
* @param array $context * @param array|\ArrayAccess $context.
* Contains a list of imported files. * Contains a list of imported files.
*/ */
function locale_translate_batch_import_save(array $context) { function locale_translate_batch_import_save($context) {
if (isset($context['results']['files'])) { if (isset($context['results']['files'])) {
foreach ($context['results']['files'] as $file) { foreach ($context['results']['files'] as $file) {
// Update the file history if both project and version are known. This // Update the file history if both project and version are known. This
...@@ -293,10 +293,10 @@ function locale_translate_batch_import_save(array $context) { ...@@ -293,10 +293,10 @@ function locale_translate_batch_import_save(array $context) {
* *
* Refreshes translations after importing strings. * Refreshes translations after importing strings.
* *
* @param array $context * @param array|\ArrayAccess $context.
* Contains a list of strings updated and information about the progress. * Contains a list of strings updated and information about the progress.
*/ */
function locale_translate_batch_refresh(array &$context) { function locale_translate_batch_refresh(&$context) {
if (!isset($context['sandbox']['refresh'])) { if (!isset($context['sandbox']['refresh'])) {
$strings = $langcodes = array(); $strings = $langcodes = array();
if (isset($context['results']['stats'])) { if (isset($context['results']['stats'])) {
...@@ -597,12 +597,12 @@ function locale_config_batch_build(array $names, array $langcodes, array $option ...@@ -597,12 +597,12 @@ function locale_config_batch_build(array $names, array $langcodes, array $option
* An array of names of configuration objects to update. * An array of names of configuration objects to update.
* @param array $langcodes * @param array $langcodes
* (optional) Array of language codes to update. Defaults to all languages. * (optional) Array of language codes to update. Defaults to all languages.
* @param array $context * @param array|\ArrayAccess $context.
* Contains a list of files imported. * Contains a list of files imported.
* *
* @see locale_config_batch_build() * @see locale_config_batch_build()
*/ */
function locale_config_batch_refresh_name(array $names, array $langcodes, array &$context) { function locale_config_batch_refresh_name(array $names, array $langcodes, &$context) {
if (!isset($context['result']['stats']['config'])) { if (!isset($context['result']['stats']['config'])) {
$context['result']['stats']['config'] = 0; $context['result']['stats']['config'] = 0;
} }
......
...@@ -108,10 +108,10 @@ function _node_mass_update_helper(NodeInterface $node, array $updates, $langcode ...@@ -108,10 +108,10 @@ function _node_mass_update_helper(NodeInterface $node, array $updates, $langcode
* @param bool $revisions * @param bool $revisions
* (optional) TRUE if $nodes contains an array of revision IDs instead of * (optional) TRUE if $nodes contains an array of revision IDs instead of
* node IDs. Defaults to FALSE; will be ignored if $load is FALSE. * node IDs. Defaults to FALSE; will be ignored if $load is FALSE.
* @param array $context * @param array|\ArrayAccess $context.
* An array of contextual key/values. * An array of contextual key/values.
*/ */
function _node_mass_update_batch_process(array $nodes, array $updates, $load, $revisions, array &$context) { function _node_mass_update_batch_process(array $nodes, array $updates, $load, $revisions, &$context) {
if (!isset($context['sandbox']['progress'])) { if (!isset($context['sandbox']['progress'])) {
$context['sandbox']['progress'] = 0; $context['sandbox']['progress'] = 0;
$context['sandbox']['max'] = count($nodes); $context['sandbox']['max'] = count($nodes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment