Function __global->sort_imports_by_dependencies
Definitions
sources/import.php
- Sort a list of imports according to dependencies to help ensure imports are listed in the order they should be run.Note: this is not very performant, but it is assumed the import tool will rarely ever be used by multiple people at the same time.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
- Returns: array
Parameters
| Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
|---|---|---|---|---|---|---|---|
| $imports | array | No | No | required parameter | N/A | N/A | List of imports |
| $dependencies | ?array | No | No | Null | N/A | N/A | Map of imports to their dependencies (null: no dependencies) |
| $silent_fail | boolean | No | No | False | N/A | N/A | Whether to return null if an infinite loop / cyclic dependency occurred opposed to fatally exiting |
Returns
- The newly-sorted imports (null: Error occurred and $silent_fail was true)
- Type: ?array
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Sort a list of imports according to dependencies to help ensure imports are listed in the order they should be run.Note: this is not very performant, but it is assumed the import tool will rarely ever be used by multiple people at the same time.
*
* @param array $imports List of imports
* @param ?array $dependencies Map of imports to their dependencies (null: no dependencies)
* @param boolean $silent_fail Whether to return null if an infinite loop / cyclic dependency occurred opposed to fatally exiting
* @return ?array The newly-sorted imports (null: Error occurred and $silent_fail was true)
*/
function sort_imports_by_dependencies(array $imports, ?array $dependencies = null, bool $silent_fail = false) : ?array
* Sort a list of imports according to dependencies to help ensure imports are listed in the order they should be run.Note: this is not very performant, but it is assumed the import tool will rarely ever be used by multiple people at the same time.
*
* @param array $imports List of imports
* @param ?array $dependencies Map of imports to their dependencies (null: no dependencies)
* @param boolean $silent_fail Whether to return null if an infinite loop / cyclic dependency occurred opposed to fatally exiting
* @return ?array The newly-sorted imports (null: Error occurred and $silent_fail was true)
*/
function sort_imports_by_dependencies(array $imports, ?array $dependencies = null, bool $silent_fail = false) : ?array
