Skip to content
This repository was archived by the owner on Apr 25, 2026. It is now read-only.
This repository was archived by the owner on Apr 25, 2026. It is now read-only.

BUG property not being set under certain conditions #27

Closed

Description

@sommmen

Hiya,

I just encountered something weird.

I'm parsing this string which has different objects:

a:11:{i:0;O:31:"KPS\Logistics\Status\To\Delayed":5:{s:12:"delay_reason";s:12:"out_of_stock";s:11:"delay_until";O:8:"DateTime":3:{s:4:"date";s:26:"2021-10-28 00:00:00.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}s:4:"from";s:7:"delayed";s:2:"to";s:7:"delayed";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-10-04 07:57:02.880620";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:1;O:31:"KPS\Logistics\Status\To\Regular":3:{s:4:"from";s:10:"processing";s:2:"to";s:10:"processing";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-10-28 06:59:16.556841";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:2;O:31:"KPS\Logistics\Status\To\Delayed":5:{s:12:"delay_reason";s:12:"out_of_stock";s:11:"delay_until";O:8:"DateTime":3:{s:4:"date";s:26:"2021-11-25 00:00:00.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}s:4:"from";s:7:"delayed";s:2:"to";s:7:"delayed";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-10-28 08:54:25.005632";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:3;O:31:"KPS\Logistics\Status\To\Regular":3:{s:4:"from";s:10:"processing";s:2:"to";s:10:"processing";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-10-28 08:54:25.037250";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:4;O:31:"KPS\Logistics\Status\To\Delayed":5:{s:12:"delay_reason";s:12:"out_of_stock";s:11:"delay_until";O:8:"DateTime":3:{s:4:"date";s:26:"2021-11-25 00:00:00.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}s:4:"from";s:7:"delayed";s:2:"to";s:7:"delayed";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-10-28 11:25:48.219544";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:5;O:31:"KPS\Logistics\Status\To\Regular":3:{s:4:"from";s:10:"processing";s:2:"to";s:10:"processing";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-11-25 07:04:58.147908";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:6;O:31:"KPS\Logistics\Status\To\Delayed":5:{s:12:"delay_reason";s:12:"out_of_stock";s:11:"delay_until";O:8:"DateTime":3:{s:4:"date";s:26:"2021-12-24 00:00:00.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}s:4:"from";s:7:"delayed";s:2:"to";s:7:"delayed";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-11-25 13:50:07.229584";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:7;O:31:"KPS\Logistics\Status\To\Regular":3:{s:4:"from";s:10:"processing";s:2:"to";s:10:"processing";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-11-25 13:50:07.262880";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:8;O:31:"KPS\Logistics\Status\To\Delayed":5:{s:12:"delay_reason";s:12:"out_of_stock";s:11:"delay_until";O:8:"DateTime":3:{s:4:"date";s:26:"2021-12-24 00:00:00.000000";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}s:4:"from";s:7:"delayed";s:2:"to";s:7:"delayed";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-11-25 13:50:16.825377";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:9;O:31:"KPS\Logistics\Status\To\Regular":3:{s:4:"from";s:8:"canceled";s:2:"to";s:8:"canceled";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-11-26 09:06:38.775093";s:13:"timezone_type";i:3;s:8:"timezone";s:16:"Europe/Amsterdam";}}i:10;O:32:"KPS\Logistics\Status\To\Canceled":4:{s:2:"to";s:8:"canceled";s:13:"cancel_reason";s:6:"refund";s:4:"from";s:8:"canceled";s:4:"date";O:8:"DateTime":3:{s:4:"date";s:26:"2021-11-26 08:06:38.796815";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}}}
Details
Array
(
    [0] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Delayed
            [delay_reason] => out_of_stock
            [delay_until] => DateTime Object
                (
                    [date] => 2021-10-28 00:00:00.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )

            [from] => delayed
            [to] => delayed
            [date] => DateTime Object
                (
                    [date] => 2021-10-04 07:57:02.880620
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [1] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Regular
            [from] => processing
            [to] => processing
            [date] => DateTime Object
                (
                    [date] => 2021-10-28 06:59:16.556841
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [2] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Delayed
            [delay_reason] => out_of_stock
            [delay_until] => DateTime Object
                (
                    [date] => 2021-11-25 00:00:00.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )

            [from] => delayed
            [to] => delayed
            [date] => DateTime Object
                (
                    [date] => 2021-10-28 08:54:25.005632
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [3] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Regular
            [from] => processing
            [to] => processing
            [date] => DateTime Object
                (
                    [date] => 2021-10-28 08:54:25.037250
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [4] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Delayed
            [delay_reason] => out_of_stock
            [delay_until] => DateTime Object
                (
                    [date] => 2021-11-25 00:00:00.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )

            [from] => delayed
            [to] => delayed
            [date] => DateTime Object
                (
                    [date] => 2021-10-28 11:25:48.219544
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [5] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Regular
            [from] => processing
            [to] => processing
            [date] => DateTime Object
                (
                    [date] => 2021-11-25 07:04:58.147908
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [6] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Delayed
            [delay_reason] => out_of_stock
            [delay_until] => DateTime Object
                (
                    [date] => 2021-12-24 00:00:00.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )

            [from] => delayed
            [to] => delayed
            [date] => DateTime Object
                (
                    [date] => 2021-11-25 13:50:07.229584
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [7] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Regular
            [from] => processing
            [to] => processing
            [date] => DateTime Object
                (
                    [date] => 2021-11-25 13:50:07.262880
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [8] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Delayed
            [delay_reason] => out_of_stock
            [delay_until] => DateTime Object
                (
                    [date] => 2021-12-24 00:00:00.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )

            [from] => delayed
            [to] => delayed
            [date] => DateTime Object
                (
                    [date] => 2021-11-25 13:50:16.825377
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [9] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Regular
            [from] => canceled
            [to] => canceled
            [date] => DateTime Object
                (
                    [date] => 2021-11-26 09:06:38.775093
                    [timezone_type] => 3
                    [timezone] => Europe/Amsterdam
                )

        )

    [10] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => KPS\Logistics\Status\To\Canceled
            [to] => canceled
            [cancel_reason] => refund
            [from] => canceled
            [date] => DateTime Object
                (
                    [date] => 2021-11-26 08:06:38.796815
                    [timezone_type] => 3
                    [timezone] => UTC
                )

        )

)

This is my model:

public class OrderItemStatusLogWpModel : IPhpObject
{
    private string? _className;

    [PhpProperty("cancel_reason")]
    public string? CancelReason { get; set; }

    [PhpProperty("delay_reason")]
    public string? DelayReason { get; set; }

    [PhpProperty("delay_until")]
    public PhpDateTime? DelayUntil { get; set; }

    [PhpProperty("from")]
    public string? From { get; set; }

    [PhpProperty("to")]
    public string? To { get; set; }

    [PhpProperty("date")]
    public PhpDateTime? Date { get; set; }

    #region IPhpObject

    public string GetClassName() => _className ?? throw new InvalidOperationException($"{nameof(_className)} was not set yet, call {nameof(SetClassName)} first!");

    public void SetClassName(string className) =>
        _className = className;

    #endregion
}

image

Now i remove the CancelReason property, and run the same code:

public class OrderItemStatusLogWpModel : IPhpObject
{
    private string? _className;

    //[PhpProperty("cancel_reason")]
    //public string? CancelReason { get; set; }

    [PhpProperty("delay_reason")]
    public string? DelayReason { get; set; }

    [PhpProperty("delay_until")]
    public PhpDateTime? DelayUntil { get; set; }

    [PhpProperty("from")]
    public string? From { get; set; }

    [PhpProperty("to")]
    public string? To { get; set; }

    [PhpProperty("date")]
    public PhpDateTime? Date { get; set; }

    #region IPhpObject

    public string GetClassName() => _className ?? throw new InvalidOperationException($"{nameof(_className)} was not set yet, call {nameof(SetClassName)} first!");

    public void SetClassName(string className) =>
        _className = className;

    #endregion
}

And now suddenly the Date property is not being set:

image

It seems to only be the last entry that is having difficulties:

image

Running v0.10.0

Activity

  1. changed the title [-]Q property not being set under certain conditions[/-] [+]BUG property not being set under certain conditions[/+] on Dec 23, 2021
  2. sommmen commented on Dec 23, 2021

    @sommmen
    ContributorAuthor

    @StringEpsilon hiya thanks the update.

    Would it be possible to update the package? this is quite breaking for me :(

  3. StringEpsilon commented on Dec 23, 2021

    @StringEpsilon
    Owner

    Done.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions