Skip to content
This repository was archived by the owner on Aug 24, 2022. It is now read-only.
This repository was archived by the owner on Aug 24, 2022. It is now read-only.

Fatal error on DateTimeImmutable::createFromMutable #13

@tjveldhuizen

Description

@tjveldhuizen
root@19da4cbeb2d9:/app/src# php -v
PHP 8.0.8 (cli) (built: Jul  1 2021 22:40:15) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.8, Copyright (c), by Zend Technologies
    with Xdebug v3.1.0beta2, Copyright (c) 2002-2021, by Derick Rethans
<?php
require('../vendor/autoload.php');

$date = new \DateTime();
$immutable = \Safe\DateTimeImmutable::createFromMutable($date);

results in:

Fatal error: Uncaught Error: Call to a member function format() on null in /app/vendor/thecodingmachine/safe8/lib/DateTimeImmutable.php:75
Stack trace:
#0 /app/vendor/thecodingmachine/safe8/lib/DateTimeImmutable.php(38): Safe\DateTimeImmutable->format('Y-m-d H:i:s.u')
#1 /app/vendor/thecodingmachine/safe8/lib/DateTimeImmutable.php(241): Safe\DateTimeImmutable::createFromRegular(Object(Safe\DateTimeImmutable))
#2 /app/src/test.php(5): Safe\DateTimeImmutable::createFromMutable(Object(DateTime))
#3 {main}
  thrown in /app/vendor/thecodingmachine/safe8/lib/DateTimeImmutable.php on line 75

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions