guzzlehttp.inc.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. declare( strict_types=1 );
  3. use Isolated\Symfony\Component\Finder\Finder;
  4. return array(
  5. /*
  6. * By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working
  7. * directory. You can however define which files should be scoped by defining a collection of Finders in the
  8. * following configuration key.
  9. *
  10. * For more see: https://github.com/humbug/php-scoper#finders-and-paths
  11. */
  12. 'finders' => [
  13. Finder::create()->files()->in( 'vendor/guzzlehttp/guzzle' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
  14. Finder::create()->files()->in( 'vendor/guzzlehttp/promises' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
  15. Finder::create()->files()->in( 'vendor/guzzlehttp/psr7' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
  16. ],
  17. /*
  18. * When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the
  19. * original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited
  20. * support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your
  21. * heart contents.
  22. *
  23. * For more see: https://github.com/humbug/php-scoper#patchers
  24. */
  25. 'patchers' => [
  26. /**
  27. * Replaces the Adapter string references with the prefixed versions.
  28. *
  29. * @param string $filePath The path of the current file.
  30. * @param string $prefix The prefix to be used.
  31. * @param string $content The content of the specific file.
  32. *
  33. * @return string The modified content.
  34. */
  35. function( $file_path, $prefix, $content ) {
  36. // 18 is the length of the GrantFactory.php file path.
  37. if ( substr( $file_path, -18 ) !== 'src/Middleware.php' ) {
  38. return $content;
  39. }
  40. $replaced = str_replace(
  41. sprintf( '%s\\\\cookies must be an instance of GuzzleHttp\\\\Cookie\\\\CookieJarInterface', $prefix ),
  42. sprintf( 'cookies must be an instance of %s\\\\GuzzleHttp\\\\Cookie\\\\CookieJarInterface', $prefix ),
  43. $content
  44. );
  45. return $replaced;
  46. },
  47. ],
  48. );