Skip to content

fix: UseArrowFunctionsFixer - don't convert lambda with use($var) clause if it includes another file#9389

Merged
keradus merged 4 commits intomasterfrom
copilot/fix-arrow-function-logic
Jan 28, 2026
Merged

fix: UseArrowFunctionsFixer - don't convert lambda with use($var) clause if it includes another file#9389
keradus merged 4 commits intomasterfrom
copilot/fix-arrow-function-logic

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 28, 2026

The use_arrow_functions rule incorrectly converts closures that capture variables via use() and include external files. Arrow functions don't support use() clauses, so captured variables are no longer exposed to the included file, changing runtime behavior.

// Before (incorrect): converted to arrow function
$load = function ($path) use ($container) {
    return include $path;  // $container accessible in included file
};

// After: preserved as closure
$load = function ($path) use ($container) {
    return include $path;  // $container still accessible in included file
};

Changes

  • Added containsIncludeOrRequire() to detect include/include_once/require/require_once tokens in return statements
  • Skip transformation when closure has both use() clause and include/require statement
  • Added test coverage for all four include/require variants and edge cases

Behavior

Conversion still occurs when:

  • Closure has no use() clause (included file doesn't need access to variables)
  • Closure has use() but no include/require (no file to expose variables to)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/OndraM/ci-detector/zipball/8b0223b5ed235fd377c75fdd1bfcad05c0f168b8
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/PHP-CS-Fixer/cli-executor/zipball/85c95a45a6a23e7d57f70b46de5fa1ffa55c5c66
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/PHP-CS-Fixer/phpunit-constraint-isidenticalstring/zipball/47dafbaec6905eea738ae7067b7cc0473fd792af
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/PHP-CS-Fixer/phpunit-constraint-xmlmatchesxsd/zipball/c72b45d101d7d00bb938347ada14767e7416ed85
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/bovigo/vfsStream/zipball/fe695ec993e0a55c3abdda10a9364eb31c6f1bf0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/colinodell/json5/zipball/5724d21bc5c910c2560af1b8915f0cc0163579c8
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/facile-it/paraunit/zipball/189def486646c47392f4ecf6055c8ffb297ea1ab
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/infection/abstract-testframework-adapter/zipball/18925e20d15d1a5995bb85c9dc09e8751e1e069b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/infection/extension-installer/zipball/9b351d2910b9a23ab4815542e93d541e0ca0cdcf
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/infection/include-interceptor/zipball/0cc76d95a79d9832d74e74492b0a30139904bdf7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/infection/infection/zipball/3654db483619b63b9bcb04c24caeb03677c6d057
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/infection/mutator/zipball/3c976d721b02b32f851ee4e15d553ef1e9186d1d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/jsonrainbow/json-schema/zipball/2eeb75d21cf73211335888e7f5e6fd7440723ec7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/marc-mabe/php-enum/zipball/bb426fcdd65c60fb3638ef741e8782508fda7eef
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/php-coveralls/php-coveralls/zipball/916bdb118597f61ce6715fb738ab8f234b89a2cb
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/reactphp/child-process/zipball/970f0e71945556422ee4570ccbabaedc3cf04ad3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/reactphp/dns/zipball/7562c05391f42701c1fccf189c8225fece1cd7c3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/reactphp/event-loop/zipball/ba276bda6083df7e0050fd9b33f66ad7a4ac747a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/reactphp/promise/zipball/23444f53a813a3296c1368bb104793ce8d88f04a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/reactphp/socket/zipball/ef5b17b81f6f60504c539313f94f2d826c5faa08
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sanmai/DuoClock/zipball/47461e3ff65b7308635047831a55615652e7be1a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sanmai/di-container/zipball/8b9ad72f6ac1f9e185e5bd060dc9479cb5191d8b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sanmai/later/zipball/72a82d783864bca90412d8a26c1878f8981fee97
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sanmai/pipeline/zipball/d7046ecce91ae57fca403be694888371a21250eb
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/15c5dd40dc4f38794d383bb95465193f5e0ae180
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/183a9b2632194febd219bb9246eee421dad8d45e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit/zipball/54391c61e4af8078e5b276ab082b6d3c54c9ad64
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/comparator/zipball/2c95e1e86cb8dd41beb8d502057d1081ccc8eca9
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/complexity/zipball/ee41d384ab1906c68852636b6de493846e13e5a0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/diff/zipball/b4ccd857127db5d41a5b676f24b51371d76d8544
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/environment/zipball/a5c75038693ad2e8d4b6c15ba2403532647830c4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d36ad0d782e5756913e42ad87cb2890f4ffe467a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2c1ed04922802c15e1de5d7447b4856de949cf56
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/118cfaaa8bc5aef3287bf315b6060b1174754af6
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/c1ca3814734c07492b3d4c5f794f4b0995333da2
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/3e0404dc6b300e6bf56415467ebcb3fe4f33e964
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3b415def83fbcb41f991d9ebf16ae4ad8b7837b3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fdfc727f0fcacfeb8fcb30c7e5da173125b58be3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/config/zipball/4275b53b8ab0cf37f48bf273dc2285c8178efdfb
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/console/zipball/41e38717ac1dd7a46b6bda7d6a82af2d98a78894
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/dependency-injection/zipball/76a02cddca45a5254479ad68f9fa274ead0a7ef2
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/event-dispatcher/zipball/dc2c0eba1af673e736bb851d747d266108aea746
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/filesystem/zipball/d551b38811096d0be9c4691d406991b47c0c630a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/finder/zipball/ad4daa7c38668dcb031e63bc99ea9bd42196a2cb
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/options-resolver/zipball/b38026df55197f9e39a44f3215788edf83187b80
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/polyfill-php84/zipball/d8ced4d875142b6a7426000426b8abc631d6b191
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/polyfill-php85/zipball/d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/process/zipball/608476f4604102976d687c483ac63a79ba18cc97
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/stopwatch/zipball/8a24af0a2e8a872fb745047180649b8418303084
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/string/zipball/1c4b10461bf2ec27537b5f36105337262f5f5d6f
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/var-dumper/zipball/0e4769b46a0c3c62390d124635ce59f66874b282
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/var-exporter/zipball/03a60f169c79a28513a78c967316fbc8bf17816f
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/symfony/yaml/zipball/24dd4de28d2e3988b311751ac49e684d783e2345
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/thecodingmachine/safe/zipball/2cdd579eeaa2e78e51c7509b50cc9fb89a956236
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • https://api.github.com/repos/webmozarts/assert/zipball/ce6a2f100c404b2d32a1dd1270f9b59ad4f57649
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/JMmVee /usr/bin/composer install --no-interaction --quiet (http block)
  • salsa.debian.org
    • Triggering command: /usr/bin/wget wget -q REDACTED --output-document=bin/checkbashisms remo�� add /https---github.com-guzzle-guzzle.git/ HP-CS-Fixer/vendor/guzzlehttp/guzzle REDACTED p-enum.git/ /https---github.--delta-base-offset git che/�� 3.0.5 -- /usr/local/.ghcu--all --no-checkout -coveralls.git or/sanmai/di-con-r git (dns block)
    • Triggering command: /usr/bin/wget wget -q REDACTED --output-document=bin/checkbashisms chec�� v1.6.12 che/composer/vcs/https---github.com-php-coveralls-php-coveralls.--reference git e.git com-jsonrainbow-json-schema.git/remote che/composer/vcs/https---github.set-url git remo�� set-url 3cf04ad3 /home/REDACTED/.config/composer/vendor/bin/git REDACTED HP-CS-Fixer/phpu./vendor/bin/phpunit HP-CS-Fixer/vendtests/Fixer/FunctionNotation/UseArrowFunctionsFixerTest.php git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>use_arrow_functions: change logic when callback includes external file</issue_title>
<issue_description>### Problem description

When callback includes file with include/include_once/require/require_once, and callback is explicitly using variables from outside of callback scope via use ($var) syntax, that $var is exposed transparenty to included file.
Converting such callback to arrow function removes this behaviour and effectively changing the outcome of the script.

use_arrow_functions rule (UseArrowFunctionsFixer class) shall not do conversion to arrow function for such cases

Detected in symfony/symfony@4e92c8b

Minimal reproducer CLI command

php-cs-fixer fix

Minimal reproducer code snippet

<?php

$load = \Closure::bind(static function ($path, $env) use ($container, $loader, $resource, $type) {
    return include $path;
}, null, null);

code shall not be modified , but is modified wrongly into:

$load = \Closure::bind(static fn ($path, $env) => include $path, null, null);

Fixer version

3.93

PHP version

8.5

How do you run Fixer?

Composer package

Contribution Checks

  • I have verified if this problem was already reported
  • I am familiar with "Feature or bug?"</issue_description>

<agent_instructions>Read the issue description. Create unit test in UseArrowFunctionsFixerTest.php file based on example from issue and fix the logic in UseArrowFunctionsFixer.php.

Ensure tests are executed properly afterwards, especially composer qa command. Ensure CI is green.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…e/require

Co-authored-by: keradus <2716794+keradus@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix logic in use_arrow_functions for external file callbacks Fix use_arrow_functions: skip conversion when closure exposes variables to included files Jan 28, 2026
Copilot AI requested a review from keradus January 28, 2026 12:13
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 28, 2026

Coverage Status

coverage: 92.942% (+0.001%) from 92.941%
when pulling c124c06 on copilot/fix-arrow-function-logic
into 9a10233 on master.

@keradus keradus changed the title Fix use_arrow_functions: skip conversion when closure exposes variables to included files fix: UseArrowFunctionsFixer - don't convert lambdas with use($var) clause if it includes another file Jan 28, 2026
@keradus keradus marked this pull request as ready for review January 28, 2026 23:19
@keradus keradus changed the title fix: UseArrowFunctionsFixer - don't convert lambdas with use($var) clause if it includes another file fix: UseArrowFunctionsFixer - don't convert lambda with use($var) clause if it includes another file Jan 28, 2026
@keradus keradus merged commit dc6bc0b into master Jan 28, 2026
32 of 33 checks passed
@keradus keradus deleted the copilot/fix-arrow-function-logic branch January 28, 2026 23:49
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.

use_arrow_functions: change logic when callback includes external file

3 participants