From 1313a0c7feaefb37a7938bb626be290d96825dff Mon Sep 17 00:00:00 2001 From: Nathan Utama Date: Fri, 1 Dec 2023 11:36:45 +0100 Subject: [PATCH] silence php81 deprecations --- lib/event/sfEvent.class.php | 4 ++++ lib/form/sfForm.class.php | 4 ++++ lib/form/sfFormFieldSchema.class.php | 10 ++++++++++ lib/response/sfResponse.class.php | 12 +++++++++++ .../sfNamespacedParameterHolder.class.php | 10 ++++++++++ lib/util/sfParameterHolder.class.php | 10 ++++++++++ lib/validator/sfValidatorError.class.php | 10 ++++++++++ .../sfValidatorErrorSchema.class.php | 20 +++++++++++++++++++ lib/validator/sfValidatorSchema.class.php | 4 ++++ lib/view/sfViewParameterHolder.class.php | 10 ++++++++++ lib/widget/sfWidgetFormSchema.class.php | 4 ++++ lib/yaml/sfYamlInline.class.php | 2 +- 12 files changed, 99 insertions(+), 1 deletion(-) diff --git a/lib/event/sfEvent.class.php b/lib/event/sfEvent.class.php index b59cdaf050..b21520876f 100644 --- a/lib/event/sfEvent.class.php +++ b/lib/event/sfEvent.class.php @@ -117,6 +117,7 @@ public function getParameters() * * @return Boolean true if the parameter exists, false otherwise */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return array_key_exists($name, $this->parameters); @@ -129,6 +130,7 @@ public function offsetExists($name) * * @return mixed The parameter value */ + #[\ReturnTypeWillChange] public function offsetGet($name) { if (!array_key_exists($name, $this->parameters)) @@ -145,6 +147,7 @@ public function offsetGet($name) * @param string $name The parameter name * @param mixed $value The parameter value */ + #[\ReturnTypeWillChange] public function offsetSet($name, $value) { $this->parameters[$name] = $value; @@ -155,6 +158,7 @@ public function offsetSet($name, $value) * * @param string $name The parameter name */ + #[\ReturnTypeWillChange] public function offsetUnset($name) { unset($this->parameters[$name]); diff --git a/lib/form/sfForm.class.php b/lib/form/sfForm.class.php index 47bca58da7..c3b286be38 100644 --- a/lib/form/sfForm.class.php +++ b/lib/form/sfForm.class.php @@ -703,6 +703,7 @@ public function resetFormFields() * * @return Boolean true if the widget exists, false otherwise */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return isset($this->widgetSchema[$name]); @@ -715,6 +716,7 @@ public function offsetExists($name) * * @return sfFormField A form field instance */ + #[\ReturnTypeWillChange] public function offsetGet($name) { if (!isset($this->formFields[$name])) @@ -742,6 +744,7 @@ public function offsetGet($name) * * @throws LogicException */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new LogicException('Cannot update form fields.'); @@ -754,6 +757,7 @@ public function offsetSet($offset, $value) * * @param string $offset The field name */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset( diff --git a/lib/form/sfFormFieldSchema.class.php b/lib/form/sfFormFieldSchema.class.php index 91d094cc11..62c3b7e6ed 100644 --- a/lib/form/sfFormFieldSchema.class.php +++ b/lib/form/sfFormFieldSchema.class.php @@ -46,6 +46,7 @@ public function __construct(sfWidgetFormSchema $widget, sfFormField $parent = nu * * @return Boolean true if the widget exists, false otherwise */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return isset($this->widget[$name]); @@ -58,6 +59,7 @@ public function offsetExists($name) * * @return sfFormField A form field instance */ + #[\ReturnTypeWillChange] public function offsetGet($name) { if (!isset($this->fields[$name])) @@ -97,6 +99,7 @@ public function offsetGet($name) * * @throws LogicException */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new LogicException('Cannot update form fields (read-only).'); @@ -109,6 +112,7 @@ public function offsetSet($offset, $value) * * @throws LogicException */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { throw new LogicException('Cannot remove form fields (read-only).'); @@ -117,6 +121,7 @@ public function offsetUnset($offset) /** * Resets the field names array to the beginning (implements the Iterator interface). */ + #[\ReturnTypeWillChange] public function rewind() { reset($this->fieldNames); @@ -128,6 +133,7 @@ public function rewind() * * @return string The key */ + #[\ReturnTypeWillChange] public function key() { return current($this->fieldNames); @@ -138,6 +144,7 @@ public function key() * * @return mixed The escaped value */ + #[\ReturnTypeWillChange] public function current() { return $this[current($this->fieldNames)]; @@ -146,6 +153,7 @@ public function current() /** * Moves to the next form field (implements the Iterator interface). */ + #[\ReturnTypeWillChange] public function next() { next($this->fieldNames); @@ -157,6 +165,7 @@ public function next() * * @return boolean The validity of the current element; true if it is valid */ + #[\ReturnTypeWillChange] public function valid() { return $this->count > 0; @@ -167,6 +176,7 @@ public function valid() * * @return integer The number of embedded form fields */ + #[\ReturnTypeWillChange] public function count() { return count($this->fieldNames); diff --git a/lib/response/sfResponse.class.php b/lib/response/sfResponse.class.php index c564f88255..af77d6115f 100644 --- a/lib/response/sfResponse.class.php +++ b/lib/response/sfResponse.class.php @@ -149,6 +149,8 @@ public function serialize() return serialize($this->content); } + + /** * Unserializes a sfResponse instance. * @@ -161,4 +163,14 @@ public function unserialize($serialized) { $this->content = unserialize($serialized); } + + public function __serialize() + { + return $this->serialize(); + } + + public function __unserialize($serialized) + { + return $this->unserialize($serialized); + } } diff --git a/lib/util/sfNamespacedParameterHolder.class.php b/lib/util/sfNamespacedParameterHolder.class.php index 476887007b..dcc6b02bf8 100644 --- a/lib/util/sfNamespacedParameterHolder.class.php +++ b/lib/util/sfNamespacedParameterHolder.class.php @@ -396,4 +396,14 @@ public function unserialize($serialized) $this->default_namespace = $data[0]; $this->parameters = $data[1]; } + + public function __serialize() + { + return $this->serialize(); + } + + public function __unserialize($serialized) + { + return $this->unserialize($serialized); + } } diff --git a/lib/util/sfParameterHolder.class.php b/lib/util/sfParameterHolder.class.php index 003166d8ae..f389262b7b 100644 --- a/lib/util/sfParameterHolder.class.php +++ b/lib/util/sfParameterHolder.class.php @@ -210,4 +210,14 @@ public function unserialize($serialized) { $this->parameters = unserialize($serialized); } + + public function __serialize() + { + return $this->serialize(); + } + + public function __unserialize($serialized) + { + return $this->unserialize($serialized); + } } diff --git a/lib/validator/sfValidatorError.class.php b/lib/validator/sfValidatorError.class.php index 24326b2da1..3a2b15812f 100644 --- a/lib/validator/sfValidatorError.class.php +++ b/lib/validator/sfValidatorError.class.php @@ -153,4 +153,14 @@ public function unserialize($serialized) { list($this->validator, $this->arguments, $this->code, $this->message) = unserialize($serialized); } + + public function __serialize() + { + return $this->serialize(); + } + + public function __unserialize($serialized) + { + return $this->unserialize($serialized); + } } diff --git a/lib/validator/sfValidatorErrorSchema.class.php b/lib/validator/sfValidatorErrorSchema.class.php index 424b4622e0..6328fc2961 100644 --- a/lib/validator/sfValidatorErrorSchema.class.php +++ b/lib/validator/sfValidatorErrorSchema.class.php @@ -186,6 +186,7 @@ public function getMessageFormat() * * @return int The number of array */ + #[\ReturnTypeWillChange] public function count() { return count($this->errors); @@ -194,6 +195,7 @@ public function count() /** * Reset the error array to the beginning (implements the Iterator interface). */ + #[\ReturnTypeWillChange] public function rewind() { reset($this->errors); @@ -206,6 +208,7 @@ public function rewind() * * @return string The key */ + #[\ReturnTypeWillChange] public function key() { return key($this->errors); @@ -216,6 +219,7 @@ public function key() * * @return mixed The escaped value */ + #[\ReturnTypeWillChange] public function current() { return current($this->errors); @@ -224,6 +228,7 @@ public function current() /** * Moves to the next error (implements the Iterator interface). */ + #[\ReturnTypeWillChange] public function next() { next($this->errors); @@ -236,6 +241,7 @@ public function next() * * @return boolean The validity of the current element; true if it is valid */ + #[\ReturnTypeWillChange] public function valid() { return $this->count > 0; @@ -248,6 +254,7 @@ public function valid() * * @return bool true if the error exists, false otherwise */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return isset($this->errors[$name]); @@ -260,6 +267,7 @@ public function offsetExists($name) * * @return sfValidatorError A sfValidatorError instance */ + #[\ReturnTypeWillChange] public function offsetGet($name) { return isset($this->errors[$name]) ? $this->errors[$name] : null; @@ -273,6 +281,7 @@ public function offsetGet($name) * * @throws LogicException */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { throw new LogicException('Unable update an error.'); @@ -283,6 +292,7 @@ public function offsetSet($offset, $value) * * @param string $offset (ignored) */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { } @@ -341,4 +351,14 @@ public function unserialize($serialized) { list($this->validator, $this->arguments, $this->code, $this->message, $this->errors, $this->globalErrors, $this->namedErrors) = unserialize($serialized); } + + public function __serialize() + { + return $this->serialize(); + } + + public function __unserialize($serialized) + { + return $this->unserialize($serialized); + } } diff --git a/lib/validator/sfValidatorSchema.class.php b/lib/validator/sfValidatorSchema.class.php index 02e619d8e1..095981b8a8 100644 --- a/lib/validator/sfValidatorSchema.class.php +++ b/lib/validator/sfValidatorSchema.class.php @@ -293,6 +293,7 @@ public function getPostValidator() * * @return bool true if the schema has a field with the given name, false otherwise */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return isset($this->fields[$name]); @@ -305,6 +306,7 @@ public function offsetExists($name) * * @return sfValidatorBase The sfValidatorBase instance associated with the given name, null if it does not exist */ + #[\ReturnTypeWillChange] public function offsetGet($name) { return isset($this->fields[$name]) ? $this->fields[$name] : null; @@ -316,6 +318,7 @@ public function offsetGet($name) * @param string $name The field name * @param sfValidatorBase $validator An sfValidatorBase instance */ + #[\ReturnTypeWillChange] public function offsetSet($name, $validator) { if (!$validator instanceof sfValidatorBase) @@ -331,6 +334,7 @@ public function offsetSet($name, $validator) * * @param string $name */ + #[\ReturnTypeWillChange] public function offsetUnset($name) { unset($this->fields[$name]); diff --git a/lib/view/sfViewParameterHolder.class.php b/lib/view/sfViewParameterHolder.class.php index caaa7796be..88a7db4c05 100644 --- a/lib/view/sfViewParameterHolder.class.php +++ b/lib/view/sfViewParameterHolder.class.php @@ -186,4 +186,14 @@ public function unserialize($serialized) $this->setEscapingMethod($escapingMethod); $this->setEscaping($escaping); } + + public function __serialize() + { + return $this->serialize(); + } + + public function __unserialize($serialized) + { + return $this->unserialize($serialized); + } } diff --git a/lib/widget/sfWidgetFormSchema.class.php b/lib/widget/sfWidgetFormSchema.class.php index c316f247a3..b29aec0781 100644 --- a/lib/widget/sfWidgetFormSchema.class.php +++ b/lib/widget/sfWidgetFormSchema.class.php @@ -502,6 +502,7 @@ public function setParent(sfWidgetFormSchema $parent = null) * * @return bool true if the schema has a field with the given name, false otherwise */ + #[\ReturnTypeWillChange] public function offsetExists($name) { return isset($this->fields[$name]); @@ -514,6 +515,7 @@ public function offsetExists($name) * * @return sfWidget The sfWidget instance associated with the given name, null if it does not exist */ + #[\ReturnTypeWillChange] public function offsetGet($name) { return isset($this->fields[$name]) ? $this->fields[$name] : null; @@ -525,6 +527,7 @@ public function offsetGet($name) * @param string $name The field name * @param sfWidget $widget An sfWidget instance */ + #[\ReturnTypeWillChange] public function offsetSet($name, $widget) { if (!$widget instanceof sfWidget) @@ -551,6 +554,7 @@ public function offsetSet($name, $widget) * * @param string */ + #[\ReturnTypeWillChange] public function offsetUnset($name) { unset($this->fields[$name]); diff --git a/lib/yaml/sfYamlInline.class.php b/lib/yaml/sfYamlInline.class.php index 7fc074f273..0323be3488 100644 --- a/lib/yaml/sfYamlInline.class.php +++ b/lib/yaml/sfYamlInline.class.php @@ -68,7 +68,7 @@ static public function dump($value) return 'true'; case false === $value: return 'false'; - case ctype_digit($value): + case ctype_digit((string) $value): return is_string($value) ? "'$value'" : (int) $value; case is_numeric($value): return is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : (is_string($value) ? "'$value'" : $value);