Repository navigation
Symbols are not found for safe 3.0 #617
Description
Activity
As a guess, is
composer-require-checkergrepping through the files listed incomposer.json'sautoload.files[]array, parsing them as strings, looking for function definitions? If it is, that won't work for safe 3.0 because the files listed inautoloadare just stubs, and they import the real files (which differ based on PHP version) at runtime.I wonder if there's a way to tell
composer-require-checker"here is a list of files where our functions live", but without being inautoload(because we explicitly don't want all our files to be autoloaded)?(If it's using some other mechanism then the solution would be completely different, I'm just making guesses about how
composer-require-checkermight work)Also perhaps there's something we could add to
composer.jsonto indicate "this package is responsible for the entireSafe\namespace"?composer-require-checkerhas a scan-file configuration directive, this works, but is clumsy as hell, since you have to add to it every time you use a new safe function from a new extension:{ "scan-files" : [ "vendor/thecodingmachine/safe/generated/8.4/array.php", "vendor/thecodingmachine/safe/generated/8.4/datetime.php", "vendor/thecodingmachine/safe/generated/8.4/filesystem.php", "vendor/thecodingmachine/safe/generated/8.4/info.php", "vendor/thecodingmachine/safe/generated/8.4/json.php", "vendor/thecodingmachine/safe/generated/8.4/outcontrol.php", "vendor/thecodingmachine/safe/generated/8.4/pcre.php", "vendor/thecodingmachine/safe/generated/8.4/stream.php" ] }I don't know if there is something that can be defined on the composer-level...
I wonder if you could actually make tagged releases or branches that discard this version checking and only include the correct code for that version directly in the generated file.
Then anyone with this issue (which would include me when I start using it) can just ensure they have the correct safe tag
Another option is that this library becomes simply a way to generate files directly in your own project. That might also allow for a much leaner codebase with only the required safe functions included - I wonder if this could be handled with rector somehow?
Just a bit of wondering in general really
I wonder if you could actually make tagged releases or branches that discard this version checking and only include the correct code for that version directly in the generated file.
We had this discussion in #500 - tl;dr the current approach is ugly, but every other approach is worse D:
Reacted by ballidevcomposer-require-checkerhas a scan-file configuration directive, this works, but is clumsy as hell, since you have to add to it every time you use a new safe function from a new extension:The documentation suggests that you can use wildcards, so
{ "scan-files" : [ "vendor/thecodingmachine/safe/generated/8.4/*.php", ] }The documentation suggests that you can use wildcards, so
{ "scan-files" : [ "vendor/thecodingmachine/safe/generated/8.4/*.php", ] }Sadly this doesn't work, tried this as I found my solution. When using the wildcard every unused function is printed as unknown. But I really don't know why... Here's an excerpt:
ComposerRequireChecker 4.16.1@2449a6298a0c39d940287d5d3afaf05a6f80fd0c The following 918 unknown symbols were found: +------------------------------------------------------+--------------------+ | Unknown Symbol | Guessed Dependency | +------------------------------------------------------+--------------------+ | AddressInfo | ext-sockets | | apache_getenv | | | apache_get_version | | | apache_lookup_uri | | | apache_request_headers | | | apache_response_headers | | | apache_setenv | | | apcu_cache_info | | | apcu_cas | | | apcu_dec | | | apcu_inc | | | apcu_sma_info | | | bindtextdomain | ext-gettext | ...I ran into this issue too. Dunno why wildcards not working. I ended up manually adding every single file needed by my codebase - which fixed my issue with
composer-require-checker:"scan-files" : [ "vendor/thecodingmachine/safe/generated/8.1/array.php", "vendor/thecodingmachine/safe/generated/8.1/classobj.php", "vendor/thecodingmachine/safe/generated/8.1/datetime.php", "vendor/thecodingmachine/safe/generated/8.1/exec.php", "vendor/thecodingmachine/safe/generated/8.1/filesystem.php", "vendor/thecodingmachine/safe/generated/8.1/ftp.php", "vendor/thecodingmachine/safe/generated/8.1/info.php", "vendor/thecodingmachine/safe/generated/8.1/json.php", "vendor/thecodingmachine/safe/generated/8.1/mbstring.php", "vendor/thecodingmachine/safe/generated/8.1/openssl.php", "vendor/thecodingmachine/safe/generated/8.1/outcontrol.php", "vendor/thecodingmachine/safe/generated/8.1/pcre.php", "vendor/thecodingmachine/safe/generated/8.1/strings.php", "vendor/thecodingmachine/safe/generated/8.1/url.php" ],
maybe its worth opening a issue on
composer-require-checker
When using
composer-require-checkerwith in a project with safe 3.0 I get these unknown symbols:When I switch back to 2.5 no unknown symbols are found. I tried to find the differences, but nothing obvious.
Anyone know how to handle this?