PHP Objects, Patterns and Practice (3rd edition)
CHAPTER 5 ■ OBJECT TOOLS Neither solution is ideal. By specifying paths in this much detail, you freeze the library file in plac ...
CHAPTER 5 ■ OBJECT TOOLS Autoload In some circumstances, you may wish to organize your classes so that each sits in its own file ...
CHAPTER 5 ■ OBJECT TOOLS Again, I make some assumptions about the location of class files and directories and their relationship ...
CHAPTER 5 ■ OBJECT TOOLS Typically, you would do something like this when you want your system to be able to run user- created p ...
CHAPTER 5 ■ OBJECT TOOLS Learning About an Object or Class As you know, you can constrain the object types of method arguments u ...
CHAPTER 5 ■ OBJECT TOOLS Learning About Methods You can acquire a list of all the methods in a class using the get_class_methods ...
CHAPTER 5 ■ OBJECT TOOLS is_callable() optionally accepts a second argument, a Boolean. If you set this to true, the function wi ...
CHAPTER 5 ■ OBJECT TOOLS is_subclass_of() will tell you only about class inheritance relationships. It will not tell you that a ...
CHAPTER 5 ■ OBJECT TOOLS As you have seen, the call() method is invoked when an undefined method is called by client code. In th ...
CHAPTER 5 ■ OBJECT TOOLS Class Description ReflectionParameter Method argument information ReflectionProperty Class property inf ...
CHAPTER 5 ■ OBJECT TOOLS Parameter #1 [ $firstName ] Parameter #2 [ $mainName ] Parameter #3 [ $price ] Parameter #4 [ $play ...
CHAPTER 5 ■ OBJECT TOOLS Examining a Class The Reflection ::export() method can provide a great deal of useful information for d ...
CHAPTER 5 ■ OBJECT TOOLS You can even examine a user-defined class’s source code. The ReflectionClass object provides access to ...
CHAPTER 5 ■ OBJECT TOOLS } if ( $method->isAbstract() ) { $details .= "$name is abstract\n"; } if ( $method->isPublic() ) ...
CHAPTER 5 ■ OBJECT TOOLS Because ReflectionMethod provides us with getFileName(), getStartLine(), and getEndLine() methods, it’s ...
CHAPTER 5 ■ OBJECT TOOLS The code checks whether the argument is a reference with isPassedByReference(), and finally looks for t ...
CHAPTER 5 ■ OBJECT TOOLS Here, PersonModule and FtpModule both provide empty implementations of the execute() method. Each class ...
CHAPTER 5 ■ OBJECT TOOLS Before you can invoke the execute() method of each Module, an instance has to be created. That’s the pu ...
CHAPTER 5 ■ OBJECT TOOLS The example assumes that the required object can be instantiated with a single string argument to its c ...
CHAPTER 5 ■ OBJECT TOOLS ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf