Skip to content

Commit a7dbb05

Browse files
authored
Adding Deprecated attribute to some already deprecated methods (#813)
* Adding Deprecated attribute to some already deprecated methods * Suppress the deprecation in test_post_create_with_thumbnail for >= 12 * CHANGELOG
1 parent 1931b81 commit a7dbb05

File tree

17 files changed

+57
-29
lines changed

17 files changed

+57
-29
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636
cleaning the global scope between tests.
3737

3838

39+
### Changed
40+
41+
- Added `Deprecation` attribute to some already-deprecated methods in the
42+
framework to better indicate their deprecation status.
43+
3944
## v1.12.4
4045

4146
### Fixed

src/mantle/console/concerns/trait-interacts-with-io.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ public function info( $string, $verbosity = null ): void {
291291
*
292292
* @param string $message Message to log.
293293
*/
294+
#[\Deprecated( 'Use `line()` instead.' )]
294295
public function log( string $message ): void {
295296
$this->line( $message );
296297
}

src/mantle/container/class-container.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ public function flush(): void {
11141114
*
11151115
* @deprecated Use `get_instance()` instead.
11161116
*/
1117+
#[\Deprecated( 'Use get_instance() instead.' )]
11171118
public static function getInstance(): static {
11181119
return static::get_instance();
11191120
}

src/mantle/database/factory/class-attachment-factory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public function with_real_thumbnail( callable|string|null $file = null, int $wid
163163
* @param int $legacy_parent The parent post ID.
164164
* @param array $legacy_args The arguments.
165165
*/
166+
#[\Deprecated( 'Use create() or create_and_get() instead.' )]
166167
public function create_object( $args, $legacy_parent = 0, $legacy_args = [] ): int|null {
167168
// Backward compatibility for legacy argument format.
168169
if ( is_string( $args ) ) { // @phpstan-ignore-line
@@ -185,6 +186,7 @@ public function create_object( $args, $legacy_parent = 0, $legacy_args = [] ): i
185186
*
186187
* @return int|\WP_Error The attachment ID on success. The value 0 or WP_Error on failure.
187188
*/
189+
#[\Deprecated( 'Use the `with_image()` method instead.' )]
188190
public function create_upload_object( ?string $file, int $parent = 0 ): int|\WP_Error {
189191
return $this->with_image( $file, $parent )->create();
190192
}

src/mantle/database/factory/class-factory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public function create( array $args = [] ): mixed {
116116
*
117117
* @param array $args The arguments.
118118
*/
119+
#[\Deprecated( 'Use create() or create_and_get() instead.' )]
119120
public function create_object( array $args ): int|null {
120121
return $this->create( $args );
121122
}

src/mantle/database/factory/class-post-factory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ public function definition(): array {
283283
*
284284
* @param array $args The arguments.
285285
*/
286+
#[\Deprecated( 'Use the `with_thumbnail()` method instead.' )]
286287
public function create_with_thumbnail( array $args = [] ): ?int {
287288
return $this->with_thumbnail()->create( $args );
288289
}

src/mantle/framework/helpers.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* Intentionally not Namespaced to allow for root-level access to
66
* framework methods.
77
*
8-
* @deprecated Deprecated in favor of package-specific helpers.
9-
*
108
* @package Mantle
119
*
1210
* @phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound, Squiz.Commenting.FunctionComment

src/mantle/http-client/class-http-client.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Http_Client {
1616
/**
1717
* Create an instance of the Http Client
1818
*/
19+
#[\Deprecated( 'Use ' . \Mantle\Http_Client\Factory::class . '::create() instead.' )]
1920
public static function create(): \Mantle\Http_Client\Factory {
2021
return new Factory();
2122
}

src/mantle/http/autoload.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ function view( ?string $slug = null, array|string|null $name = null, array $vari
105105
* @param array|string $name View name, optional. Supports passing variables in if
106106
* $variables is not used.
107107
*/
108+
#[\Deprecated( 'Use view() instead.' )]
108109
function render_view( ...$args ): void {
109110
echo view( ...$args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
110111
}

src/mantle/http/class-uploaded-file.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function store_as_attachment( string $path = '/', ?string $name = null, $
116116
}
117117

118118
$disk_name = $options['disk'] ?? null;
119-
$disk = Container::getInstance()->make( Filesystem_Manager::class )->drive( $disk_name );
119+
$disk = Container::get_instance()->make( Filesystem_Manager::class )->drive( $disk_name );
120120

121121
// Create the attachment for the file.
122122
$attachment = Attachment::create(

0 commit comments

Comments
 (0)