Version 3 is not compatible with PHP 7.4

Created on 7 June 2023, over 1 year ago
Updated 21 March 2024, 9 months ago

Problem/Motivation

The version 3 of this module is not compatible with PHP 7.4. The drupal modules compatible with Drupal 9 should be also compatible with PHP 7.4.

ParseError: syntax error, unexpected '|', expecting ';' or '{' en Composer\Autoload\ClassLoader::Composer\Autoload\{closure}() (lรญnea 106 de /var/www/html/web/modules/contrib/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterText.php)
#0 /var/www/html/vendor/composer/ClassLoader.php(432): Composer\Autoload\ClassLoader::Composer\Autoload\{closure}('/var/www/html/w...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('Drupal\\color_fi...')
#2 [internal function]: spl_autoload_call('Drupal\\color_fi...')
FILE: /var/www/html/web/modules/contrib/color_field/src/ColorHex.php
------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------
 33 | ERROR | The function str_starts_with() is not present in PHP version 7.4 or earlier
------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/color_field/src/Plugin/Field/FieldWidget/ColorFieldWidgetBase.php
---------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------
 29 | ERROR | The function str_starts_with() is not present in PHP version 7.4 or earlier
---------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterCss.php
--------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------
 67 | ERROR | 'mixed' type declaration is not present in PHP version 7.4 or earlier
--------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterSwatch.php
-----------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
 164 | ERROR | Union types are not present in PHP version 7.4 or earlier. Found: array|MarkupInterface
-----------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/color_field/src/Plugin/Field/FieldType/ColorFieldType.php
-------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------
 141 | ERROR | The function str_starts_with() is not present in PHP version 7.4 or earlier
-------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/color_field/src/Feeds/Target/Color.php
------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------
 72 | ERROR | The function str_starts_with() is not present in PHP version 7.4 or earlier
------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/color_field/color_field.module
-------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------
 211 | ERROR | 'mixed' type declaration is not present in PHP version 7.4 or earlier
-------------------------------------------------------------------------------------

Proposed resolution

  • Fix the cases in which is not compatible.
๐Ÿ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain lpeidro Madrid

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

Comments & Activities

  • Issue created by @lpeidro
  • ๐Ÿ‡ช๐Ÿ‡ธSpain lpeidro Madrid
  • ๐Ÿ‡ช๐Ÿ‡ธSpain lpeidro Madrid
  • ๐Ÿ‡ช๐Ÿ‡ธSpain lpeidro Madrid

    I upload the patch to be applied in projects.

    Patch โ†’

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    9 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    Composer require failure
  • @lpeidro opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain lpeidro Madrid
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia markgp

    TypeError: Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldFormatterText::getColorFormat(): Return value must be of type array, Drupal\Core\StringTranslation\TranslatableMarkup returned in Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldFormatterText->getColorFormat() (line 112 of /var/www/html/web/modules/contrib/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterText.php)

    Still has issues when trying to add the field in the "Manage Display" dialogue.

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    9 pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia roshni27

    please review paatch

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Synflag

    Hi, regarding Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldFormatterText::getColorFormat():
    This is 7.4 compatible:

    /**
     * This function is used to get the color format.
     *
     * @param string|null $format
     *   Format is of string type.
     *
     * @return array|\Drupal\Component\Render\MarkupInterface
     *   Returns array or string.
     */
    protected function getColorFormat(?string $format = NULL) {
        $formats = [];
        $formats['hex'] = $this->t('Hex triplet');
        $formats['rgb'] = $this->t('RGB Decimal');
    
        if ($format !== null) {
            return [$format => $formats[$format]];
        }
    
        return $formats;
    }

    Greetings
    Lars Jendrzejewski, synflag Web Engineering

Production build 0.71.5 2024