mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
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:
parent
807da4963b
commit
57ec38d136
@ -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.
|
@ -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>
|
@ -16,6 +16,9 @@
|
||||
|
||||
namespace core;
|
||||
|
||||
use core\attribute\deprecated;
|
||||
use core\attribute\deprecated_with_reference;
|
||||
|
||||
/**
|
||||
* Deprecation utility.
|
||||
*
|
||||
|
@ -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;
|
||||
|
@ -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');
|
||||
|
||||
/**
|
||||
|
@ -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 {
|
||||
|
2
lib/tests/fixtures/deprecated_fixtures.php
vendored
2
lib/tests/fixtures/deprecated_fixtures.php
vendored
@ -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.
|
||||
|
@ -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']);`
|
||||
|
Loading…
x
Reference in New Issue
Block a user