I've learned most of my OOP practices from C#, and coded php primarily in MVC but without custom objects for data types (user information and such I primarily stored in associative arrays). I'm wanting to take what I've learned in C# (making structs, or data classes basically, to store specific types of data, such as a user record, or say an article's information) into php. This is so I can know exactly what data values to expect (because they're defined fields, instead of just added to an array), allowing a bit more abstraction between controller and view.
Is there a certain way to do this in php, and in the MVC design pattern specifically? I am curious where I should put the definitions of these new "data types."
Or am I just thinking about this in the wrong way, and there is a better way to do it?
EDIT: A C# example of what I'm trying to accomplish:
class program1
{
public void main ()
{
Article randomArticle = getArticle (); //instead of returning an object array, it returns a defined data type with predefined fields, so I don't need to guess what's there and what isn't
Console.WriteLine(randomArticle.title);
Console.ReadLine();
}
public Article getArticle ()
{
return new Article("Sometitle", "SomeContent");
}
}
struct Article
{
public Title {get; private set;}
public Content {get; private set;}
public Article (string title, string content)
{
this.Title = title;
this.Content = content;
}
}
(idk if the above actually would compile, but it gives you the gist of what I'm attempting to do in PHP)