Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
delete ComposerImporter (#50)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jjergus authored Feb 7, 2020
1 parent 816e33c commit 645a83c
Show file tree
Hide file tree
Showing 26 changed files with 19 additions and 591 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ A minimal configuration file is:
}
```

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.
This will look for autoloadable definitions in `src/`, and also look in `vendor/`.
Projects in `vendor/` are only processed if they also contain a `hh_autoload.json` file.

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.

The following settings are optional:

- `"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
- `"includeVendor": false` - do not include `vendor/` definitions in `vendor/autoload.hack`
- `"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.
- `"devRoots": [ "path/", ...]` - additional roots to only include in dev mode, not when installed as a dependency.
- `"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.
- `"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
Expand Down Expand Up @@ -91,7 +93,7 @@ Information you may need is available from:
How It Works
============

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

Expand Down
18 changes: 0 additions & 18 deletions src/AutoloadFilesBehavior.hack

This file was deleted.

1 change: 0 additions & 1 deletion src/Config.hack
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace Facebook\AutoloadMap;
type Config = shape(
'roots' => ImmVector<string>,
'devRoots' => ImmVector<string>,
'autoloadFilesBehavior' => AutoloadFilesBehavior,
'includeVendor' => bool,
'extraFiles' => ImmVector<string>,
'parser' => Parser,
Expand Down
6 changes: 0 additions & 6 deletions src/ConfigurationLoader.hack
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ abstract final class ConfigurationLoader {
'devRoots',
),
),
'autoloadFilesBehavior' => TypeAssert\is_nullable_enum(
AutoloadFilesBehavior::class,
$data['autoloadFilesBehavior'] ?? null,
'autoloadFilesbehavior',
) ??
AutoloadFilesBehavior::FIND_DEFINITIONS,
'relativeAutoloadRoot' => TypeAssert\is_nullable_bool(
$data['relativeAutoloadRoot'] ?? null,
'relativerAutoloadRoot',
Expand Down
1 change: 0 additions & 1 deletion src/Merger.hack
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace Facebook\AutoloadMap;
* For example, we may merge:
* - the root autoload map
* - additional autoload maps for each vendored dependency
* - in the case of composer, a psr0, psr4, and classmap
*/
abstract final class Merger {
/** Return a new map containing all the entries from the input maps.
Expand Down
181 changes: 0 additions & 181 deletions src/builders/ComposerImporter.hack

This file was deleted.

14 changes: 6 additions & 8 deletions src/builders/RootImporter.hack
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ namespace Facebook\AutoloadMap;
*
* This will:
* - create an `HHImporter` for the current directory
* - create `ComposerImporter`s or `HHImporter`s for every project under
* `vendor/`
* - create `HHImporter`s for every project under `vendor/` that has
* `hh_autoload.json`
*
* 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.
*/
final class RootImporter implements Builder {
private Vector<Builder> $builders = Vector {};
Expand All @@ -38,12 +42,6 @@ final class RootImporter implements Builder {
$dependency,
IncludedRoots::PROD_ONLY,
);
continue;
}
$composer_json = $dependency.'/composer.json';
if (\file_exists($composer_json)) {
$this->builders[] = new ComposerImporter($composer_json, $config);
continue;
}
}
}
Expand Down
78 changes: 0 additions & 78 deletions src/filters/BasePSRFilter.hack

This file was deleted.

33 changes: 0 additions & 33 deletions src/filters/ClassesOnlyFilter.hack

This file was deleted.

Loading

0 comments on commit 645a83c

Please sign in to comment.