Configurable

TypedPropertyFromToOneRelationTypeRector

Complete @var annotations or types based on @ORM\*toOne annotations or attributes

 use Doctrine\ORM\Mapping as ORM;

 class SimpleColumn
 {
     /**
      * @ORM\OneToOne(targetEntity="App\Company\Entity\Company")
      * @ORM\JoinColumn(nullable=false)
      */
-    private $company;
+    private ?\App\Company\Entity\Company $company = null;
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Property\TypedPropertyFromToOneRelationTypeRector;

return RectorConfig::configure()
    ->withConfiguredRule(TypedPropertyFromToOneRelationTypeRector::class, [
        'force_nullable' => true,
    ]);

 use Doctrine\ORM\Mapping as ORM;

 class SimpleColumn
 {
     /**
      * @ORM\OneToOne(targetEntity="App\Company\Entity\Company")
      * @ORM\JoinColumn(nullable=false)
      */
-    private $company;
+    private \App\Company\Entity\Company $company;
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Property\TypedPropertyFromToOneRelationTypeRector;

return RectorConfig::configure()
    ->withConfiguredRule(TypedPropertyFromToOneRelationTypeRector::class, [
        'force_nullable' => false,
    ]);
SETS:  Code Quality