Skip to content

Improve PHP 8.4+ support by avoiding implicitly nullable types #75

@PaulRotmann

Description

@PaulRotmann

As mentioned in #74, I would like to add support for PHP 8.4. I have made the following changes in src/Graph/GraphComposer.php:

/**
 *
 * @param string $dir
 * @param GraphViz|null $graphviz
 */
public function __construct($dir, $graphviz = null)
{
    if ($graphviz === null) {
        $graphviz = new GraphViz();
        $graphviz->setFormat('svg');
    }
    $analyzer = new \JMS\Composer\DependencyAnalyzer();
    $this->dependencyGraph = $analyzer->analyze($dir);
    $this->graphviz = $graphviz;
}

This change works well and addresses the PHP 8.4 deprecation where implicitly nullable parameter declarations are deprecated. However, the bigger issue is the dependency on jms/composer-deps-analyzer.

The jms/composer-deps-analyzer package has not been updated since 2016 and therefore lacks support for PHP 8.4+ and its stricter nullable type requirements. This dependency prevents us from maintaining full compatibility across all PHP versions without potentially significant effort to identify and migrate to alternative dependencies.

There are some different approaches here:

  1. Release a new major version of graph-composer that drops support for older PHP versions and only supports PHP 8.0+. This would allow us to modernize the codebase and dependencies.

  2. Investigate and migrate to a more actively maintained alternative to jms/composer-deps-analyzer, though this would require substantial research and testing.

  3. Fork the jms/composer-deps-analyzer package and maintain our own PHP 8.4+ compatible version.

Not sure which of this options might be the way to go yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions