Problem/Motivation

------ -------------------------------------------------------------------------------
Line custom_field.tokens.inc
------ -------------------------------------------------------------------------------
305 Call to deprecated method renderPlain() of class Drupal\Core\Render\Renderer:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\Render\RendererInterface::renderInIsolation() instead.
------ -------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------------------------------
Line src/Plugin/CustomField/FeedsType/FileTarget.php
------ ------------------------------------------------------------------------------------------------------
87 Fetching deprecated class constant EXISTS_ERROR of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Error instead.
96 Fetching deprecated class constant EXISTS_REPLACE of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Replace instead.
97 Fetching deprecated class constant EXISTS_RENAME of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Rename instead.
98 Fetching deprecated class constant EXISTS_ERROR of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Error instead.
118 Fetching deprecated class constant EXISTS_REPLACE of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Replace instead.
122 Fetching deprecated class constant EXISTS_RENAME of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Rename instead.
126 Fetching deprecated class constant EXISTS_ERROR of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Error instead.
226 Fetching deprecated class constant EXISTS_ERROR of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Error instead.
230 Fetching deprecated class constant EXISTS_REPLACE of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Replace instead.
362 Fetching deprecated class constant EXISTS_RENAME of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Rename instead.
------ ------------------------------------------------------------------------------------------------------

------ ----------------------------------------------------------------------------------------------------
Line src/Plugin/CustomField/FieldType/FileType.php
------ ----------------------------------------------------------------------------------------------------
143 Fetching deprecated class constant EXISTS_ERROR of interface Drupal\Core\File\FileSystemInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\File\FileExists::Error instead.
------ ----------------------------------------------------------------------------------------------------

------ --------------------------------------------------------------------------------------------
Line src/Plugin/CustomField/FieldWidget/FileWidget.php
------ --------------------------------------------------------------------------------------------
278 Call to deprecated method renderPlain() of interface Drupal\Core\Render\RendererInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\Render\RendererInterface::renderInIsolation() instead.
------ --------------------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/Plugin/CustomFieldFormatterManager.php
------ ------------------------------------------------------------------------------
64 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

------ --------------------------------------------------------------------------------------------
Line src/Plugin/DataType/CustomFieldStringLong.php
------ --------------------------------------------------------------------------------------------
57 Call to deprecated method renderPlain() of interface Drupal\Core\Render\RendererInterface:
in drupal:10.3.0 and is removed from drupal:12.0.0. Use
\Drupal\Core\Render\RendererInterface::renderInIsolation() instead.
------ --------------------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/Plugin/Field/FieldFormatter/CustomTemplateFormatter.php
------ ------------------------------------------------------------------------------
137 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------------------------------------
Line src/Plugin/Field/FieldType/CustomItemList.php
------ ------------------------------------------------------------------------------------------------------------
93 Method Drupal\custom_field\Plugin\Field\FieldType\CustomItemList::postSave() should return bool but return
statement is missing.
------ ------------------------------------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/Plugin/views/argument/CustomFieldDate.php
------ ------------------------------------------------------------------------------
51 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

(I'm ignoring the submodules for now)

Steps to reproduce

phpstan analyse -l0 custom_field

Proposed resolution

  • in custom_field.tokens.inc, FileWidget.php, and CustomFieldStringLong.php, use renderInIsolation()
  • in FileTarget.php and FileType.php, use FileExists constants in place of global constants
  • in CustomFieldFormatterManager.php, CustomTemplateFormatter.php, and CustomFieldDate.php, use dependency injection
  • in CustomItemList.php, return bool

Remaining tasks

make a MR

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

benstallings created an issue. See original summary.

benstallings’s picture

Assigned: benstallings » Unassigned
Status: Active » Needs review

I was not able to inject the dependency in CustomFieldFormatterManager because I don't fully understand what's going on there.

I did not inject the dependency in CustomFieldDate because that part of the code is already deprecated.

apmsooner’s picture

Status: Needs review » Needs work

These functions related to file were introduced in 10.3. These changes would therefore break 10.2 sites. I was holding off on these issues for that reason and deeming a new major version would be necessary.

apmsooner’s picture

Status: Needs work » Fixed

I bumped the core min version to 10.3 as thats when the core file changes got introduced. I reverted the one of the dependency injections that would have put a dependency on token module and lastly I fixed the failed test. There's just some dependency injection warnings left but can resolve those later.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.