ComposerRequireChecker icon indicating copy to clipboard operation
ComposerRequireChecker copied to clipboard

Missing PHP version should give readable error

Open kelunik opened this issue 4 years ago • 1 comments

I missed adding the "php" version requirement in composer.json and all internal functions have been reported as unknown, even though I had configured them in the config:

{
    "php-core-extensions": [
        "Core",
        "date",
        "pcre",
        "Phar",
        "Reflection",
        "SPL",
        "standard",
        "hash"
    ]
}
The following 14 unknown symbols were found:
+----------------+--------------------+
| Unknown Symbol | Guessed Dependency |
+----------------+--------------------+
| array_filter   | php                |
|                | ext-standard       |
| array_map      | php                |
|                | ext-standard       |
| array_pop      | php                |
|                | ext-standard       |
| count          | php                |
|                | ext-standard       |
| Error          | php                |
|                | ext-Core           |
| Exception      | php                |
|                | ext-Core           |
| explode        | php                |
|                | ext-standard       |
| implode        | php                |
|                | ext-standard       |
| ltrim          | php                |
|                | ext-standard       |
| PHP_OS_FAMILY  | php                |
|                | ext-Core           |
| preg_split     | php                |
|                | ext-pcre           |
| strtr          | php                |
|                | ext-standard       |
| str_replace    | php                |
|                | ext-standard       |
| var_export     | php                |
|                | ext-standard       |
+----------------+--------------------+

While it's kind of obvious that php needs to be added as a requirement, this leaved me puzzled for some minutes. I guess an extra error message would be helpful?

kelunik avatar Dec 14 '21 17:12 kelunik

IMO this is expected (not confusing).

What would an enhancement look like? Consider that we don't suggest specific composer.json additions either 🤔

Ocramius avatar Dec 14 '21 18:12 Ocramius

It's probably connected, but correct me if I am wrong.

I am curious. From what I see ext-Core or ext-standard are not things that could be required in composer.json. I have php set properly.

	"require": {
		"php": "^8.2"
        }

Yet, library reports standard symbols as unknown:

The following 2 unknown symbols were found:
+----------------+--------------------+
| Unknown Symbol | Guessed Dependency |
+----------------+--------------------+
| sleep          | ext-standard       |
| Throwable      | ext-Core           |
+----------------+--------------------+

What am I missing?

fliespl avatar Mar 17 '23 08:03 fliespl

I just realized that I used custom config file that doesn't add items, but replaces default ones:

  "php-core-extensions" : [
  ],

Adjusted to:

  "php-core-extensions" : [
      "Core",
      "date",
      "json",
      "pcre",
      "Phar",
      "Reflection",
      "SPL",
      "random",
      "standard"
  ],

And now all is fine. Sorry about confusion.

fliespl avatar Mar 17 '23 09:03 fliespl

Closing here - seems very much discussed :-)

Proposals for improvements should come as a PR, if you are reading this, and you have a suggestion on current behavior :+1:

Ocramius avatar Mar 17 '23 09:03 Ocramius