diff --git a/language/predefined/attributes.xml b/language/predefined/attributes.xml
index 3ae9cd9b7afd..3e97de7913c9 100644
--- a/language/predefined/attributes.xml
+++ b/language/predefined/attributes.xml
@@ -11,6 +11,7 @@
&language.predefined.attributes.attribute;
&language.predefined.attributes.allowdynamicproperties;
&language.predefined.attributes.deprecated;
+ &language.predefined.attributes.nodiscard;
&language.predefined.attributes.override;
&language.predefined.attributes.returntypewillchange;
&language.predefined.attributes.sensitiveparameter;
diff --git a/language/predefined/attributes/nodiscard.xml b/language/predefined/attributes/nodiscard.xml
new file mode 100644
index 000000000000..1bd7c5679d46
--- /dev/null
+++ b/language/predefined/attributes/nodiscard.xml
@@ -0,0 +1,160 @@
+
+
+ The NoDiscard attribute
+ NoDiscard
+
+
+
+
+ &reftitle.intro;
+
+ This attribute can be used to indicate that the return value of a function
+ or a method should not be discarded. If the return value is not used in any
+ way, a warning will be emitted.
+
+
+ This is useful for functions where not checking the return value is likely
+ to be a bug.
+
+
+ To intentionally discard the return value of such a function, use (void)
+ cast to suppress the warning.
+
+
+
+
+ &reftitle.classsynopsis;
+
+
+
+ final
+ NoDiscard
+
+
+ &Properties;
+
+ public
+ readonly
+ stringnull
+ message
+
+
+ &Methods;
+
+
+
+
+
+
+
+
+ &reftitle.properties;
+
+
+ message
+
+
+ An optional message explaining why the return value should not be discarded.
+
+
+
+
+
+
+
+ &reftitle.examples;
+
+ Basic usage
+
+ $items
+ * @return array
+ */
+#[\NoDiscard("as processing might fail for individual items")]
+function bulk_process(array $items): array {
+ $results = [];
+
+ foreach ($items as $key => $item) {
+ if (\random_int(0, 9999) < 9999) {
+ // Pretend to do something useful with $item,
+ // which will succeed in 99.99% of cases.
+ echo "Processing {$item}", PHP_EOL;
+ $error = null;
+ } else {
+ $error = new \Exception("Failed to process {$item}.");
+ }
+
+ $results[$key] = $error;
+ }
+
+ return $results;
+}
+
+?>
+]]>
+
+ &example.outputs.85.similar;
+
+
+
+
+
+ Intentionally discarding the return value
+
+
+]]>
+
+
+
+
+
+ &reftitle.seealso;
+
+ Attributes overview
+
+
+
+
+
+ &language.predefined.attributes.nodiscard.construct;
+
+
+
diff --git a/language/predefined/attributes/nodiscard/construct.xml b/language/predefined/attributes/nodiscard/construct.xml
new file mode 100644
index 000000000000..928e7f75ad82
--- /dev/null
+++ b/language/predefined/attributes/nodiscard/construct.xml
@@ -0,0 +1,53 @@
+
+
+
+
+ NoDiscard::__construct
+ Construct a new NoDiscard attribute instance
+
+
+
+ &reftitle.description;
+
+ public NoDiscard::__construct
+ stringnullmessage&null;
+
+
+ Constructs a new NoDiscard instance.
+
+
+
+
+ &reftitle.parameters;
+
+
+ message
+
+
+ The value of the message property.
+
+
+
+
+
+
+
diff --git a/language/predefined/versions.xml b/language/predefined/versions.xml
index e76bf2bc175f..49a18c5680f1 100644
--- a/language/predefined/versions.xml
+++ b/language/predefined/versions.xml
@@ -182,6 +182,8 @@
+
+