1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace core;
|
|
|
18 |
|
|
|
19 |
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_ALL)]
|
|
|
20 |
class attribute_helper_attribute_a {
|
|
|
21 |
public function __construct(
|
|
|
22 |
public readonly string $value,
|
|
|
23 |
) {
|
|
|
24 |
}
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
#[\Attribute]
|
|
|
28 |
class attribute_helper_attribute_b {
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Helper for loading attributes.
|
|
|
33 |
*
|
|
|
34 |
* @package core
|
|
|
35 |
* @copyright 2024 Andrew Lyons <andrew@nicols.co.uk>
|
|
|
36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
37 |
*/
|
|
|
38 |
#[attribute_helper_attribute_a('a')]
|
|
|
39 |
#[attribute_helper_attribute_a('b')]
|
|
|
40 |
#[attribute_helper_attribute_b]
|
|
|
41 |
class attribute_helper_example {
|
|
|
42 |
#[attribute_helper_attribute_a('a')]
|
|
|
43 |
#[attribute_helper_attribute_a('b')]
|
|
|
44 |
#[attribute_helper_attribute_b]
|
|
|
45 |
public const WITH_ATTRIBUTES = 'examplevalue';
|
|
|
46 |
|
|
|
47 |
public const WITHOUT_ATTRIBUTE = 'examplevalue';
|
|
|
48 |
|
|
|
49 |
#[attribute_helper_attribute_a('a')]
|
|
|
50 |
#[attribute_helper_attribute_a('b')]
|
|
|
51 |
#[attribute_helper_attribute_b]
|
|
|
52 |
public string $withattributes = 'With attributes';
|
|
|
53 |
|
|
|
54 |
public string $withoutattributes = 'Without attributes';
|
|
|
55 |
|
|
|
56 |
#[attribute_helper_attribute_a('a')]
|
|
|
57 |
#[attribute_helper_attribute_a('b')]
|
|
|
58 |
#[attribute_helper_attribute_b]
|
|
|
59 |
public function with_attributes(): void {
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
public function without_attributes(): void {
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
class attribute_helper_example_without {
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
#[attribute_helper_attribute_a('a')]
|
|
|
70 |
#[attribute_helper_attribute_a('b')]
|
|
|
71 |
#[attribute_helper_attribute_b]
|
|
|
72 |
enum attribute_helper_enum: string {
|
|
|
73 |
#[attribute_helper_attribute_a('a')]
|
|
|
74 |
#[attribute_helper_attribute_a('b')]
|
|
|
75 |
#[attribute_helper_attribute_b]
|
|
|
76 |
case WITH_ATTRIBUTES = 'With attributes';
|
|
|
77 |
|
|
|
78 |
case WITHOUT_ATTRIBUTE = 'Without attributes';
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
#[attribute_helper_attribute_a('a')]
|
|
|
82 |
#[attribute_helper_attribute_a('b')]
|
|
|
83 |
#[attribute_helper_attribute_b]
|
|
|
84 |
function attribute_helper_method_with(): void {
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
function attribute_helper_method_without(): void {
|
|
|
88 |
}
|