ampproject / ampproject/amp-toolbox-php

Add dependency resolution and ordering for transformers

Open
#219 5 comments 0 reactions 0 assignees View on GitHub
Optimizer
Dominant language
PHP
Stars
74
Forks
25
Avg merge
1d 15h
Merged PRs (30d)
3

Description

_Based on a discussion in Slack with @06romix:_

What I was thinking of was to have two interfaces with corresponding methods:

```php
interface Requires {
/**
* Return the collection of dependencies that this transformer requires.
*
* @return string[]
*/
public static function requires();
}
```

```php
interface Provides {
/**
* Return the collection of dependencies that this transformer provides.
*
* @return string[]
*/
public static function provides();
}
```

The interfaces can be checked with `instanceof` without even instantiating the classes. The strings that are returned can be thought of as "tags". So, one or more transformers could require `'ssr'`, and the `ServersideRendering` transformer would provide `'ssr'`. If someone replaces that transformer with a custom one, they can still have it provide `'ssr'` to fulfil the dependency chain.
The ordering can then happen based on these tags, provided that it is resolvable. If it is not, there is obviously already a problem that needs to be solved.

Contributor guide

No contributing guide indexed for this repository

Research direction

No files, tests, or entry points are named. Start by locating the transformer pipeline and its current ordering mechanism, then determine how dependency tags would be defined and resolved. Done means the proposed interfaces and ordering behavior are implemented with unresolved dependencies handled, with tests covering the dependency chain.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.