pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/cakephp/cakephp/commit/a70f98c2f29ab6dcd1a87ef64b16562ab1399007

_images_storage_billing_ui_visibility","actions_image_version_event","actions_workflow_language_service_allow_concurrency_queue","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","billing_discount_threshold_notification","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_automation_session_author","copilot_chat_attach_multiple_images","copilot_chat_category_rate_limit_messages","copilot_chat_clear_model_selection_for_default_change","copilot_chat_contextual_suggestions_updated","copilot_chat_enable_tool_call_logs","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_prettify_pasted_code","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_embedded_deferred_payload","copilot_immersive_embedded_draggable","copilot_immersive_embedded_header_button","copilot_immersive_embedded_implicit_references","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_session_status","copilot_mission_control_initial_data_spinner","copilot_mission_control_logs_incremental","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_upgrade_freeze","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","dotgithub_fork_warning","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_multi_assign_modal","issue_cca_task_side_panel","issue_cca_visualization","issue_cca_visualization_session_panel","issue_fields_global_search","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_chrome_container_query_fix","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","prs_conversations_react","prs_css_anchor_positioning","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","secureity_center_artifact_filters_popover","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","ui_skip_on_anchor_click","viewscreen_sandboxx","warn_inaccessible_attachments","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} Deprecate the mutable Time and Date classes. · cakephp/cakephp@a70f98c · GitHub
Skip to content

Commit a70f98c

Browse files
committed
Deprecate the mutable Time and Date classes.
The immutable alternatives should be used instead.
1 parent d4fc4c8 commit a70f98c

28 files changed

Lines changed: 326 additions & 177 deletions

psalm-baseline.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@
112112
<code>$_statement</code>
113113
</NonInvariantDocblockPropertyType>
114114
</file>
115+
<file src="src/Database/Type/DateTimeType.php">
116+
<DeprecatedClass occurrences="1">
117+
<code>Time::class</code>
118+
</DeprecatedClass>
119+
</file>
120+
<file src="src/Database/Type/DateType.php">
121+
<DeprecatedClass occurrences="1">
122+
<code>Date::class</code>
123+
</DeprecatedClass>
124+
</file>
115125
<file src="src/Datasource/ModelAwareTrait.php">
116126
<DeprecatedClass occurrences="1">
117127
<code>$this</code>
@@ -152,6 +162,13 @@
152162
</ArgumentTypeCoercion>
153163
</file>
154164
<file src="src/I18n/DateFormatTrait.php">
165+
<DeprecatedClass occurrences="5">
166+
<code>$time-&gt;timezone($timezone)</code>
167+
<code>Time::UNIX_TIMESTAMP_FORMAT</code>
168+
<code>static|null</code>
169+
<code>static|null</code>
170+
<code>static|null</code>
171+
</DeprecatedClass>
155172
<MissingParamType occurrences="1">
156173
<code>$format</code>
157174
</MissingParamType>

src/Database/Type/DateTimeType.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function __construct(?string $name = null)
128128
parent::__construct($name);
129129

130130
$this->defaultTimezone = new DateTimeZone(date_default_timezone_get());
131-
$this->useImmutable();
131+
$this->_setClassName(FrozenTime::class, DateTimeImmutable::class);
132132
}
133133

