hhvm / hhvm-autoload Goto Github PK
View Code? Open in Web Editor NEWAutoload classes, functions, enums, constants, and typedefs on HHVM
License: MIT License
Autoload classes, functions, enums, constants, and typedefs on HHVM
License: MIT License
This is my installation for hhvm-autoload : https://imgur.com/a/5AiRCV3
This is the result from hh_client : https://pastebin.com/CUnYQT8f
i'm i wrong in something ?
Please tag a new release for HHVM 3.x that includes "use relative paths for require_once statement in generated autoload map" 4d66f5a (e.g.: either v1.7.1
or v1.8
)
This makes Packagist report it as unknown license.
- hhvm/hhvm-autoload[v2.0.4, ..., v2.0.13, v3.0.0, ..., v3.1.4] require composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
Warning: The switch statement failed to match any of the cases in /Users/fredemmott/code/xhp-lib/vendor/hhvm/hhvm-autoload/src/HHClientFallbackHandler.hack on line 215
PSR0Filter and PSR4Filter have issues when a psr autoload declaration doesn't end with a /
(e.g. php-resque's)
My fix for this is to add:
$this->root = rtrim($this->root, '/').'/';
to the BasePSRFilter
constructor.
We tend to run composer from outside of our VMs, while run HHVM from inside. This means that the paths don't match so the autoloader can't find any of the files.
Being able to specific the root would solve this.
diff --git a/src/Writer.hack b/src/Writer.hack
index 06244e2..1c2a41a 100644
--- a/src/Writer.hack
+++ b/src/Writer.hack
@@ -178,9 +178,7 @@ final class Writer {
true,
);
- $map = \var_export($map, true)
- |> \str_replace('array (', 'darray[', $$)
- |> \str_replace(')', ']', $$);
+ $map = \serialize($map);
if ($this->relativeAutoloadRoot) {
try {
@@ -212,7 +210,13 @@ function is_dev(): bool {
function map(): \Facebook\AutoloadMap\AutoloadMap {
/* HH_IGNORE_ERROR[4110] invalid return type */
- return $map;
+ /* HH_IGNORE_ERROR[2049] undefined magic intrinsic */
+ /* HH_IGNORE_ERROR[4107] undefined magic intrinsic */
+ return __hhas_adata(
+ <<<'HHAS_ADATA'
+$map
+HHAS_ADATA
+ );
}
} // Generated\
This tag is likely just going to draw in PHP users who are going to end up confused.
Our project stores PHP dependencies in vendor/composer
(since we share vendor/
between JavaScript and PHP). Better handling for custom roots was introduced because of #10, but doubly-nested vendor directories still aren't supported because the root is assumed to be the parent directory of vendor-dir
:
hhvm-autoload/src/ComposerPlugin.php
Lines 37 to 40 in 2808fe0
Should a config key be introduced to fix this, or would re-purposing relativeAutoloadRoot
be sufficient?
Related to #10, I missed extraFiles
. Relative paths have the current root prepended.
This is also an issue if setting autoloadFilesBehavior
to 'exec'
.
I'm getting the following with a simple almost empty file after installing autoload via composer:
File
namespace mine;
function main(): void {
}
Command:
vendor/bin/hh-autoload
Output:
Fatal error: Uncaught exception 'HH\InvariantException' with message 'FactParse typesshould be an array<shape('name' => string)>' in /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/TypeAssert.hack:80
Stack trace:
#0 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/TypeAssert.hack(80): HH\invariant_violation()
#1 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/FactParseScanner.hack(37): Facebook\AutoloadMap\__Private\TypeAssert\is_array_of_shapes_with_name_field()
#2 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/FactParseScanner.hack(116): Facebook\AutoloadMap\FactParseScanner::untypedToShape()
#3 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/HHImporter.hack(83): Facebook\AutoloadMap\FactParseScanner->getAutoloadMap()
#4 (): Closure$Facebook\AutoloadMap\HHImporter::getAutoloadMap()
#5 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/HHImporter.hack(83): HH\Vector->map()
#6 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/RootImporter.hack(53): Facebook\AutoloadMap\HHImporter->getAutoloadMap()
#7 (): Closure$Facebook\AutoloadMap\RootImporter::getAutoloadMap()
#8 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/RootImporter.hack(53): HH\Vector->map()
#9 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/Writer.hack(65): Facebook\AutoloadMap\RootImporter->getAutoloadMap()
#10 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/bin/hh-autoload.hack(141): Facebook\AutoloadMap\Writer->setBuilder()
#11 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/bin/hh-autoload.hack(91): Facebook\AutoloadMap\GenerateScript::generateAutoloader()
#12 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/bin/hh-autoload.hack(184): Facebook\AutoloadMap\GenerateScript::main()
#13 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/bin/hh-autoload(19): Facebook\AutoloadMap\cli_main()
#14 (): Facebook\AutoloadMap\cli_main_UNSAFE()
#15 {main}
Next exception 'Exception' with message 'Failed to parse '/Users/xixixao/hack-hello/./vendor/composer/ClassLoader.php"' in /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/FactParseScanner.hack:58
Stack trace:
#0 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/FactParseScanner.hack(116): Facebook\AutoloadMap\FactParseScanner::untypedToShape()
#1 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/HHImporter.hack(83): Facebook\AutoloadMap\FactParseScanner->getAutoloadMap()
#2 (): Closure$Facebook\AutoloadMap\HHImporter::getAutoloadMap()
#3 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/HHImporter.hack(83): HH\Vector->map()
#4 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/RootImporter.hack(53): Facebook\AutoloadMap\HHImporter->getAutoloadMap()
#5 (): Closure$Facebook\AutoloadMap\RootImporter::getAutoloadMap()
#6 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/builders/RootImporter.hack(53): HH\Vector->map()
#7 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/src/Writer.hack(65): Facebook\AutoloadMap\RootImporter->getAutoloadMap()
#8 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/bin/hh-autoload.hack(141): Facebook\AutoloadMap\Writer->setBuilder()
#9 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/bin/hh-autoload.hack(91): Facebook\AutoloadMap\GenerateScript::generateAutoloader()
#10 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/bin/hh-autoload.hack(184): Facebook\AutoloadMap\GenerateScript::main()
#11 /Users/xixixao/hack-hello/vendor/hhvm/hhvm-autoload/bin/hh-autoload(19): Facebook\AutoloadMap\cli_main()
#12 (): Facebook\AutoloadMap\cli_main_UNSAFE()
#13 {main}
Should have src/ and lib/ in roots if present. Should have test/ or tests/ in devRoots if present. SHould loudly say it created it.
@simonwelsh , @jesseschalken : thoughts?
cli /vendor/bin/hh-autoload.hack,
getting errors
Fatal error: Uncaught exception 'OutOfBoundsException' with message 'Lval on missing array element' in /path/to/project/vendor/hhvm/hhvm-autoload/src/builders/ComposerImporter.hack:152
Stack trace:
#0 /path/to/project/vendor/hhvm/hhvm-autoload/src/builders/ComposerImporter.hack(101): Facebook\AutoloadMap\ComposerImporter::normalizePSRRoots()
#1 /path/to/project/vendor/hhvm/hhvm-autoload/src/builders/ComposerImporter.hack(41): Facebook\AutoloadMap\ComposerImporter->importPSR4()
#2 /path/to/project/vendor/hhvm/hhvm-autoload/src/builders/RootImporter.hack(45): Facebook\AutoloadMap\ComposerImporter->__construct()
#3 /path/to/project/vendor/hhvm/hhvm-autoload/bin/hh-autoload.hack(134): Facebook\AutoloadMap\RootImporter->__construct()
#4 /path/to/project/vendor/hhvm/hhvm-autoload/bin/hh-autoload.hack(91): Facebook\AutoloadMap\GenerateScript::generateAutoloader()
#5 /path/to/project/vendor/hhvm/hhvm-autoload/bin/hh-autoload.hack(184): Facebook\AutoloadMap\GenerateScript::main()
#6 (): Facebook\AutoloadMap\cli_main()
#7 {main}
HHVM version
HipHop VM 4.43.0 (rel)
Compiler: 1580770874_N
Repo schema: da39a3ee5e6b4b0d3255bfef95601890afd80709
OS
MacOS, Ubuntu18.04.2(
container (hhvm/hhvm)
91carriage/hack-requests uses .hh
files and a PSR-4 autoloader. These get filtered out.
Hi
Since 2e8b1ec, vendor/hh_autoload.hh contains a require_once
containing an absolute path which leads to <...>/vendor/hhvm/hhvm-autoload/src/AutoloadMap.php
This is causing errors in certain environment, e.g. using external volumes in docker containers, shipping prepared code to other machines...
@fredemmott mentioned
It probably shouldn’t be an absolute path
If so, I'd be happy to provide a quick PR...
NF FTW
(Native Facts For The Win).
It might be nice to keep this project around for the pseudo-reflection "where's this symbol defined" api. If this is the direction the Meta team wants to pursue, the following steps would have to be taken.
The hack Oss world should update their bin/ scripts to stop looking for the autoloader.
We expect this project to be replaced by a future zero-configuration built-in autoloader; to prepare for that, we should work on making this work with zero configuration to uncover any issues that will need to be addressed by the future built-in one.
This currently has a custom github action that predates hhvm/actions; this means things need fixing twice.
I have setup hhvm-autoload in my project.
I have an index.php file to route web requests to the right controller. index.php does require_once(__DIR__.'/vendor/hh_autoload.php');
I have two controller classes: Foo
and Bar
.
Foo
does not extend any other class and has a single static method bar()
which returns a string.
Bar
extends BaseController
and overrides some methods. BaseController
is defined as abstract.
index.php can call Foo:bar()
with no issue, however when hhvm hits the line with the Bar
class, it throws a Class Undefined error.
I checked and Bar
is properly listed in the generated hh_autoload.php file.
Neither Foo, Bar or BaseController are in a namespace. The project also includes XHP and a few other libs via composer.
Any idea what could be causing this?
If I comment out the extends BaseController
statement from the Bar
definition, it loads the class properly and runs it fine.
HHVM data:
HipHop VM 3.18.3 (rel)
Compiler: tags/HHVM-3.18.3-0-g1ddd4af7b1342c20635afbdc67701fbcbdf97bfa
Repo schema: 61b13efcfd4e2fabea72495f96208746a568a688
I should also add that hh_client returns no errors.
Approaches include:
Callbacks may want to:
hh_client --json --search-TYPE_GOES_HERE
to automatically find itHHVM 3.18 adds https://github.com/facebook/hhvm/tree/master/hphp/runtime/ext/factparse
Would be good to use it instead of definition-finder as it's a rather slow dependency, and factparse should be faster.
There's a couple of packages that have composer autoload a single file, which then goes and loads in a different one with all the function definitions. This stops the default handling of files
autoload values from working for these packages.
Example: guzzlehttp/guzzle (composer.json, referenced file)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.