Page MenuHomePhabricator

Support PHP namespaces
OpenPublic

Asked by tamal on Mar 17 2017, 7:06 AM.

Details

Reposting from T12411 as suggested.

Hi,
We would like to use external PHP libraries that use namespaces with our custom phabricator installation. Here are some of our use-cases:

  • Use Braintree PHP SDK.
  • We have a gRPC.io api. The generated client for gRPC apis use namespaces.

We maintain our internal changes as a set of commits that we periodically rebase to pull in upstream Phabricator's changes. So, we prefer to not use externals, because that makes rebasing difficult. We would like to use it like a Phabricator's library. When we can arc liberate, we get errors like below:

Writing '__phutil_library_init__.php' to '/home/user/Source/phabricator/braintree_php'...
[2017-03-17 04:45:36] EXCEPTION: (XHPASTSyntaxErrorException) vendor/symfony/yaml/Dumper.php: `arc liberate` has limited support for features introduced after PHP 5.2.3.
This library uses an unsupported feature (namespaces) on line 12 of
braintree_php/vendor/symfony/yaml/Dumper.php. at [<phutil>/src/moduleutils/PhutilLibraryMapBuilder.php:488]
phutil(head=2016_W40, ref.master=3b428ff32aad, ref.2016_W40=db4fadb59679)
  #0 PhutilLibraryMapBuilder::analyzeLibrary() called at [<phutil>/src/moduleutils/PhutilLibraryMapBuilder.php:77]
  #1 PhutilLibraryMapBuilder::buildMap() called at [<phutil>/src/moduleutils/PhutilLibraryMapBuilder.php:109]
  #2 PhutilLibraryMapBuilder::buildAndWriteMap() called at [<phutil>/scripts/phutil_rebuild_map.php:75

I think PHP libraries with namespace is probably more common in 2017 than it was in 2015 D14498 . Can this be supported? May be using something like https://github.com/nikic/PHP-Parser make it easier to implement this feature.

Thanks.

New Answer