phpcs errors - $this in plain function, DateTimeInterface not implementable

Created on 13 March 2023, almost 2 years ago
Updated 15 August 2024, 4 months ago

Problem/Motivation

phpcs using PHP 8.1 outputs the following errors:

FILE: /var/www/html/web/modules/contrib/smart_date/modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateRecurrenceFormatter.php
----------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------
 339 | ERROR | "$this" can no longer be used in a plain function or method since PHP 7.1.
----------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/smart_date/src/TypedData/Plugin/DataType/SmartDate.php
--------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------
 17 | ERROR | The interface DateTimeInterface is intended for type hints only and is not implementable.
--------------------------------------------------------------------------------------------------------

The latter is just because phpcs thinks the DateTimeInterface used there is the PHP global interface.

Proposed resolution

Attached patch fixes these errors.

📌 Task
Status

Needs work

Version

3.7

Component

Code

Created by

🇨🇦Canada bgilhome Victoria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @bgilhome
  • 🇺🇸United States a_handan

    I've created a new patch based on bgilhome's work on the original patch. This new patch should be compatible with the 4.1.x branch (I had issues with composer when trying to apply the original patch on a 4.0 or above version). Please review

  • Status changed to Needs work 4 months ago
  • 🇵🇭Philippines cleavinjosh

    Hi,

    After I run

    </code> in the <strong>3.7.x</strong> branch, I did not encounter the issue mentioned in the description.
    
    These are the issues I encountered:
    
    <code>➜  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml smart_date
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/smart_date.tokens.inc
    -----------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------
     101 | ERROR | [x] Use null coalesce operator instead of ternary operator.
     109 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    -----------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/tests/src/Functional/SmartDateTimezoneWidgetTest.php
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 7 ERRORS AND 1 WARNING AFFECTING 8 LINES
    ------------------------------------------------------------------------------------------------------------------------------------
       1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
       4 | WARNING | [x] Unused use statement
      53 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
      59 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
      60 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
      63 | ERROR   | [x] Array closing indentation error, expected 6 spaces but found 8
      67 | ERROR   | [x] Data types in @var tags need to be fully namespaced
     108 | ERROR   | [x] Data types in @var tags need to be fully namespaced
    ------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/smart_date.module
    -------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------
     137 | ERROR | [x] Each PHP statement must be on a line by itself
    -------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/README.md
    -----------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------
     104 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
     111 | ERROR   | [x] Expected 1 newline at end of file; 0 found
    -----------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/smart_date.install
    ---------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
    ---------------------------------------------------------------------------------------------------------------
      8 | ERROR   | [x] Expected strict_types=1, found strict_types = 1.
     66 | WARNING | [x] 'TODO: Need to populate $before here?' should match the format '@todo Fix problem X here.'
     83 | WARNING | [ ] Unused variable $query.
    ---------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/modules/smart_date_recur/smart_date_recur.tokens.inc
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------------------------------------
     124 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
     137 | WARNING | [ ] There must be no blank line following an inline comment
    ------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/modules/smart_date_recur/smart_date_recur.install
    ---------------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 3 LINES
    ---------------------------------------------------------------------------------------------------------------------------------
      6 | ERROR | [x] There must be exactly one blank line after the file comment
      7 | ERROR | [x] Expected 1 line before declare statement, found 0.
      7 | ERROR | [x] Expected strict_types=1, found strict_types = 1.
     60 | ERROR | [x] Short array syntax must be used to define arrays
    ---------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/modules/smart_date_recur/smart_date_recur.module
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     145 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     718 | WARNING | [x] 'TODO: store unaltered instances instead?' should match the format '@todo Fix problem X here.'
     770 | WARNING | [x] 'TODO: Delete invalid rule?' should match the format '@todo Fix problem X here.'
     771 | WARNING | [x] 'TODO: Log a warning.' should match the format '@todo Fix problem X here.'
     779 | WARNING | [x] 'TODO: Log a warning.' should match the format '@todo Fix problem X here.'
     884 | ERROR   | [ ] All functions defined in a module file must be prefixed with the module's name, found "array_key_last" but expected "smart_date_recur_array_key_last"
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/modules/smart_date_recur/src/Entity/SmartDateOverride.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\ContentEntityBase.
    -----------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/modules/smart_date_recur/src/Entity/SmartDateRule.php
    -------------------------------------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
    -------------------------------------------------------------------------------------------------------------------------------------
     558 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     705 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     765 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     779 | WARNING | [ ] Possible useless method overriding detected
    -------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/modules/smart_date_recur/src/Plugin/QueueWorker/RecurRuleUpdate.php
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Queue\QueueWorkerBase.
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/modules/smart_date_recur/src/Controller/Instances.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------------------
      19 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Symfony\Component\DependencyInjection\ContainerInterface.
     101 | WARNING | [ ] Unused variable $entity.
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/FormElement/Boolean.php
    -----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\config_translation\FormElement\FormElementBase.
    -----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Form/SmartDateFormatSettingsForm.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/SmartDateServiceProvider.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\smart_date\Normalizer\SmartDateItemNormalizer.
    ----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/TypedData/Plugin/DataType/SmartDate.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 8 ERRORS AFFECTING 6 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------
      7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\TypedData\Plugin\DataType\Timestamp.
     25 | ERROR | [ ] Class property $end_value should use lowerCamel naming without underscores
     25 | ERROR | [ ] Missing member variable doc comment
     26 | ERROR | [ ] Missing member variable doc comment
     27 | ERROR | [ ] Missing member variable doc comment
     28 | ERROR | [ ] Class property $rrule_index should use lowerCamel naming without underscores
     28 | ERROR | [ ] Missing member variable doc comment
     29 | ERROR | [ ] Missing member variable doc comment
    ------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Plugin/diff/Field/SmartdateFieldBuilder.php
    ----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldItemListInterface.
    ----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Plugin/Field/FieldWidget/SmartDateInlineWidget.php
    --------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------
     28 | ERROR | [x] Array closing indentation error, expected 4 spaces but found 6
    --------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Plugin/Field/FieldWidget/SmartDateTimezoneWidget.php
    ----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------------
     186 | WARNING | Only string literals should be passed to t() where possible
    ----------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 4 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------------------
      16 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface.
     118 | ERROR | [x] Use null coalesce operator instead of ternary operator.
     121 | ERROR | [x] Use null coalesce operator instead of ternary operator.
     122 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Plugin/Field/FieldType/SmartDateItem.php
    ----------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 1 WARNING AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------------------------------
      77 | WARNING | [x] '@todo: Define this via an options provider once' should match the format '@todo Fix problem X here.'
     142 | ERROR   | [x] Expected 1 space before "/"; 0 found
     142 | ERROR   | [x] Expected 1 space after "/"; 0 found
     142 | ERROR   | [x] Expected 1 space before "*"; 0 found
     142 | ERROR   | [x] Expected 1 space after "*"; 0 found
    ----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Plugin/Field/FieldType/DateTimeComputed.php
    -------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\TypedData\TypedData.
    -------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Plugin/migrate/process/ParseDates.php
    -------------------------------------------------------------------------------------------------------------------------------
    FOUND 97 ERRORS AND 20 WARNINGS AFFECTING 59 LINES
    -------------------------------------------------------------------------------------------------------------------------------
       5 | WARNING | [x] Unused use statement
      12 | WARNING | [ ] Line exceeds 80 characters; contains 116 characters
      13 | ERROR   | [x] Whitespace found at end of line
      15 | WARNING | [ ] Line exceeds 80 characters; contains 121 characters
      17 | WARNING | [ ] Line exceeds 80 characters; contains 105 characters
      18 | WARNING | [ ] Line exceeds 80 characters; contains 118 characters
      20 | WARNING | [ ] Line exceeds 80 characters; contains 94 characters
      21 | ERROR   | [x] Whitespace found at end of line
      23 | ERROR   | [x] Whitespace found at end of line
      32 | ERROR   | [x] Whitespace found at end of line
      34 | ERROR   | [x] Whitespace found at end of line
      38 | ERROR   | [x] There must be exactly one newline after the class comment
      48 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
      56 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
      82 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
      85 | WARNING | [ ] Line exceeds 80 characters; contains 115 characters
      94 | ERROR   | [x] Expected one space after the comma, 0 found
      94 | ERROR   | [x] Expected one space after the comma, 0 found
     101 | ERROR   | [x] Inline control structures are not allowed
     103 | ERROR   | [x] Expected one space after the comma, 0 found
     103 | ERROR   | [x] Expected one space after the comma, 0 found
     110 | ERROR   | [x] Inline control structures are not allowed
     117 | ERROR   | [x] Expected one space after the comma, 0 found
     117 | ERROR   | [x] Expected one space after the comma, 0 found
     123 | WARNING | [ ] Line exceeds 80 characters; contains 105 characters
     126 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
     128 | ERROR   | [x] Expected 1 space before "*"; 0 found
     128 | ERROR   | [x] Expected 1 space after "*"; 0 found
     128 | ERROR   | [x] Expected 1 space before "*"; 0 found
     128 | ERROR   | [x] Expected 1 space after "*"; 0 found
     128 | ERROR   | [x] Expected 1 space before "*"; 0 found
     128 | ERROR   | [x] Expected 1 space after "*"; 0 found
     137 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
     142 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
     147 | WARNING | [ ] Line exceeds 80 characters; contains 97 characters
     148 | ERROR   | [x] Expected 1 space after cast statement; 0 found
     154 | WARNING | [ ] Line exceeds 80 characters; contains 111 characters
     155 | WARNING | [ ] Line exceeds 80 characters; contains 111 characters
     159 | ERROR   | [x] Expected 1 space before "*"; 0 found
     159 | ERROR   | [x] Expected 1 space after "*"; 0 found
     159 | ERROR   | [x] Expected 1 space before "*"; 0 found
     159 | ERROR   | [x] Expected 1 space after "*"; 0 found
     164 | WARNING | [ ] Line exceeds 80 characters; contains 99 characters
     166 | ERROR   | [x] Expected 1 space before "*"; 0 found
     166 | ERROR   | [x] Expected 1 space after "*"; 0 found
     166 | ERROR   | [x] Expected 1 space before "*"; 0 found
     166 | ERROR   | [x] Expected 1 space after "*"; 0 found
     172 | ERROR   | [x] Expected 1 space before "*"; 0 found
     172 | ERROR   | [x] Expected 1 space after "*"; 0 found
     172 | ERROR   | [x] Expected 1 space before "*"; 0 found
     172 | ERROR   | [x] Expected 1 space after "*"; 0 found
     173 | ERROR   | [x] Expected 1 space before "*"; 0 found
     173 | ERROR   | [x] Expected 1 space after "*"; 0 found
     173 | ERROR   | [x] Expected 1 space before "*"; 0 found
     173 | ERROR   | [x] Expected 1 space after "*"; 0 found
     182 | ERROR   | [x] Inline control structures are not allowed
     182 | ERROR   | [x] Expected 0 spaces before semicolon; 1 found
     182 | ERROR   | [x] Expected 1 space before "*"; 0 found
     182 | ERROR   | [x] Expected 1 space after "*"; 0 found
     182 | ERROR   | [x] Expected 1 space before "*"; 0 found
     182 | ERROR   | [x] Expected 1 space after "*"; 0 found
     192 | ERROR   | [x] Inline control structures are not allowed
     197 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
     201 | WARNING | [ ] Line exceeds 80 characters; contains 93 characters
     216 | WARNING | [ ] Line exceeds 80 characters; contains 84 characters
     230 | ERROR   | [x] Expected 1 space before "*"; 0 found
     230 | ERROR   | [x] Expected 1 space after "*"; 0 found
     230 | ERROR   | [x] Expected 1 space before "*"; 0 found
     230 | ERROR   | [x] Expected 1 space after "*"; 0 found
     231 | ERROR   | [x] Expected 1 space before "*"; 0 found
     231 | ERROR   | [x] Expected 1 space after "*"; 0 found
     231 | ERROR   | [x] Expected 1 space before "*"; 0 found
     231 | ERROR   | [x] Expected 1 space after "*"; 0 found
     231 | ERROR   | [x] Expected 1 space before "*"; 0 found
     231 | ERROR   | [x] Expected 1 space after "*"; 0 found
     232 | ERROR   | [x] Expected 1 space before "*"; 0 found
     232 | ERROR   | [x] Expected 1 space after "*"; 0 found
     232 | ERROR   | [x] Expected 1 space before "*"; 0 found
     232 | ERROR   | [x] Expected 1 space after "*"; 0 found
     232 | ERROR   | [x] Expected 1 space before "*"; 0 found
     232 | ERROR   | [x] Expected 1 space after "*"; 0 found
     233 | ERROR   | [x] Expected 1 space before "*"; 0 found
     233 | ERROR   | [x] Expected 1 space after "*"; 0 found
     233 | ERROR   | [x] Expected 1 space before "*"; 0 found
     233 | ERROR   | [x] Expected 1 space after "*"; 0 found
     233 | ERROR   | [x] Expected 1 space before "*"; 0 found
     233 | ERROR   | [x] Expected 1 space after "*"; 0 found
     233 | WARNING | [x] A comma should follow the last multiline array item. Found: 60
     237 | ERROR   | [x] Expected 1 space after cast statement; 0 found
     239 | ERROR   | [x] Expected 1 space after cast statement; 0 found
     239 | ERROR   | [x] Expected 1 space after cast statement; 0 found
     239 | ERROR   | [x] Expected 1 space before "/"; 0 found
     239 | ERROR   | [x] Expected 1 space after "/"; 0 found
     255 | WARNING | [ ] Line exceeds 80 characters; contains 96 characters
     257 | ERROR   | [x] Inline control structures are not allowed
     271 | ERROR   | [x] Whitespace found at end of line
     284 | ERROR   | [x] Whitespace found at end of line
     299 | ERROR   | [x] Expected 1 space before "+"; 0 found
     299 | ERROR   | [x] Expected 1 space after "+"; 0 found
     305 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
     312 | ERROR   | [x] Inline control structures are not allowed
     327 | WARNING | [ ] Line exceeds 80 characters; contains 100 characters
     328 | ERROR   | [x] You must use "/**" style comments for a function comment
     328 | ERROR   | [x] Incorrect spacing between argument "$format" and equals sign; expected 1 but found 0
     328 | ERROR   | [x] Incorrect spacing between default value and equals sign for argument "$format"; expected 1 but found 0
     328 | ERROR   | [x] Incorrect spacing between argument "$timestamp" and equals sign; expected 1 but found 0
     328 | ERROR   | [x] Incorrect spacing between default value and equals sign for argument "$timestamp"; expected 1 but found 0
     328 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
     328 | ERROR   | [x] Incorrect spacing between argument "$timezone" and equals sign; expected 1 but found 0
     328 | ERROR   | [x] Incorrect spacing between default value and equals sign for argument "$timezone"; expected 1 but found 0
     328 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
     331 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
     331 | ERROR   | [x] Expected 1 space after cast statement; 0 found
     333 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
     333 | ERROR   | [x] Expected 1 space after cast statement; 0 found
     334 | ERROR   | [x] Expected 1 blank line after function; 0 found
     335 | ERROR   | [x] The closing brace for the class must have an empty line before it
    -------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 99 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Plugin/views/argument/Date.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AND 1 WARNING AFFECTING 5 LINES
    -------------------------------------------------------------------------------------------------------------------------
      45 | ERROR   | [ ] Class property $option_name should use lowerCamel naming without underscores
      45 | ERROR   | [ ] Missing member variable doc comment
     118 | ERROR   | [x] Missing function doc comment
     131 | ERROR   | [x] Missing function doc comment
     185 | WARNING | [ ] Line exceeds 80 characters; contains 94 characters
     192 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
    -------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Plugin/views/filter/Date.php
    ----------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
    ----------------------------------------------------------------------------------------------------------------
      9 | WARNING | [x] Unused use statement
     69 | ERROR   | [x] Missing function doc comment
     72 | ERROR   | [x] Inline comments must start with a capital letter
    ----------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Feeds/Target/SmartDate.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\feeds\Exception\EmptyFeedException.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/TwigExtension/SmartDateFormat.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
    -----------------------------------------------------------------------------------------------------------------------------
      7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\smart_date\SmartDateTrait.
     26 | ERROR   | [ ] Description for the @return value is missing
     32 | WARNING | [x] A comma should follow the last multiline array item. Found: )
     87 | WARNING | [ ] Unused private method getSetting()
     94 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
     94 | ERROR   | [ ] Description for the @return value is missing
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/SmartDateDurationConfigTrait.php
    --------------------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    --------------------------------------------------------------------------------------------------------------------
     22 | ERROR | [x] Use null coalesce operator instead of ternary operator.
     30 | ERROR | [x] Use null coalesce operator instead of ternary operator.
     47 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    --------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/SmartDateTrait.php
    -----------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
    -----------------------------------------------------------------------------------------------------------
       8 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is DateTimeZone.
       8 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
     259 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
     260 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
     556 | WARNING | [ ] Unused variable $year_pos.
     559 | WARNING | [ ] Unused variable $year_pos.
    -----------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Commands/SmartDateDrushCommands.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 7 ERRORS AND 1 WARNING AFFECTING 5 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------
       6 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
      41 | ERROR   | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
      42 | ERROR   | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 2
      42 | ERROR   | [x] Multi-line function declarations must define one parameter per line
      42 | ERROR   | [x] Multi-line function declarations must have a trailing comma after the last parameter
      42 | ERROR   | [x] The closing parenthesis of a multi-line function declaration must be on a new line
      75 | ERROR   | [ ] The array declaration extends to column 195 (the limit is 120). The array content should be split up over multiple lines
     199 | WARNING | [ ] Unused variable $result.
    ----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/smart_date/src/Normalizer/SmartDateItemNormalizer.php
    --------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------------------------------------------------------
     12 | WARNING | Line exceeds 80 characters; contains 93 characters
     16 | WARNING | Line exceeds 80 characters; contains 85 characters
    --------------------------------------------------------------------------------------------------------------------------
    
    Time: 3.86 secs; Memory: 18MB
    
    ➜  contrib

    I also tried to apply the patch by @bgilhome to 4.1.x branch and was not able to apply.

    ➜  smart_date git:(4.1.x) curl https://www.drupal.org/files/issues/2023-09-20/date-time-interface-not-implementable-3347525.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   795  100   795    0     0   2004      0 --:--:-- --:--:-- --:--:--  2007
    patching file src/TypedData/Plugin/DataType/SmartDate.php
    Reversed (or previously applied) patch detected!  Assume -R? [n] n
    Apply anyway? [n] n
    Skipping patch.
    2 out of 2 hunks ignored -- saving rejects to file src/TypedData/Plugin/DataType/SmartDate.php.rej
    ➜  smart_date git:(4.1.x) ✗
    ➜  smart_date git:(4.1.x) curl https://www.drupal.org/files/issues/2023-09-20/date-time-interface-not-implementable-3347525.patch | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   795  100   795    0     0   5124      0 --:--:-- --:--:-- --:--:--  5162
    Checking patch src/TypedData/Plugin/DataType/SmartDate.php...
    error: while searching for:
    namespace Drupal\smart_date\TypedData\Plugin\DataType;
    
    use Drupal\Core\Datetime\DrupalDateTime;
    use Drupal\Core\TypedData\Type\DateTimeInterface;
    use Drupal\Core\TypedData\Plugin\DataType\Timestamp;
    
    /**
    
    error: patch failed: src/TypedData/Plugin/DataType/SmartDate.php:3
    error: src/TypedData/Plugin/DataType/SmartDate.php: patch does not apply
    ➜  smart_date git:(4.1.x)

    I then tried to apply the patch by @a_handan and then the same thing happened.

    Please check and advise. Thank you.

Production build 0.71.5 2024