MDL-80677 core: Move deprecated attributes to \core\attribute NS

Note: Removing the manual require for the attribute from moodlelib
because the class does not have to exist at time of definition, only
when the Reflection API instantiates an instance in \core\deprecation,
by which point the autoloader is available.
This commit is contained in:
Andrew Nicols 2024-02-27 11:36:10 +08:00
parent 807da4963b
commit 57ec38d136
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
8 changed files with 16 additions and 12 deletions

View File

@ -14,9 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core;
use Attribute;
namespace core\attribute;
/**
* Attribute to describe a deprecated item.
@ -25,7 +23,7 @@ use Attribute;
* @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[Attribute]
#[\Attribute]
class deprecated {
/**
* A deprecated item.

View File

@ -14,10 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core;
namespace core\attribute;
/**
* Attribute to describe a deprecated item.
* Attribute to describe a deprecated item which contains a reference to the owning feature.
*
* @package core
* @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>

View File

@ -16,6 +16,9 @@
namespace core;
use core\attribute\deprecated;
use core\attribute\deprecated_with_reference;
/**
* Deprecation utility.
*

View File

@ -18,6 +18,7 @@ namespace core;
use coding_exception;
use core_text;
use core\attribute\deprecated;
use core\ip_utils;
use invalid_parameter_exception;
use moodle_exception;

View File

@ -74,7 +74,6 @@ define('HOURMINS', 60);
// We currently include \core\param manually here to avoid broken upgrades.
// This may change after the next LTS release as LTS releases require the previous LTS release.
require_once(__DIR__ . '/classes/deprecation.php');
require_once(__DIR__ . '/classes/deprecated.php');
require_once(__DIR__ . '/classes/param.php');
/**

View File

@ -16,15 +16,18 @@
namespace core;
use core\attribute\deprecated;
use core\attribute\deprecated_with_reference;
/**
* Tests for \core\deprecated and \core\deprecation.
* Tests for \core\attribute\sdeprecated and \core\deprecation.
*
* @package core
* @category test
* @copyright 2024 Andrew Lyons <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \core\deprecated
* @covers \core\deprecated_with_reference
* @covers \core\attribute\deprecated
* @covers \core\attribute\deprecated_with_reference
* @covers \core\deprecation
*/
class deprecation_test extends \advanced_testcase {

View File

@ -16,7 +16,7 @@
namespace core\fixtures;
use core\deprecated;
use core\attribute\deprecated;
/**
* A file containing a variety of fixturs for deprecated attribute tests.

View File

@ -39,7 +39,7 @@ information provided here is intended especially for developers.
* The following callbacks have been migrated to hooks:
- before_standard_html_head() -> core\hook\output\standard_head_html_prepend
* Deprecated PARAM_ types with the exception of PARAM_CLEAN now emit a deprecation exception. These were all deprecated in Moodle 2.0.
* A new \core\deprecated attribute can be used to more clearly describe deprecated methods.
* A new \core\attribute\deprecated attribute can be used to more clearly describe deprecated methods.
* A new \core\deprecation class can be used to inspect for deprecated attributes:
- `\core\deprecation::is_deprecated(example::class);`
- `\core\deprecation::emit_deprecation_if_present([self::class, 'some_method']);`