My webhost stopped supporting PHP 8.0 and so I had to do acrobatics to upgrade Mysidia to 8.4
This guide is not comprehensive because I don't remember all the stuff I needed to do and I'm bad at documentation. I can leave some tips though. This will be ongoing, and I will help if you attenpt this and have errors.
Tip 1.
Use this piece of code reight above a function method to reduce some of the errors with incorrect return types:
#[\ReturnTypeWillChange]
public function foo(): mixed
Note: this might be depreciated at some point, and it will not fix all errors, so you will have to learn the next tip.
Tip 2.
Where errors are generated with functions asking for specific return types, you will need to do something like this. I'm going to use the example in core\native\mysstring
around line 495ish there is this function which gave me a huge headache and was nearly impossible to track the location of, but I'm giving it to you so you don't have the problems I did.
/**
* Return the key of the current element.
* @return int
*/
public function key()
{
return $this->_index;
}
Here is my fixed code
Notice that I put : int after the parenthesis in the function name. This is now the standard way to do functions and methods in modern PHP. I knew to put int because in the comment it says * @return int so this is the type that function is supposed to return. This will force templates to hash with integers instead of float numbers.
When you go through all the errors and find their locations, look at the comment on that bit of code to find out the return type, and then after the parenthesis use a colon and the return type. Here is a list of return types below:
: int
: string
: void
: mixed
: bool
: array
: float
: callable
: interfaces
If the * @return is trying to return a function, I don't think you need to add anything.
You won't be required to go through every single function in the entire code to get it to work, but you will need to test everything to see where it's needed. Most of the code I encountered was in resources, and some of the models, but I'm still testing things myself so I'm sure I will hit other spots. Eventually you should do this to all the functions for forward compatability, but for now only focus on the errors and warnings.
This guide is not comprehensive because I don't remember all the stuff I needed to do and I'm bad at documentation. I can leave some tips though. This will be ongoing, and I will help if you attenpt this and have errors.
Tip 1.
Use this piece of code reight above a function method to reduce some of the errors with incorrect return types:
#[\ReturnTypeWillChange]
public function foo(): mixed
Note: this might be depreciated at some point, and it will not fix all errors, so you will have to learn the next tip.
Tip 2.
Where errors are generated with functions asking for specific return types, you will need to do something like this. I'm going to use the example in core\native\mysstring
around line 495ish there is this function which gave me a huge headache and was nearly impossible to track the location of, but I'm giving it to you so you don't have the problems I did.
/**
* Return the key of the current element.
* @return int
*/
public function key()
{
return $this->_index;
}
Here is my fixed code
Code:
/**
* Return the key of the current element.
* @return int
*/
public function key(): int
{
return $this->_index;
}
Notice that I put : int after the parenthesis in the function name. This is now the standard way to do functions and methods in modern PHP. I knew to put int because in the comment it says * @return int so this is the type that function is supposed to return. This will force templates to hash with integers instead of float numbers.
When you go through all the errors and find their locations, look at the comment on that bit of code to find out the return type, and then after the parenthesis use a colon and the return type. Here is a list of return types below:
: int
: string
: void
: mixed
: bool
: array
: float
: callable
: interfaces
If the * @return is trying to return a function, I don't think you need to add anything.
You won't be required to go through every single function in the entire code to get it to work, but you will need to test everything to see where it's needed. Most of the code I encountered was in resources, and some of the models, but I'm still testing things myself so I'm sure I will hit other spots. Eventually you should do this to all the functions for forward compatability, but for now only focus on the errors and warnings.
Last edited:
