Skip to content

Commit 645a83c

Browse files
authored
delete ComposerImporter (hhvm#50)
Also removes: - `autoloadFilesBehavior` config option (this is backwards compatible because invalid keys are ignored -- I also updated tests to check for that) - all filters - leftover test fixtures Also updates README. This should be a new major release (hhvm-autoload 3.0.0)
1 parent 816e33c commit 645a83c

26 files changed

+19
-591
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ A minimal configuration file is:
2121
}
2222
```
2323

24-
This will look for autoloadable definitions in `src/`, and also look in `vendor/`. It will pay attention to the `autoload` sections of `composer.json` inside the `vendor/` directory.
24+
This will look for autoloadable definitions in `src/`, and also look in `vendor/`.
25+
Projects in `vendor/` are only processed if they also contain a `hh_autoload.json` file.
26+
27+
Previously we also supported projects without `hh_autoload.json` by simulating Composer's autoload behavior, but we no longer do because that mostly applied to PHP files which HHVM can no longer parse.
2528

2629
The following settings are optional:
2730

2831
- `"extraFiles": ["file1.hack"]` - files that should not be autoloaded, but should be `require()`ed by `vendor/autoload.hack`. This should be needed much less frequently than under Composer
2932
- `"includeVendor": false` - do not include `vendor/` definitions in `vendor/autoload.hack`
30-
- `"autoloadFilesBehavior": "scan"|"exec"` - whether autoload `files` from vendor should be `scan`ned for definitions, or `exec`uted by `vendor/autoload.hack` - `scan` is the default, and generally favorable, but `exec` is needed if you have dependencies that need code to be executed on startup. `scan` is sufficient if your dependencies just use `files` because they need to define things that aren't classes, which is usually the case.
3133
- `"devRoots": [ "path/", ...]` - additional roots to only include in dev mode, not when installed as a dependency.
3234
- `"relativeAutoloadRoot": false` - do not use a path relative to `__DIR__` for autoloading. Instead, use the path to the folder containing `hh_autoload.json` when building the autoload map.
3335
- `"failureHandler:" classname<Facebook\AutoloadMap\FailureHandler>` - use the specified class to handle definitions that aren't the Map. Your handler will not be invoked for functions or constants
@@ -91,7 +93,7 @@ Information you may need is available from:
9193
How It Works
9294
============
9395

94-
- A parser (FactParse or DefinitionFinder) provides a list of all Hack definitions in the specified locations
96+
- A parser (FactParse) provides a list of all Hack definitions in the specified locations
9597
- This is used to generate something similar to a classmap, except including other kinds of definitions
9698
- The map is provided to HHVM with [`HH\autoload_set_paths()`](https://docs.hhvm.com/hack/reference/function/HH.autoload_set_paths/)
9799

src/AutoloadFilesBehavior.hack

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Config.hack

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace Facebook\AutoloadMap;
1313
type Config = shape(
1414
'roots' => ImmVector<string>,
1515
'devRoots' => ImmVector<string>,
16-
'autoloadFilesBehavior' => AutoloadFilesBehavior,
1716
'includeVendor' => bool,
1817
'extraFiles' => ImmVector<string>,
1918
'parser' => Parser,

src/ConfigurationLoader.hack

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ abstract final class ConfigurationLoader {
6060
'devRoots',
6161
),
6262
),
63-
'autoloadFilesBehavior' => TypeAssert\is_nullable_enum(
64-
AutoloadFilesBehavior::class,
65-
$data['autoloadFilesBehavior'] ?? null,
66-
'autoloadFilesbehavior',
67-
) ??
68-
AutoloadFilesBehavior::FIND_DEFINITIONS,
6963
'relativeAutoloadRoot' => TypeAssert\is_nullable_bool(
7064
$data['relativeAutoloadRoot'] ?? null,
7165
'relativerAutoloadRoot',

src/Merger.hack

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ namespace Facebook\AutoloadMap;
1414
* For example, we may merge:
1515
* - the root autoload map
1616
* - additional autoload maps for each vendored dependency
17-
* - in the case of composer, a psr0, psr4, and classmap
1817
*/
1918
abstract final class Merger {
2019
/** Return a new map containing all the entries from the input maps.

src/builders/ComposerImporter.hack

Lines changed: 0 additions & 181 deletions
This file was deleted.

src/builders/RootImporter.hack

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ namespace Facebook\AutoloadMap;
1313
*
1414
* This will:
1515
* - create an `HHImporter` for the current directory
16-
* - create `ComposerImporter`s or `HHImporter`s for every project under
17-
* `vendor/`
16+
* - create `HHImporter`s for every project under `vendor/` that has
17+
* `hh_autoload.json`
18+
*
19+
* Previously we also supported projects without `hh_autoload.json` by
20+
* simulating Composer's autoload behavior, but we no longer do because that
21+
* mostly applied to PHP files which HHVM can no longer parse.
1822
*/
1923
final class RootImporter implements Builder {
2024
private Vector<Builder> $builders = Vector {};
@@ -38,12 +42,6 @@ final class RootImporter implements Builder {
3842
$dependency,
3943
IncludedRoots::PROD_ONLY,
4044
);
41-
continue;
42-
}
43-
$composer_json = $dependency.'/composer.json';
44-
if (\file_exists($composer_json)) {
45-
$this->builders[] = new ComposerImporter($composer_json, $config);
46-
continue;
4745
}
4846
}
4947
}

src/filters/BasePSRFilter.hack

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/filters/ClassesOnlyFilter.hack

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)