Skip to content

Conversation

@csizmazia
Copy link
Contributor

@csizmazia csizmazia commented Sep 30, 2025

Description

The objective of this PR is to add constants which were supposed to be inherited but can't in older versions of symfony/console.

Details

In this package we're registering two composer commands:

kununu
  kununu:cs-fixer           Applies PHP CS Fixer on specified files or directories.
  kununu:cs-fixer-git-hook  Installs PHP CS Fixer as a Git pre-commit hook.

Our classes inherit from Composer\Command\BaseCommand which itself inherits from Symfony\Component\Console\Command\Command. The latter, in newer versions, defines constants for return values (SUCCESS, FAILURE, etc.).

When these commands are run, they are executed by the composer binary (composer.phar).
Example:

#0 phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php(245): Kununu\CsFixer\Command\CsFixerCommand->execute()
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run()
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand()
#3 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(336): Symfony\Component\Console\Application->doRun()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun()
#5 phar:///usr/local/bin/composer/src/Composer/Console/Application.php(131): Symfony\Component\Console\Application->run()
#6 phar:///usr/local/bin/composer/bin/composer(95): Composer\Console\Application->run()
#7 /usr/local/bin/composer(29): require('...')

This means that the relevant version of symfony/console is the one baked into the composer.phar that you're using.

In our services we deliberately use the LTS version 2.2 of composer.

This version builds on a rather old version of symfony/console, see https://github.com/composer/composer/blob/2.2.25/composer.json#L35C30-L35C36.

In that version, the Symfony\Component\Console\Command\Command class did not yet define constants for return values, see https://github.com/symfony/console/blob/v2.8.52/Command/Command.php

However, when developing with an IDE like PHPstorm we were tricked into believing that the constants exist because symfony/console might be installed in a newer version locally or within a service. Plus, executed with composer locally might even have worked if you have a newer composer version installed.

@csizmazia csizmazia requested a review from a team as a code owner September 30, 2025 07:22
@github-actions
Copy link

Qodana for PHP

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@csizmazia csizmazia merged commit 8d3f6b4 into main Sep 30, 2025
4 checks passed
@csizmazia csizmazia deleted the hotfix-unknown-constants branch September 30, 2025 07:43
@tdashton
Copy link
Contributor

Good to know and nice investigation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants