public static function nonStatic(string $source, ?string $sourceClass = null, ?string $targetClass = null): string
  {
    // Replace static fields.
    $source = preg_replace('/(public|protected|private)\s+static(\s+)\$/i', '${1}${2}$', $source);

    // Replace usage of static fields.
    $source = preg_replace('/self::\$/', '$this->', $source);

    // Replace static methods.
    $source = preg_replace('/(public|protected|private)\s+static(\s+)(function)/i', '${1}${2}${3}', $source);

    // Replace invocation of static methods.
    $source = preg_replace('/self::/', '$this->', $source);

    // Replace class name.
    if ($sourceClass!==null)
    {
      $source = preg_replace('/(class)(\s+)'.$sourceClass.'/', '${1}${2}'.$targetClass, $source);
    }

    return $source;
  }