Skip to content

ServiceMapProvider always has a ServiceMap with the new Entropy DI Container #9901

Closed

Description

@simonschaufi

Bug Report

I have a TYPO3 Rector rule where I want to migrate configuration from Services.yaml. This works fine in Unit tests as in unit tests there is a special "hack" to make it work:

if (defined('PHPUNIT_COMPOSER_INSTALL')) {
    $this->serviceMap = null;
}

but when you run the code on a real project, it doesn't work. The following line:

if (SimpleParameterProvider::hasParameter(Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER)) {

never gets called because $this->serviceMap instanceof ServiceMap is always true.

Subject Details
Rector version 2.6.7

I'm pretty sure there is a bug in Entropy Container as Entropy should not create a service if it's nullable.

Minimal PHP Code Causing Issue

# packages/extension/Configuration/Services.yaml
services:
  _defaults:
    autowire: true
    autoconfigure: true
    public: false

  Vendor\Extension\:
    resource: '../Classes/*'

  Vendor\Extension\Command\CleanOrphanedProcessedFilesCommand:
    tags:
      - name: 'console.command'
        command: 'my:clean-orphaned-processed-files'
        schedulable: false
<?php

namespace Vendor\Extension\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class CleanOrphanedProcessedFilesCommand extends Command
{
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        return Command::SUCCESS;
    }
}

Then run \Ssch\TYPO3Rector\TYPO314\v0\AddAsNonSchedulableCommandAttributeRector in TYPO3 Rector,

Expected Behaviour

Actually migrate something

Verification

When I change the constructor to null, then my rule works:

    public function __construct(ServiceMapFactory $serviceMapFactory, ?ServiceMap $serviceMap = null)
    {
        $this->serviceMapFactory = $serviceMapFactory;
        $this->serviceMap = null;
    }

Activity

  1. TomasVotruba commented on Sep 17, 2026

    @TomasVotruba
    Member

    Indeed. What do you suggest?

  2. simonschaufi commented on Sep 17, 2026

    @simonschaufi
    Author

    this is my suggestion: Entropy should not create a service if it's nullable and pass null instead. The other question would be, why is the service even nullable and how was it before Entropy?

  3. TomasVotruba commented on Sep 17, 2026

    @TomasVotruba
    Member

    That would be git blame to answer. I don't think it's needed in ctor, but PR would have to test this. Feel free to kick off one

  4. simonschaufi commented on Sep 17, 2026

    @simonschaufi
    Author

    Well, you implemented this new DI Framework and i just see that it doesn't work exactly like before. I'm wondering why you ask me about a PR because I would expect you as a specialist to suggest a solution as you are giving me the impression that if I find a bug, I need to fix it myself. I have already suggested changes in the past and they were just closed and this is not how I want to be treated.

  5. TomasVotruba commented on Sep 17, 2026

    @TomasVotruba
    Member

    Sure 👍 Closing then.

  6. simonschaufi commented on Oct 19, 2026

    @simonschaufi
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions