core/modules/file/src/FileServiceProvider.php | 1 - .../file/src/Plugin/rest/resource/FileUploadResource.php | 12 ++++++------ .../EntityResource/File/FileUploadHalJsonTestBase.php | 3 +-- core/modules/rest/src/RequestHandler.php | 2 +- .../rest/tests/src/Functional/FileUploadResourceTestBase.php | 2 -- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/core/modules/file/src/FileServiceProvider.php b/core/modules/file/src/FileServiceProvider.php index 35dd4a5..a22750a 100644 --- a/core/modules/file/src/FileServiceProvider.php +++ b/core/modules/file/src/FileServiceProvider.php @@ -2,7 +2,6 @@ namespace Drupal\file; - use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceModifierInterface; use Drupal\Core\StackMiddleware\NegotiationMiddleware; diff --git a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php index 154ee9d..12982a3 100644 --- a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php +++ b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php @@ -25,7 +25,6 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; use Symfony\Component\Routing\Route; -use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -268,7 +267,7 @@ public function post(Request $request, $entity_type_id, $bundle, $field_name) { */ protected function streamUploadData() { // 'rb' is needed so reading works correctly on Windows environments too. - $file_data = fopen('php://input','rb'); + $file_data = fopen('php://input', 'rb'); $temp_file_path = $this->fileSystem->tempnam('temporary://', 'file'); $temp_file = fopen($temp_file_path, 'wb'); @@ -424,7 +423,7 @@ protected function validate(FileInterface $file, FieldDefinitionInterface $field * @param string $filename * The file name. * @param array $validators - * The array of upload validators. + * The array of upload validators. * * @return string * The prepared/munged filename. @@ -479,14 +478,15 @@ protected function getUploadLocation(array $settings) { /** * Retrieves the upload validators for a field definition. * + * This is copied from \Drupal\file\Plugin\Field\FieldType\FileItem as there + * is no entity instance available here that that a FileItem would exist for. + * * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition + * The field definition for which to get validators. * * @return array * An array suitable for passing to file_save_upload() or the file field * element's '#upload_validators' property. - * - * This is copied from \Drupal\file\Plugin\Field\FieldType\FileItem as there - * is no entity instance available here that that a FileItem would exist for. */ protected function getUploadValidators($field_definition) { $validators = [ diff --git a/core/modules/hal/tests/src/Functional/EntityResource/File/FileUploadHalJsonTestBase.php b/core/modules/hal/tests/src/Functional/EntityResource/File/FileUploadHalJsonTestBase.php index 3e0da32..80060cf 100644 --- a/core/modules/hal/tests/src/Functional/EntityResource/File/FileUploadHalJsonTestBase.php +++ b/core/modules/hal/tests/src/Functional/EntityResource/File/FileUploadHalJsonTestBase.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\hal\Functional\EntityResource\File; - use Drupal\Tests\rest\Functional\FileUploadResourceTestBase; use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait; @@ -28,7 +27,7 @@ /** * {@inheritdoc} */ - protected function getExpectedNormalizedEntity($fid = 1, $expected_filename = 'example.txt', $expected_as_filename = false) { + protected function getExpectedNormalizedEntity($fid = 1, $expected_filename = 'example.txt', $expected_as_filename = FALSE) { $normalization = parent::getExpectedNormalizedEntity($fid, $expected_filename, $expected_as_filename); // Cannot use applyHalFieldNormalization() as it uses the $entity property diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index 8a94416..e61e59d 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -118,7 +118,7 @@ public function handleRaw(RouteMatchInterface $route_match, Request $request) { * @param \Drupal\rest\RestResourceConfigInterface $resource_config * The REST resource config entity. * - * @return \Drupal\rest\ResourceResponseInterface $response + * @return \Drupal\rest\ResourceResponseInterface * The prepared REST resource response. */ protected function prepareResponse($response, RestResourceConfigInterface $resource_config) { diff --git a/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php b/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php index 4278293..cadb2bd 100644 --- a/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php @@ -12,8 +12,6 @@ use Drupal\file\Entity\File; use Drupal\rest\RestResourceConfigInterface; use Drupal\Tests\RandomGeneratorTrait; -use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait; -use Drupal\Tests\rest\Functional\ResourceTestBase; use Drupal\user\Entity\User; use GuzzleHttp\RequestOptions; use Psr\Http\Message\ResponseInterface;