Problem/Motivation

On PHP 8.4 getting this on the /admin/reports/status page.

Deprecated: CssLint\Linter::__construct(): Implicitly marking parameter $oProperties as nullable is deprecated, the explicit nullable type must be used instead in /app/vendor/neilime/php-css-lint/src/CssLint/Linter.php on line 71

The neilime/php-css-lint:3.2.0 dependency version is not really compatible with the latest PHP, so upgrade it.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

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

kaszarobert created an issue. See original summary.

dhruv.mittal’s picture

Assigned: Unassigned » dhruv.mittal
dhruv.mittal’s picture

Assigned: dhruv.mittal » Unassigned

I think if this is the issue of library then it should be fix in the library it self not the module.

kaszarobert’s picture

And yes, it is fixed in the library, but since the module's composer.json requires versions "^2.0|^3.0", the latest php-css-lint 7.0.0 cannot be installed.

chris burge’s picture

The issue is with the third-party library.

Symfony dependencies were added to neilime/php-css-lint beginning in v5.0.0 as dev dependencies, and there are compatibility issues with Drupal core as a result. For example, v5.0.0 requires ^6.4 of several Symfony libraries. This makes it compatible with Drupal 10 but not Drupal 11, which require Symfony 7. This is also true of v7.0.0.

I think the next step here is to file an issue with neilime/php-css-lint requesting support for Symfony 7 in its dev dependencies.

This is also an issue for Laravel (https://packagist.org/packages/laravel/framework#v12.46.0).

chris burge’s picture

Status: Active » Postponed

Issue filed: https://github.com/neilime/php-css-lint/issues/183.

Moving to postponed, pending upstream fix.

chris burge’s picture

Status: Postponed » Active

neilime/php-css-lint released 7.1.0 with support for Symfony 7.2.

In v2 and v3, CssLint\Linter::lintString() returns true for a valid CSS string and false otherwise. In v7, it returns a Generator object with any errors.

v7 is also failing to catch invalid CSS in some of my quick testing:

color: blue font-weight:bold

v2 fails validation but v7 passes validation.

Before investing additional time into this, we probably need to decide if CSS validation for the style element is actually providing value.

kaszarobert’s picture

Perhaps for class validity checks Drupal's built-in \Drupal\Component\Utility\Html::getClass() or \Drupal\Component\Utility\Html::cleanCssIdentifier() functions would be enough. What do you think?

kaszarobert’s picture

Oh, I was wrong. It seems Html::cleanCssIdentifier($value) is already used for checking CSS classes. The php-css-lint library is used for inline CSS style checking.

tobiasb’s picture

For people who need now a patch for neilime/php-css-lint.

tobiasb’s picture

Title: Deprecated: CssLint\Linter::__construct(): Implicitly marking parameter $oProperties as nullable is deprecated, the explicit nullable type must be used instead in /app/vendor/neilime/php-css-lint/src/CssLint/Linter.php on line 71 » PHP 8.4 compatibility of dependency neilime/php-css-lint
Issue tags: +PHP 8.4
clemorphy’s picture

I think this issue should be prioritized because it kinda breaks the contribution workflow with the ajax response marked as failed, even if it saves the data.
PHP 8.4 is 1.5 years old now, so it's quite common.

pfructuoso made their first commit to this issue’s fork.

pfructuoso’s picture

Status: Active » Needs review
StatusFileSize
new2.41 KB

This patch fixes the PHP 8.4 compatibility issue within the module itself, without requiring patches on the upstream library.

Approach: Instead of patching neilime/php-css-lint v3.2.0 (as proposed in #11), this updates the module's composer constraint to ^2.0|^3.0|^7.0 and adapts the code to handle both APIs:

  • v2/v3: lintString() returns bool
  • v7+: lintString() returns Generator<LintError> (empty generator = valid CSS)

Composer will automatically resolve the correct version based on the PHP environment:

  • PHP 8.1: installs v3.x (unchanged behavior)
  • PHP ≥8.2 (including 8.4): installs v7.x, which has no PHP 8.4 deprecations

Note: Symfony is only a dev dependency of neilime/php-css-lint v7.x, so there are no conflicts with either Drupal 10 (Symfony 6) or Drupal 11 (Symfony 7).

ludwig.json has also been updated from v3.1.3 to v7.2.0 for sites not using Composer.

Additionally, the implicit nullable parameter $section_storage = NULL in buildForm() has been corrected to ?SectionStorageInterface $section_storage = NULL, fixing a pre-existing PHP 8.4 deprecation in the same file.

  • chris burge committed 2b41080b on 2.x
    Resolve #3566065 "Remove neilime/php css lint dependency"
    
chris burge’s picture

Title: PHP 8.4 compatibility of dependency neilime/php-css-lint » Remove neilime/php-css-lint dependency
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

clemorphy’s picture

Perfect, thanks guys !

Status: Fixed » Closed (fixed)

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