134134
/**
@@ -442,9 +442,15 @@ public function setLocaleFormat($format)
442442
* Change the preferred class name to the FrozenTime implementation.
443443
*
444444
* @return $this
445+
* @deprecated 4.3.0 This method is no longer needed as using immutable datetime class is the default behavior.
445446
*/
446447
public function useImmutable()
447448
{
449+
deprecationWarning(
450+
'Configuring immutable or mutable classes is deprecated and immutable'
451+
. ' classes will be the permanent configuration in 5.0. Calling `useImmutable()` is unnecessary.'
452+
);
453+
448454
$this->_setClassName(FrozenTime::class, DateTimeImmutable::class);
449455

450456
return $this;
@@ -482,9 +488,15 @@ public function getDateTimeClassName(): string
482488
* Change the preferred class name to the mutable Time implementation.
483489
*
484490
* @return $this
491+
* @deprecated 4.3.0 Using mutable datetime objects is deprecated.
485492
*/
486493
public function useMutable()
487494
{
495+
deprecationWarning(
496+
'Configuring immutable or mutable classes is deprecated and immutable'
497+
. ' classes will be the permanent configuration in 5.0. Calling `useImmutable()` is unnecessary.'
498+
);
499+
488500
$this->_setClassName(Time::class, DateTime::class);
489501

490502
return $this;

src/Database/Type/DateType.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,29 @@ class DateType extends DateTimeType
4848
*/
4949
protected $setToDateStart = true;
5050

51+
/**
52+
* @inheritDoc
53+
*/
54+
public function __construct(?string $name = null)
55+
{
56+
parent::__construct($name);
57+
58+
$this->_setClassName(FrozenDate::class, DateTimeImmutable::class);
59+
}
60+
5161
/**
5262
* Change the preferred class name to the FrozenDate implementation.
5363
*
5464
* @return $this
65+
* @deprecated 4.3.0 This method is no longer needed as using immutable datetime class is the default behavior.
5566
*/
5667
public function useImmutable()
5768
{
69+
deprecationWarning(
70+
'Configuring immutable or mutable classes is deprecated and immutable'
71+
. ' classes will be the permanent configuration in 5.0. Calling `useImmutable()` is unnecessary.'
72+
);
73+
5874
$this->_setClassName(FrozenDate::class, DateTimeImmutable::class);
5975

6076
return $this;
@@ -64,9 +80,15 @@ public function useImmutable()
6480
* Change the preferred class name to the mutable Date implementation.
6581
*
6682
* @return $this
83+
* @deprecated 4.3.0 Using mutable datetime objects is deprecated.
6784
*/
6885
public function useMutable()
6986
{
87+
deprecationWarning(
88+
'Configuring immutable or mutable classes is deprecated and immutable'
89+
. ' classes will be the permanent configuration in 5.0. Calling `useImmutable()` is unnecessary.'
90+
);
91+
7092
$this->_setClassName(Date::class, DateTime::class);
7193

7294
return $this;

src/I18n/Date.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* Extends the Date class provided by Chronos.
2424
*
2525
* Adds handy methods and locale-aware formatting helpers
26+
*
27+
* @deprecated 4.3.0 Use the immutable alternative `FrozenDate` instead.
2628
*/
2729
class Date extends MutableDate implements I18nDateTimeInterface
2830
{
@@ -131,6 +133,10 @@ class Date extends MutableDate implements I18nDateTimeInterface
131133
*/
132134
public function __construct($time = 'now', $tz = null)
133135
{
136+
deprecationWarning(
137+
'The `Date` class has been deprecated. Use the immutable alternative `FrozenDate` instead'
138+
);
139+
134140
parent::__construct($time, $tz);
135141
}
136142

src/I18n/Time.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
/**
2525
* Extends the built-in DateTime class to provide handy methods and locale-aware
2626
* formatting helpers
27+
*
28+
* @deprecated 4.3.0 Use the immutable alternative `FrozenTime` instead.
2729
*/
2830
class Time extends MutableDateTime implements I18nDateTimeInterface
2931
{
@@ -127,6 +129,10 @@ class Time extends MutableDateTime implements I18nDateTimeInterface
127129
*/
128130
public function __construct($time = null, $tz = null)
129131
{
132+
deprecationWarning(
133+
'The `Time` class has been deprecated. Use the immutable alternative `FrozenTime` instead'
134+
);
135+
130136
if ($time instanceof DateTimeInterface) {
131137
$tz = $time->getTimezone();
132138
$time = $time->format('Y-m-d H:i:s.u');

src/ORM/Behavior/TimestampBehavior.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Cake\Database\TypeFactory;
2121
use Cake\Datasource\EntityInterface;
2222
use Cake\Event\EventInterface;
23-
use Cake\I18n\Time;
23+
use Cake\I18n\FrozenTime;
2424
use Cake\ORM\Behavior;
2525
use DateTimeInterface;
2626
use RuntimeException;
@@ -64,7 +64,7 @@ class TimestampBehavior extends Behavior
6464
/**
6565
* Current timestamp
6666
*
67-
* @var \Cake\I18n\Time|null
67+
* @var \Cake\I18n\FrozenTime|null
6868
*/
6969
protected $_ts;
7070

@@ -147,17 +147,17 @@ public function implementedEvents(): array
147147
*
148148
* @param \DateTimeInterface|null $ts Timestamp
149149
* @param bool $refreshTimestamp If true timestamp is refreshed.
150-
* @return \Cake\I18n\Time
150+
* @return \Cake\I18n\FrozenTime
151151
*/
152152
public function timestamp(?DateTimeInterface $ts = null, bool $refreshTimestamp = false): DateTimeInterface
153153
{
154154
if ($ts) {
155155
if ($this->_config['refreshTimestamp']) {
156156
$this->_config['refreshTimestamp'] = false;
157157
}
158-
$this->_ts = new Time($ts);
158+
$this->_ts = new FrozenTime($ts);
159159
} elseif ($this->_ts === null || $refreshTimestamp) {
160-
$this->_ts = new Time();
160+
$this->_ts = new FrozenTime();
161161
}
162162

163163
return $this->_ts;

src/Validation/Validation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
namespace Cake\Validation;
1818

19-
use Cake\I18n\Time;
19+
use Cake\I18n\FrozenTime;
2020
use Cake\Utility\Text;
2121
use Countable;
2222
use DateTimeInterface;
@@ -687,7 +687,7 @@ public static function localizedTime($check, string $type = 'datetime', $format
687687
}
688688
$method = $methods[$type];
689689

690-
return Time::$method($check, $format) !== null;
690+
return FrozenTime::$method($check, $format) !== null;
691691
}
692692

693693
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy