Page 1 of 1

Whats this called when...

Posted: Thu Jan 31, 2008 5:37 am
by Kadanis
Sorry for the obscure title, couldn't think of how to phrase it without running out of room ;)

Basically, I was wondering what you would call the $type variable in the following code. As in $data is an object, $type is a ....... (fill in the blank)

In the code fragment from a class in our application, there are 2 params. 1 is an object from a mysqli_fetch_object method, the other is technically an integer, but actually should be passed one of 3 class constants. Is the var type still an integer, or is there another name for it, in order to reference it back to the constants.

In my old VB6 days, I seem to recall this being a custom ENUM, but not sure if there is anything like that in php.

It's more for curiousity than anything else, as I was writing up the phpDocs and wondered if there was a specific name for this.

Code: Select all

 
 
    const PRESEND = 0;
    const REMAINDER = 1;
    const FULL = 2;
    
    /**
     * Builds an array of packets that require renaming in order to initiate send
     *
     * @param unknown_type $data
     * @param unknown_type $type
     */
    protected function packets_for_rename($data , $type) {
        $packet_array = unserialize($data->packets);
        $campaign_id = $data->CID;
        $template_id = $data->TemplateID;
        
        foreach ($packet_array as $packet_file) {
            if ( strstr($packet_file, $type) ) {        
                $this->packets_for_rename[] = $packet_file;
            }
        }
 
    }
 

Re: Whats this called when...

Posted: Thu Jan 31, 2008 6:09 am
by Chris Corbyn
I'm becoming increasingly frustrated with the lack of enum support in PHP but I guess I mustn't grumble given that PHP is a loosely typed language.

It's just documented as "int" yep :) I usually document the parameter as an int, then use @see or @link{} tags to refer users to the class constants I've defined to get those ints.