Skip to content

Commit 02a6a76

Browse files
update
1 parent be758d1 commit 02a6a76

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

src/Time.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public function __construct($date = null, $timezone = null)
9090
}
9191

9292
// clone copy of self
93-
if(!self::isTimeInstance()){
94-
self::$staticData = clone $this;
95-
}
93+
// if(!self::isTimeInstance()){
94+
// self::$staticData = $this->copy();
95+
// }
9696
}
9797

9898
/**
@@ -114,13 +114,6 @@ public function __call($name, $args)
114114
return self::nonExistMethod($name, $args, $this);
115115
}
116116

117-
/**
118-
* Handle the calls to non-existent static methods.
119-
* @param string $name
120-
* @param mixed $args
121-
*
122-
* @return mixed
123-
*/
124117
/**
125118
* Magic: static dynamic calls map to supported methods using stored static instance.
126119
*
@@ -130,7 +123,11 @@ public function __call($name, $args)
130123
*/
131124
public static function __callStatic($name, $args)
132125
{
133-
return self::nonExistMethod($name, $args, self::$staticData);
126+
$instance = (self::$staticData instanceof self)
127+
? self::$staticData->copy()
128+
: new self();
129+
130+
return self::nonExistMethod($name, $args, $instance);
134131
}
135132

136133
/**

src/Traits/TimeTrait.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
namespace Tamedevelopers\Support\Traits;
66

7-
use Closure;
87
use DateTime;
98
use Tamedevelopers\Support\Str;
10-
use Tamedevelopers\Support\Time;
119
use Tamedevelopers\Support\Country;
1210
use Tamedevelopers\Support\Capsule\TimeHelper;
1311
use Tamedevelopers\Support\Capsule\CustomException;
@@ -18,19 +16,8 @@
1816
*
1917
* Internal helpers used by the Time class for cloning, timezone handling,
2018
* and common operations. Public API is provided by Time and dynamic dispatch.
21-
* @property mixed $staticData
2219
*/
2320
trait TimeTrait{
24-
25-
/**
26-
* Determine whether the static context already holds a Time instance.
27-
*
28-
* @return bool
29-
*/
30-
static protected function isTimeInstance()
31-
{
32-
return self::$staticData instanceof Time;
33-
}
3421

3522
/**
3623
* Clone a new instance of the owning class.

tests/time.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
$time2 = (new Time)->setTimezone('America/St_Barthelemy');
2323
$time3 = (new Time)->setTimezone('Indian/Antananarivo');
24-
$time4 = TameTime('first day of December 2008', 'Pacific/Pago_Pago');
24+
// $time4 = TameTime('first day of December 2008', 'Pacific/Pago_Pago');
2525

2626
// [
2727
// $time->toJsTimer('24 Jan 2025 14:00:00'),
@@ -37,7 +37,7 @@
3737

3838
dd(
3939
$time2,
40-
$time3,
40+
$time3::greetings('24 Jan 2025 14:00:00'),
4141
);
4242

4343
dd(

0 commit comments

Comments
 (0)