Change record status: 
Project: 
Introduced in branch: 
11.3.x
Introduced in version: 
11.3.0
Description: 

Batch api callbacks such finish or operation callbacks now support any callables that Drupal\Core\Utility\CallableResolver supports.

These callbacks can now live in services and will support dependency injection.

Note that the callback no longer needs to be static. See allowed callables in the related change record.
⚠️ Warning
Using $this as a pointer for form callback [$this, 'someMethod'] is an antipattern and should be avoided to prevent the full object from being serialized.

Batch Builder:

Create the Batch Builder object first:
$batch_builder = new BatchBuilder();

Before operations:
$batch_builder->addOperation([$batch_test_callbacks, 'titleCallback'], []);

After operations:
$batch_builder->addOperation(BatchInjectionCallbacks::class . ':titleCallback', []);

Before finished:
$batch_builder->setFinishCallback([$batch_test_callbacks, 'finished1Finished']);

After finished:
$batch_builder->setFinishCallback(BatchTestCallbacks::class . ':finished1Finished');

Batch Array:

Before operations:
'operations' => [[[$batch_test_callbacks, 'titleCallback'], []]],

After operations:

'operations' => [[BatchInjectionCallbacks::class . ':titleCallback', []]],

Before finished:
$batch['finished'] = [$batch_test_callbacks, 'finished1Finished'];

After finished:
$batch['finished'] = BatchTestCallbacks::class . ':finished1Finished';

Impacts: 
Module developers