From php+freelanceEngineer at gary.mort.net Wed Jan 2 15:05:09 2013 From: php+freelanceEngineer at gary.mort.net (Gary Mort) Date: Wed, 02 Jan 2013 20:05:09 +0000 Subject: [nycphp-talk] Test Message-ID: <11000867.Array.20130102200509.50e492f576c5e7.61623927@mail101.us4.mandrillapp.com> Test e-mail - I seem to have no email since the start of december - just want to check to see if I am still receiving mail. From leamhall at gmail.com Wed Jan 2 15:07:00 2013 From: leamhall at gmail.com (leam hall) Date: Wed, 2 Jan 2013 15:07:00 -0500 Subject: [nycphp-talk] Test In-Reply-To: <11000867.Array.20130102200509.50e492f576c5e7.61623927@mail101.us4.mandrillapp.com> References: <11000867.Array.20130102200509.50e492f576c5e7.61623927@mail101.us4.mandrillapp.com> Message-ID: On Wed, Jan 2, 2013 at 3:05 PM, Gary Mort < php+freelanceEngineer at gary.mort.net> wrote: > Test e-mail - I seem to have no email since the start of december - just > want to check to see if I am still receiving mail. > Quiet times. Any progress on "Learning to program the right way"? Leam -- Mind on a Mission -------------- next part -------------- An HTML attachment was scrubbed... URL: From codebowl at gmail.com Wed Jan 2 15:07:07 2013 From: codebowl at gmail.com (Joseph Crawford) Date: Wed, 2 Jan 2013 15:07:07 -0500 Subject: [nycphp-talk] Test In-Reply-To: <11000867.Array.20130102200509.50e492f576c5e7.61623927@mail101.us4.mandrillapp.com> References: <11000867.Array.20130102200509.50e492f576c5e7.61623927@mail101.us4.mandrillapp.com> Message-ID: got it On Jan 2, 2013, at 3:05 PM, Gary Mort wrote: > Test e-mail - I seem to have no email since the start of december - just > want to check to see if I am still receiving mail. > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation From rstoll at tutteli.ch Fri Jan 11 18:10:17 2013 From: rstoll at tutteli.ch (Robert Stoll) Date: Fri, 11 Jan 2013 23:10:17 -0000 Subject: [nycphp-talk] Type safety in PHP Message-ID: <010f01cdf050$d24d8cc0$76e8a640$@tutteli.ch> Hi, I am currently working on my final project of my undergraduate study and the project is about type safety in PHP. One aspect of the project examines the opinion of the PHP community on this topic. I now need your help. I would be very glad, if you could take 5 - 20 minutes to fill in my online survey: http://www.q-set.co.uk/q-set.php?sCode=PGSKQCJUWZVK I will publish the deliverables of my project under an open source license. Thus you contribute automatically to an open source project if you fill in the form :) Thanks for your help Robert Stoll -------------- next part -------------- An HTML attachment was scrubbed... URL: From ps at blu-studio.com Mon Jan 14 05:52:14 2013 From: ps at blu-studio.com (Peter Sawczynec) Date: Mon, 14 Jan 2013 05:52:14 -0500 Subject: [nycphp-talk] PHP Frameworks Message-ID: <002d01cdf245$36f1bd90$a4d538b0$@com> Good Day All: Lately I do a lot of Drupal and I may not be up on PHP frameworks anymore. Cake, Symfony, CodeIgniter. And a new one to me: Laravel. Can anyone offer me any thoughts, what you've heard, background info or real world experience with Laravel? Warmest regards, Peter Sawczynec Technology Dir. bl?studio 941.893.0396 ps at blu-studio.com www.blu-studio.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From nhart at partsauthority.com Mon Jan 14 12:50:33 2013 From: nhart at partsauthority.com (Nicholas Hart) Date: Mon, 14 Jan 2013 12:50:33 -0500 Subject: [nycphp-talk] Amazon MWS Message-ID: Hi, I believe I have asked this before but it has been a while. I wondered if anyone has tackled either setting up Amazon MWS in PHP or updating an existing Amazon SOAP API to MWS in PHP? The later is on my plate now and it would be nice to find someone who has some experience with this. Thanks. Nick From ka at kacomputerconsulting.com Mon Jan 14 13:51:12 2013 From: ka at kacomputerconsulting.com (Kristina Anderson) Date: Mon, 14 Jan 2013 10:51:12 -0800 (PST) Subject: [nycphp-talk] Amazon MWS In-Reply-To: References: Message-ID: <4724.72.229.162.69.1358189472.squirrel@kacomputerconsulting.com> Nick, I have dealt with setting up the base MWS install, and you can expect to have to modify their "out of the box" codebase in order to get it to work properly. In addition I have worked extensively with the catalog-upload functions of the API to create and modify product listings. I worked with the old SOAP API (AIM) years ago and this one is a significant change. You can feel free to contact me off list if you prefer. Kristina -- Kristina Anderson PHP / MySQL / AJAX / etc / Systems Analyst / Programmer / Consultant 718 726 8566 On Mon, January 14, 2013 9:50 am, Nicholas Hart wrote: > Hi, > > > I believe I have asked this before but it has been a while. I > wondered if anyone has tackled either setting up Amazon MWS in PHP or > updating an existing Amazon SOAP API to MWS in PHP? The later is on my > plate now and it would be nice to find someone who has some experience > with this. Thanks. > > Nick > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > > http://www.nyphp.org/show-participation > > > From ka at kacomputerconsulting.com Mon Jan 14 13:51:12 2013 From: ka at kacomputerconsulting.com (Kristina Anderson) Date: Mon, 14 Jan 2013 10:51:12 -0800 (PST) Subject: [nycphp-talk] Amazon MWS In-Reply-To: References: Message-ID: <4724.72.229.162.69.1358189472.squirrel@kacomputerconsulting.com> Nick, I have dealt with setting up the base MWS install, and you can expect to have to modify their "out of the box" codebase in order to get it to work properly. In addition I have worked extensively with the catalog-upload functions of the API to create and modify product listings. I worked with the old SOAP API (AIM) years ago and this one is a significant change. You can feel free to contact me off list if you prefer. Kristina -- Kristina Anderson PHP / MySQL / AJAX / etc / Systems Analyst / Programmer / Consultant 718 726 8566 On Mon, January 14, 2013 9:50 am, Nicholas Hart wrote: > Hi, > > > I believe I have asked this before but it has been a while. I > wondered if anyone has tackled either setting up Amazon MWS in PHP or > updating an existing Amazon SOAP API to MWS in PHP? The later is on my > plate now and it would be nice to find someone who has some experience > with this. Thanks. > > Nick > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > > http://www.nyphp.org/show-participation > > > From yitzchak.schaffer at gmx.com Mon Jan 14 14:32:01 2013 From: yitzchak.schaffer at gmx.com (Yitzchak Schaffer) Date: Mon, 14 Jan 2013 14:32:01 -0500 Subject: [nycphp-talk] PHP Frameworks In-Reply-To: <002d01cdf245$36f1bd90$a4d538b0$@com> References: <002d01cdf245$36f1bd90$a4d538b0$@com> Message-ID: <50F45D31.2040509@gmx.com> On 01/14/2013 05:52 AM, Peter Sawczynec wrote: > Can anyone offer me any thoughts, what you've heard, background info or > real world experience with Laravel? > ExpandTheRoom (an agency in Manhattan) uses Laravel, from what I've heard. From rainelemental at gmail.com Tue Jan 15 18:40:38 2013 From: rainelemental at gmail.com (Federico Ulfo) Date: Tue, 15 Jan 2013 18:40:38 -0500 Subject: [nycphp-talk] PHP SunShine Message-ID: Hi guys, are you going to PHP SunShine, which talks are you going to follow? I'll definitely go to meet with great developers and see what's new, not sure about the talks to follow, so here's the schedule: http://sunshinephp.com/schedule/ curious to get your feedback, Federico -------------- next part -------------- An HTML attachment was scrubbed... URL: From ircmaxell at gmail.com Tue Jan 15 19:46:46 2013 From: ircmaxell at gmail.com (Anthony Ferrara) Date: Tue, 15 Jan 2013 19:46:46 -0500 Subject: [nycphp-talk] PHP SunShine In-Reply-To: References: Message-ID: Federico, I'll be speaking there, so yes, I'm going! I've personally seen Cory Fowler's talk before, and it's definitely worth attending... Anthony On Tue, Jan 15, 2013 at 6:40 PM, Federico Ulfo wrote: > Hi guys, > are you going to PHP SunShine, which talks are you going to follow? > I'll definitely go to meet with great developers and see what's new, > not sure about the talks to follow, so here's the schedule: > http://sunshinephp.com/schedule/ > > curious to get your feedback, > Federico > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg at freephile.com Wed Jan 16 14:22:16 2013 From: greg at freephile.com (Greg Rundlett (freephile)) Date: Wed, 16 Jan 2013 14:22:16 -0500 Subject: [nycphp-talk] PHP SunShine In-Reply-To: References: Message-ID: Is php rain going to php sunshine? Oh no! ( Just kidding.) I guess that would make a php rainbow. On Jan 15, 2013 6:41 PM, "Federico Ulfo" wrote: > Hi guys, > are you going to PHP SunShine, which talks are you going to follow? > I'll definitely go to meet with great developers and see what's new, > not sure about the talks to follow, so here's the schedule: > http://sunshinephp.com/schedule/ > > curious to get your feedback, > Federico > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rainelemental at gmail.com Wed Jan 16 14:31:07 2013 From: rainelemental at gmail.com (Rainelemental) Date: Wed, 16 Jan 2013 14:31:07 -0500 Subject: [nycphp-talk] PHP SunShine In-Reply-To: References: Message-ID: <43CF69ED-676B-48C5-A256-A68746010E62@gmail.com> Hehe, are you coming too Gregg? From my iPhone On Jan 16, 2013, at 2:22 PM, "Greg Rundlett (freephile)" wrote: > Is php rain going to php sunshine? Oh no! ( Just kidding.) I guess that would make a php rainbow. > > On Jan 15, 2013 6:41 PM, "Federico Ulfo" wrote: >> Hi guys, >> are you going to PHP SunShine, which talks are you going to follow? >> I'll definitely go to meet with great developers and see what's new, >> not sure about the talks to follow, so here's the schedule: >> http://sunshinephp.com/schedule/ >> >> curious to get your feedback, >> Federico >> >> _______________________________________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/mailman/listinfo/talk >> >> http://www.nyphp.org/show-participation > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg at freephile.com Thu Jan 17 22:57:57 2013 From: greg at freephile.com (Greg Rundlett (freephile)) Date: Thu, 17 Jan 2013 22:57:57 -0500 Subject: [nycphp-talk] PHP SunShine In-Reply-To: <43CF69ED-676B-48C5-A256-A68746010E62@gmail.com> References: <43CF69ED-676B-48C5-A256-A68746010E62@gmail.com> Message-ID: Looks like a great conference. Unfortunately I won't be able to go. Greg Rundlett On Wed, Jan 16, 2013 at 2:31 PM, Rainelemental wrote: > Hehe, are you coming too Gregg? > > From my iPhone > > On Jan 16, 2013, at 2:22 PM, "Greg Rundlett (freephile)" < > greg at freephile.com> wrote: > > Is php rain going to php sunshine? Oh no! ( Just kidding.) I guess > that would make a php rainbow. > On Jan 15, 2013 6:41 PM, "Federico Ulfo" wrote: > >> Hi guys, >> are you going to PHP SunShine, which talks are you going to follow? >> I'll definitely go to meet with great developers and see what's new, >> not sure about the talks to follow, so here's the schedule: >> http://sunshinephp.com/schedule/ >> >> curious to get your feedback, >> Federico >> >> _______________________________________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/mailman/listinfo/talk >> >> http://www.nyphp.org/show-participation >> > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nhart at partsauthority.com Wed Jan 23 07:22:25 2013 From: nhart at partsauthority.com (Nicholas Hart) Date: Wed, 23 Jan 2013 07:22:25 -0500 Subject: [nycphp-talk] talk Digest, Vol 75, Issue 6 In-Reply-To: References: Message-ID: Hi, I recently moved our backup system to another location (about time!) and am now getting high resend counts (10,000+ over a few hours) for these transaction packets. The source and target systems are connecting over dedicated NICs on the Internet. For security, there are IP filters on these but I can easily take them off for testing. Using mtr, I can determine that there is some packet loss between locations but I am looking for a tool that will let me analyze by port along with packet size if possible to let me know where the problem actually lies. We use FIOS in both of these locations so we are using the Verizon network to send all of this data. I am in touch with them but am waiting - hopefully - to speak with one of the network techs. Any info or suggestions welcome. Thanks! Nick From leamhall at gmail.com Fri Jan 25 17:47:15 2013 From: leamhall at gmail.com (Leam Hall) Date: Fri, 25 Jan 2013 17:47:15 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes Message-ID: <51030B73.2080205@gmail.com> Okay, OOP newbie time again. In line 11 I declare an array. Per IRC conversations a day or so ago, line 49 has to go into the __construct function. However, the hope is that line 83 would add to what was done in line 49. It seems not to. I think because the extends doesn't actually call the __construct. Is my understanding correct? How would I achieve the goal of adding line 83 so that $roles included 'troop' and 'nco' for an object of class NCO? Thanks! Leam #### 1 age = 10 + rand(1,7); 15 $this->gender = $this->roll_gender(50); 16 return true; 17 } 18 19 protected function roll_age($min, $max) { 20 return 17 + rand($min, $max); 21 } 22 23 protected function roll_gender($trigger) { 24 if (rand(1, 100) < $trigger) { 25 return "Male"; 26 } else { 27 return "Female"; 28 } 29 } 30 31 protected function add_skill(&$skill_array, $skill) { 32 // Note the array pass by reference, per ##php fluffypony 33 if (array_key_exists($skill, $skill_array)) { 34 $skill_array[$skill] = $skill_array[$skill] + 1; 35 } else { 36 $skill_array[$skill] = 1; 37 } 38 return $skill_array; 39 } 40 } 41 42 class Trooper extends Person { 43 44 private $rank_min = 1; 45 private $rank_max = 2; 46 protected $rank_class = 'rank_enlisted'; 47 public $rank; 48 public function __construct($params) { 49 $this->roles[] = 'troop'; 50 $this->age = $this->roll_age($this->rank_min, 3 + $this->rank_max); 51 $this->gender = $this->roll_gender($params['percent_male']); 52 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; 53 foreach($this->roles as $role) { 54 $this->add_skill($this->skills, $params['base_skill'][$role]); 55 } 56 57 58 return true; 59 } 60 61 protected function get_rank($rank_min, $rank_max) { 62 return rand($rank_min, $rank_max); 63 } 64 65 } 66 67 class Corporal extends Trooper { 68 private $rank_min = 3; 69 private $rank_max = 4; 70 71 public function __construct($params) { 72 $this->age = $this->roll_age($this->rank_min , 5 + $this->rank_max); 73 $this->gender = $this->roll_gender($params['percent_male']); 74 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; 75 } 76 } 77 78 class NCO extends Corporal { 79 private $rank_min = 4; 80 private $rank_max = 6; 81 82 public function __construct($params) { 83 $this->roles[] = 'nco'; 84 $this->age = $this->roll_age($this->rank_min , 7 + $this->rank_max); 85 $this->gender = $this->roll_gender($params['percent_male']); 86 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; 87 foreach($this->roles as $role) { 88 $this->add_skill($this->skills, $params['base_skill'][$role]); 89 } 90 91 } 92 } 93 94 class SNCO extends NCO { 95 private $rank_min = 6; 96 private $rank_max = 9; 97 98 public function __construct($params) { 99 $this->age = $this->roll_age($this->rank_min , 10 + $this->rank_max); 100 $this->gender = $this->roll_gender($params['percent_male']); 101 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; 102 } 103 } 105 class Platoon_Officer extends Trooper { 106 private $rank_min = 1; 107 private $rank_max = 2; 108 protected $rank_class = 'rank_officer'; 109 110 public function __construct($params) { 111 $this->age = $this->roll_age($this->rank_min , 4 + $this->rank_max); 112 $this->gender = $this->roll_gender($params['percent_male']); 113 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; 114 } 115 } 116 117 118 class Company_Officer extends Platoon_Officer { 119 private $rank_min = 3; 120 private $rank_max = 4; 121 122 public function __construct($params) { 123 $this->age = $this->roll_age($this->rank_min , 7 + $this->rank_max); 124 $this->gender = $this->roll_gender($params['percent_male']); 125 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; 126 } 127 } 128 129 130 ?> From jeff at jeffslutz.com Fri Jan 25 17:51:14 2013 From: jeff at jeffslutz.com (Jeff Slutz) Date: Fri, 25 Jan 2013 17:51:14 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: <51030B73.2080205@gmail.com> References: <51030B73.2080205@gmail.com> Message-ID: I think you're looking for parent::__construct(); The child's __construct() will replace the parent's. So if you want to run the parent's you have to call it explicitly. JS -- Jeff Slutz JSLEUTH LLC 3242 44th ST APT 3F Astoria, NY 11103 c. 970.443.9390 jeff at jeffslutz.com On Fri, Jan 25, 2013 at 5:47 PM, Leam Hall wrote: > Okay, OOP newbie time again. In line 11 I declare an array. Per IRC > conversations a day or so ago, line 49 has to go into the __construct > function. However, the hope is that line 83 would add to what was done in > line 49. It seems not to. > > I think because the extends doesn't actually call the __construct. Is my > understanding correct? How would I achieve the goal of adding line 83 so > that $roles included 'troop' and 'nco' for an object of class NCO? > > Thanks! > > Leam > > #### > > 1 2 > 3 require_once 'stat_array.php'; > 4 > 5 class Person { > 6 > 7 public $name; > 8 public $age; > 9 public $gender = "Female"; > 10 public $skills = array(); > 11 public $roles = array(); > 12 > 13 public function __construct() { > 14 $this->age = 10 + rand(1,7); > 15 $this->gender = $this->roll_gender(50); > 16 return true; > 17 } > 18 > 19 protected function roll_age($min, $max) { > 20 return 17 + rand($min, $max); > 21 } > 22 > 23 protected function roll_gender($trigger) { > 24 if (rand(1, 100) < $trigger) { > 25 return "Male"; > 26 } else { > 27 return "Female"; > 28 } > 29 } > 30 > 31 protected function add_skill(&$skill_array, $skill) { > 32 // Note the array pass by reference, per ##php fluffypony > 33 if (array_key_exists($skill, $skill_array)) { > 34 $skill_array[$skill] = $skill_array[$skill] + 1; > 35 } else { > 36 $skill_array[$skill] = 1; > 37 } > 38 return $skill_array; > 39 } > 40 } > 41 > 42 class Trooper extends Person { > 43 > 44 private $rank_min = 1; > 45 private $rank_max = 2; > 46 protected $rank_class = 'rank_enlisted'; > 47 public $rank; > 48 public function __construct($params) { > 49 $this->roles[] = 'troop'; > 50 $this->age = $this->roll_age($this->rank_**min, 3 + > $this->rank_max); > 51 $this->gender = $this->roll_gender($params['** > percent_male']); > 52 $this->rank = $params[$this->rank_class][$** > this->get_rank($this->rank_**min, $this->rank_max)]; > 53 foreach($this->roles as $role) { > 54 $this->add_skill($this->**skills, > $params['base_skill'][$role]); > 55 } > 56 > 57 > 58 return true; > 59 } > 60 > 61 protected function get_rank($rank_min, $rank_max) { > 62 return rand($rank_min, $rank_max); > 63 } > 64 > 65 } > 66 > 67 class Corporal extends Trooper { > 68 private $rank_min = 3; > 69 private $rank_max = 4; > 70 > 71 public function __construct($params) { > 72 $this->age = $this->roll_age($this->rank_**min , 5 + > $this->rank_max); > 73 $this->gender = $this->roll_gender($params['** > percent_male']); > 74 $this->rank = $params[$this->rank_class][$** > this->get_rank($this->rank_**min, $this->rank_max)]; > 75 } > 76 } > 77 > 78 class NCO extends Corporal { > 79 private $rank_min = 4; > 80 private $rank_max = 6; > 81 > 82 public function __construct($params) { > 83 $this->roles[] = 'nco'; > 84 $this->age = $this->roll_age($this->rank_**min , 7 + > $this->rank_max); > 85 $this->gender = $this->roll_gender($params['** > percent_male']); > 86 $this->rank = $params[$this->rank_class][$** > this->get_rank($this->rank_**min, $this->rank_max)]; > 87 foreach($this->roles as $role) { > 88 $this->add_skill($this->**skills, > $params['base_skill'][$role]); > 89 } > 90 > 91 } > 92 } > 93 > 94 class SNCO extends NCO { > 95 private $rank_min = 6; > 96 private $rank_max = 9; > 97 > 98 public function __construct($params) { > 99 $this->age = $this->roll_age($this->rank_**min , 10 + > $this->rank_max); > 100 $this->gender = $this->roll_gender($params['** > percent_male']); > 101 $this->rank = $params[$this->rank_class][$** > this->get_rank($this->rank_**min, $this->rank_max)]; > 102 } > 103 } > 105 class Platoon_Officer extends Trooper { > 106 private $rank_min = 1; > 107 private $rank_max = 2; > 108 protected $rank_class = 'rank_officer'; > 109 > 110 public function __construct($params) { > 111 $this->age = $this->roll_age($this->rank_**min , 4 + > $this->rank_max); > 112 $this->gender = $this->roll_gender($params['** > percent_male']); > 113 $this->rank = $params[$this->rank_class][$** > this->get_rank($this->rank_**min, $this->rank_max)]; > 114 } > 115 } > 116 > 117 > 118 class Company_Officer extends Platoon_Officer { > 119 private $rank_min = 3; > 120 private $rank_max = 4; > 121 > 122 public function __construct($params) { > 123 $this->age = $this->roll_age($this->rank_**min , 7 + > $this->rank_max); > 124 $this->gender = $this->roll_gender($params['** > percent_male']); > 125 $this->rank = $params[$this->rank_class][$** > this->get_rank($this->rank_**min, $this->rank_max)]; > 126 } > 127 } > 128 > 129 > 130 ?> > > > ______________________________**_________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/**mailman/listinfo/talk > > http://www.nyphp.org/show-**participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rmarscher at beaffinitive.com Fri Jan 25 17:57:12 2013 From: rmarscher at beaffinitive.com (Rob Marscher) Date: Fri, 25 Jan 2013 17:57:12 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: References: <51030B73.2080205@gmail.com> Message-ID: Here's where the info is for that in the php docs: http://php.net/manual/en/language.oop5.decon.php On Jan 25, 2013, at 5:51 PM, Jeff Slutz wrote: > I think you're looking for parent::__construct(); > > The child's __construct() will replace the parent's. So if you want to run the parent's you have to call it explicitly. > > JS > > -- > Jeff Slutz > JSLEUTH LLC > 3242 44th ST APT 3F > Astoria, NY 11103 > c. 970.443.9390 > jeff at jeffslutz.com > > > On Fri, Jan 25, 2013 at 5:47 PM, Leam Hall wrote: >> Okay, OOP newbie time again. In line 11 I declare an array. Per IRC conversations a day or so ago, line 49 has to go into the __construct function. However, the hope is that line 83 would add to what was done in line 49. It seems not to. >> >> I think because the extends doesn't actually call the __construct. Is my understanding correct? How would I achieve the goal of adding line 83 so that $roles included 'troop' and 'nco' for an object of class NCO? >> >> Thanks! >> >> Leam >> >> #### >> >> 1 > 2 >> 3 require_once 'stat_array.php'; >> 4 >> 5 class Person { >> 6 >> 7 public $name; >> 8 public $age; >> 9 public $gender = "Female"; >> 10 public $skills = array(); >> 11 public $roles = array(); >> 12 >> 13 public function __construct() { >> 14 $this->age = 10 + rand(1,7); >> 15 $this->gender = $this->roll_gender(50); >> 16 return true; >> 17 } >> 18 >> 19 protected function roll_age($min, $max) { >> 20 return 17 + rand($min, $max); >> 21 } >> 22 >> 23 protected function roll_gender($trigger) { >> 24 if (rand(1, 100) < $trigger) { >> 25 return "Male"; >> 26 } else { >> 27 return "Female"; >> 28 } >> 29 } >> 30 >> 31 protected function add_skill(&$skill_array, $skill) { >> 32 // Note the array pass by reference, per ##php fluffypony >> 33 if (array_key_exists($skill, $skill_array)) { >> 34 $skill_array[$skill] = $skill_array[$skill] + 1; >> 35 } else { >> 36 $skill_array[$skill] = 1; >> 37 } >> 38 return $skill_array; >> 39 } >> 40 } >> 41 >> 42 class Trooper extends Person { >> 43 >> 44 private $rank_min = 1; >> 45 private $rank_max = 2; >> 46 protected $rank_class = 'rank_enlisted'; >> 47 public $rank; >> 48 public function __construct($params) { >> 49 $this->roles[] = 'troop'; >> 50 $this->age = $this->roll_age($this->rank_min, 3 + $this->rank_max); >> 51 $this->gender = $this->roll_gender($params['percent_male']); >> 52 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; >> 53 foreach($this->roles as $role) { >> 54 $this->add_skill($this->skills, $params['base_skill'][$role]); >> 55 } >> 56 >> 57 >> 58 return true; >> 59 } >> 60 >> 61 protected function get_rank($rank_min, $rank_max) { >> 62 return rand($rank_min, $rank_max); >> 63 } >> 64 >> 65 } >> 66 >> 67 class Corporal extends Trooper { >> 68 private $rank_min = 3; >> 69 private $rank_max = 4; >> 70 >> 71 public function __construct($params) { >> 72 $this->age = $this->roll_age($this->rank_min , 5 + $this->rank_max); >> 73 $this->gender = $this->roll_gender($params['percent_male']); >> 74 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; >> 75 } >> 76 } >> 77 >> 78 class NCO extends Corporal { >> 79 private $rank_min = 4; >> 80 private $rank_max = 6; >> 81 >> 82 public function __construct($params) { >> 83 $this->roles[] = 'nco'; >> 84 $this->age = $this->roll_age($this->rank_min , 7 + $this->rank_max); >> 85 $this->gender = $this->roll_gender($params['percent_male']); >> 86 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; >> 87 foreach($this->roles as $role) { >> 88 $this->add_skill($this->skills, $params['base_skill'][$role]); >> 89 } >> 90 >> 91 } >> 92 } >> 93 >> 94 class SNCO extends NCO { >> 95 private $rank_min = 6; >> 96 private $rank_max = 9; >> 97 >> 98 public function __construct($params) { >> 99 $this->age = $this->roll_age($this->rank_min , 10 + $this->rank_max); >> 100 $this->gender = $this->roll_gender($params['percent_male']); >> 101 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; >> 102 } >> 103 } >> 105 class Platoon_Officer extends Trooper { >> 106 private $rank_min = 1; >> 107 private $rank_max = 2; >> 108 protected $rank_class = 'rank_officer'; >> 109 >> 110 public function __construct($params) { >> 111 $this->age = $this->roll_age($this->rank_min , 4 + $this->rank_max); >> 112 $this->gender = $this->roll_gender($params['percent_male']); >> 113 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; >> 114 } >> 115 } >> 116 >> 117 >> 118 class Company_Officer extends Platoon_Officer { >> 119 private $rank_min = 3; >> 120 private $rank_max = 4; >> 121 >> 122 public function __construct($params) { >> 123 $this->age = $this->roll_age($this->rank_min , 7 + $this->rank_max); >> 124 $this->gender = $this->roll_gender($params['percent_male']); >> 125 $this->rank = $params[$this->rank_class][$this->get_rank($this->rank_min, $this->rank_max)]; >> 126 } >> 127 } >> 128 >> 129 >> 130 ?> >> >> >> _______________________________________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/mailman/listinfo/talk >> >> http://www.nyphp.org/show-participation > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation -------------- next part -------------- An HTML attachment was scrubbed... URL: From joeyd473 at gmail.com Fri Jan 25 18:42:28 2013 From: joeyd473 at gmail.com (Joey Derrico) Date: Fri, 25 Jan 2013 18:42:28 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: References: <51030B73.2080205@gmail.com> Message-ID: As Jeff said you have to call it explicitly class Trooper extends Person { public function _construct($parms) { parent::_construct(); //Whatever else is here } } Joey Derrico On Fri, Jan 25, 2013 at 5:57 PM, Rob Marscher wrote: > Here's where the info is for that in the php docs: > http://php.net/manual/en/language.oop5.decon.php > > > On Jan 25, 2013, at 5:51 PM, Jeff Slutz wrote: > > I think you're looking for parent::__construct(); > > The child's __construct() will replace the parent's. So if you want to > run the parent's you have to call it explicitly. > > JS > > -- > Jeff Slutz > JSLEUTH LLC > 3242 44th ST APT 3F > Astoria, NY 11103 > c. 970.443.9390 > jeff at jeffslutz.com > > > On Fri, Jan 25, 2013 at 5:47 PM, Leam Hall wrote: > >> Okay, OOP newbie time again. In line 11 I declare an array. Per IRC >> conversations a day or so ago, line 49 has to go into the __construct >> function. However, the hope is that line 83 would add to what was done in >> line 49. It seems not to. >> >> I think because the extends doesn't actually call the __construct. Is my >> understanding correct? How would I achieve the goal of adding line 83 so >> that $roles included 'troop' and 'nco' for an object of class NCO? >> >> Thanks! >> >> Leam >> >> #### >> >> 1 > 2 >> 3 require_once 'stat_array.php'; >> 4 >> 5 class Person { >> 6 >> 7 public $name; >> 8 public $age; >> 9 public $gender = "Female"; >> 10 public $skills = array(); >> 11 public $roles = array(); >> 12 >> 13 public function __construct() { >> 14 $this->age = 10 + rand(1,7); >> 15 $this->gender = $this->roll_gender(50); >> 16 return true; >> 17 } >> 18 >> 19 protected function roll_age($min, $max) { >> 20 return 17 + rand($min, $max); >> 21 } >> 22 >> 23 protected function roll_gender($trigger) { >> 24 if (rand(1, 100) < $trigger) { >> 25 return "Male"; >> 26 } else { >> 27 return "Female"; >> 28 } >> 29 } >> 30 >> 31 protected function add_skill(&$skill_array, $skill) { >> 32 // Note the array pass by reference, per ##php fluffypony >> 33 if (array_key_exists($skill, $skill_array)) { >> 34 $skill_array[$skill] = $skill_array[$skill] + 1; >> 35 } else { >> 36 $skill_array[$skill] = 1; >> 37 } >> 38 return $skill_array; >> 39 } >> 40 } >> 41 >> 42 class Trooper extends Person { >> 43 >> 44 private $rank_min = 1; >> 45 private $rank_max = 2; >> 46 protected $rank_class = 'rank_enlisted'; >> 47 public $rank; >> 48 public function __construct($params) { >> 49 $this->roles[] = 'troop'; >> 50 $this->age = $this->roll_age($this->rank_**min, 3 + >> $this->rank_max); >> 51 $this->gender = $this->roll_gender($params['** >> percent_male']); >> 52 $this->rank = $params[$this->rank_class][$** >> this->get_rank($this->rank_**min, $this->rank_max)]; >> 53 foreach($this->roles as $role) { >> 54 $this->add_skill($this->**skills, >> $params['base_skill'][$role]); >> 55 } >> 56 >> 57 >> 58 return true; >> 59 } >> 60 >> 61 protected function get_rank($rank_min, $rank_max) { >> 62 return rand($rank_min, $rank_max); >> 63 } >> 64 >> 65 } >> 66 >> 67 class Corporal extends Trooper { >> 68 private $rank_min = 3; >> 69 private $rank_max = 4; >> 70 >> 71 public function __construct($params) { >> 72 $this->age = $this->roll_age($this->rank_**min , 5 + >> $this->rank_max); >> 73 $this->gender = $this->roll_gender($params['** >> percent_male']); >> 74 $this->rank = $params[$this->rank_class][$** >> this->get_rank($this->rank_**min, $this->rank_max)]; >> 75 } >> 76 } >> 77 >> 78 class NCO extends Corporal { >> 79 private $rank_min = 4; >> 80 private $rank_max = 6; >> 81 >> 82 public function __construct($params) { >> 83 $this->roles[] = 'nco'; >> 84 $this->age = $this->roll_age($this->rank_**min , 7 + >> $this->rank_max); >> 85 $this->gender = $this->roll_gender($params['** >> percent_male']); >> 86 $this->rank = $params[$this->rank_class][$** >> this->get_rank($this->rank_**min, $this->rank_max)]; >> 87 foreach($this->roles as $role) { >> 88 $this->add_skill($this->**skills, >> $params['base_skill'][$role]); >> 89 } >> 90 >> 91 } >> 92 } >> 93 >> 94 class SNCO extends NCO { >> 95 private $rank_min = 6; >> 96 private $rank_max = 9; >> 97 >> 98 public function __construct($params) { >> 99 $this->age = $this->roll_age($this->rank_**min , 10 + >> $this->rank_max); >> 100 $this->gender = $this->roll_gender($params['** >> percent_male']); >> 101 $this->rank = $params[$this->rank_class][$** >> this->get_rank($this->rank_**min, $this->rank_max)]; >> 102 } >> 103 } >> 105 class Platoon_Officer extends Trooper { >> 106 private $rank_min = 1; >> 107 private $rank_max = 2; >> 108 protected $rank_class = 'rank_officer'; >> 109 >> 110 public function __construct($params) { >> 111 $this->age = $this->roll_age($this->rank_**min , 4 + >> $this->rank_max); >> 112 $this->gender = $this->roll_gender($params['** >> percent_male']); >> 113 $this->rank = $params[$this->rank_class][$** >> this->get_rank($this->rank_**min, $this->rank_max)]; >> 114 } >> 115 } >> 116 >> 117 >> 118 class Company_Officer extends Platoon_Officer { >> 119 private $rank_min = 3; >> 120 private $rank_max = 4; >> 121 >> 122 public function __construct($params) { >> 123 $this->age = $this->roll_age($this->rank_**min , 7 + >> $this->rank_max); >> 124 $this->gender = $this->roll_gender($params['** >> percent_male']); >> 125 $this->rank = $params[$this->rank_class][$** >> this->get_rank($this->rank_**min, $this->rank_max)]; >> 126 } >> 127 } >> 128 >> 129 >> 130 ?> >> >> >> ______________________________**_________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/**mailman/listinfo/talk >> >> http://www.nyphp.org/show-**participation >> > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From leamhall at gmail.com Fri Jan 25 18:51:37 2013 From: leamhall at gmail.com (Leam Hall) Date: Fri, 25 Jan 2013 18:51:37 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: References: <51030B73.2080205@gmail.com> Message-ID: <51031A89.50809@gmail.com> Interesting. The parent isn't multi-generational, far as I can see. That is, if C extends B which extends A, parent::__construct() in C does not have access to stuff constructed in A. I can make it work by making C extend A, but need to google a way to inherit further up the chain. Thanks! Leam On 01/25/2013 06:42 PM, Joey Derrico wrote: > As Jeff said you have to call it explicitly > > class Trooper extends Person > { > public function _construct($parms) > { > parent::_construct(); > //Whatever else is here > } > } > > Joey Derrico > > On Fri, Jan 25, 2013 at 5:57 PM, Rob Marscher > > wrote: > > Here's where the info is for that in the php docs: > http://php.net/manual/en/language.oop5.decon.php > > > On Jan 25, 2013, at 5:51 PM, Jeff Slutz > wrote: > >> I think you're looking for parent::__construct(); >> >> The child's __construct() will replace the parent's. So if you >> want to run the parent's you have to call it explicitly. >> >> JS| >> | >> >> -- >> Jeff Slutz >> JSLEUTH LLC >> 3242 44th ST APT 3F >> Astoria, NY 11103 >> c. 970.443.9390 >> jeff at jeffslutz.com >> >> >> On Fri, Jan 25, 2013 at 5:47 PM, Leam Hall > > wrote: >> >> Okay, OOP newbie time again. In line 11 I declare an array. >> Per IRC conversations a day or so ago, line 49 has to go into >> the __construct function. However, the hope is that line 83 >> would add to what was done in line 49. It seems not to. >> >> I think because the extends doesn't actually call the >> __construct. Is my understanding correct? How would I achieve >> the goal of adding line 83 so that $roles included 'troop' and >> 'nco' for an object of class NCO? >> >> Thanks! >> >> Leam >> >> #### >> >> 1 > 2 >> 3 require_once 'stat_array.php'; >> 4 >> 5 class Person { >> 6 >> 7 public $name; >> 8 public $age; >> 9 public $gender = "Female"; >> 10 public $skills = array(); >> 11 public $roles = array(); >> 12 >> 13 public function __construct() { >> 14 $this->age = 10 + rand(1,7); >> 15 $this->gender = $this->roll_gender(50); >> 16 return true; >> 17 } >> 18 >> 19 protected function roll_age($min, $max) { >> 20 return 17 + rand($min, $max); >> 21 } >> 22 >> 23 protected function roll_gender($trigger) { >> 24 if (rand(1, 100) < $trigger) { >> 25 return "Male"; >> 26 } else { >> 27 return "Female"; >> 28 } >> 29 } >> 30 >> 31 protected function add_skill(&$skill_array, $skill) { >> 32 // Note the array pass by reference, per ##php fluffypony >> 33 if (array_key_exists($skill, $skill_array)) { >> 34 $skill_array[$skill] = $skill_array[$skill] + 1; >> 35 } else { >> 36 $skill_array[$skill] = 1; >> 37 } >> 38 return $skill_array; >> 39 } >> 40 } >> 41 >> 42 class Trooper extends Person { >> 43 >> 44 private $rank_min = 1; >> 45 private $rank_max = 2; >> 46 protected $rank_class = 'rank_enlisted'; >> 47 public $rank; >> 48 public function __construct($params) { >> 49 $this->roles[] = 'troop'; >> 50 $this->age = $this->roll_age($this->rank___min, 3 >> + $this->rank_max); >> 51 $this->gender = >> $this->roll_gender($params['__percent_male']); >> 52 $this->rank = >> $params[$this->rank_class][$__this->get_rank($this->rank___min, $this->rank_max)]; >> 53 foreach($this->roles as $role) { >> 54 $this->add_skill($this->__skills, >> $params['base_skill'][$role]); >> 55 } >> 56 >> 57 >> 58 return true; >> 59 } >> 60 >> 61 protected function get_rank($rank_min, $rank_max) { >> 62 return rand($rank_min, $rank_max); >> 63 } >> 64 >> 65 } >> 66 >> 67 class Corporal extends Trooper { >> 68 private $rank_min = 3; >> 69 private $rank_max = 4; >> 70 >> 71 public function __construct($params) { >> 72 $this->age = $this->roll_age($this->rank___min , >> 5 + $this->rank_max); >> 73 $this->gender = >> $this->roll_gender($params['__percent_male']); >> 74 $this->rank = >> $params[$this->rank_class][$__this->get_rank($this->rank___min, $this->rank_max)]; >> 75 } >> 76 } >> 77 >> 78 class NCO extends Corporal { >> 79 private $rank_min = 4; >> 80 private $rank_max = 6; >> 81 >> 82 public function __construct($params) { >> 83 $this->roles[] = 'nco'; >> 84 $this->age = $this->roll_age($this->rank___min , >> 7 + $this->rank_max); >> 85 $this->gender = >> $this->roll_gender($params['__percent_male']); >> 86 $this->rank = >> $params[$this->rank_class][$__this->get_rank($this->rank___min, $this->rank_max)]; >> 87 foreach($this->roles as $role) { >> 88 $this->add_skill($this->__skills, >> $params['base_skill'][$role]); >> 89 } >> 90 >> 91 } >> 92 } >> 93 >> 94 class SNCO extends NCO { >> 95 private $rank_min = 6; >> 96 private $rank_max = 9; >> 97 >> 98 public function __construct($params) { >> 99 $this->age = $this->roll_age($this->rank___min , >> 10 + $this->rank_max); >> 100 $this->gender = >> $this->roll_gender($params['__percent_male']); >> 101 $this->rank = >> $params[$this->rank_class][$__this->get_rank($this->rank___min, $this->rank_max)]; >> 102 } >> 103 } >> 105 class Platoon_Officer extends Trooper { >> 106 private $rank_min = 1; >> 107 private $rank_max = 2; >> 108 protected $rank_class = 'rank_officer'; >> 109 >> 110 public function __construct($params) { >> 111 $this->age = $this->roll_age($this->rank___min , >> 4 + $this->rank_max); >> 112 $this->gender = >> $this->roll_gender($params['__percent_male']); >> 113 $this->rank = >> $params[$this->rank_class][$__this->get_rank($this->rank___min, $this->rank_max)]; >> 114 } >> 115 } >> 116 >> 117 >> 118 class Company_Officer extends Platoon_Officer { >> 119 private $rank_min = 3; >> 120 private $rank_max = 4; >> 121 >> 122 public function __construct($params) { >> 123 $this->age = $this->roll_age($this->rank___min , >> 7 + $this->rank_max); >> 124 $this->gender = >> $this->roll_gender($params['__percent_male']); >> 125 $this->rank = >> $params[$this->rank_class][$__this->get_rank($this->rank___min, $this->rank_max)]; >> 126 } >> 127 } >> 128 >> 129 >> 130 ?> >> >> >> _________________________________________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/__mailman/listinfo/talk >> >> >> http://www.nyphp.org/show-__participation >> >> >> >> _______________________________________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/mailman/listinfo/talk >> >> http://www.nyphp.org/show-participation > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > > > > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > From leamhall at gmail.com Fri Jan 25 18:57:40 2013 From: leamhall at gmail.com (Leam Hall) Date: Fri, 25 Jan 2013 18:57:40 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: <51031A89.50809@gmail.com> References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> Message-ID: <51031BF4.3040405@gmail.com> Err...until I remember to put parent::__construct() in B. :) Leam On 01/25/2013 06:51 PM, Leam Hall wrote: > Interesting. The parent isn't multi-generational, far as I can see. That > is, if C extends B which extends A, parent::__construct() in C does not > have access to stuff constructed in A. > > I can make it work by making C extend A, but need to google a way to > inherit further up the chain. > > Thanks! > > Leam > > > On 01/25/2013 06:42 PM, Joey Derrico wrote: >> As Jeff said you have to call it explicitly >> >> class Trooper extends Person >> { >> public function _construct($parms) >> { >> parent::_construct(); >> //Whatever else is here >> } >> } >> >> Joey Derrico >> >> On Fri, Jan 25, 2013 at 5:57 PM, Rob Marscher >> > wrote: >> >> Here's where the info is for that in the php docs: >> http://php.net/manual/en/language.oop5.decon.php >> >> >> On Jan 25, 2013, at 5:51 PM, Jeff Slutz > > wrote: >> >>> I think you're looking for parent::__construct(); >>> >>> The child's __construct() will replace the parent's. So if you >>> want to run the parent's you have to call it explicitly. >>> >>> JS| >>> | >>> >>> -- >>> Jeff Slutz >>> JSLEUTH LLC >>> 3242 44th ST APT 3F >>> Astoria, NY 11103 >>> c. 970.443.9390 >>> jeff at jeffslutz.com >>> >>> >>> On Fri, Jan 25, 2013 at 5:47 PM, Leam Hall >> > wrote: >>> >>> Okay, OOP newbie time again. In line 11 I declare an array. >>> Per IRC conversations a day or so ago, line 49 has to go into >>> the __construct function. However, the hope is that line 83 >>> would add to what was done in line 49. It seems not to. >>> >>> I think because the extends doesn't actually call the >>> __construct. Is my understanding correct? How would I achieve >>> the goal of adding line 83 so that $roles included 'troop' and >>> 'nco' for an object of class NCO? >>> >>> Thanks! >>> >>> Leam >>> >>> #### >>> >>> 1 >> 2 >>> 3 require_once 'stat_array.php'; >>> 4 >>> 5 class Person { >>> 6 >>> 7 public $name; >>> 8 public $age; >>> 9 public $gender = "Female"; >>> 10 public $skills = array(); >>> 11 public $roles = array(); >>> 12 >>> 13 public function __construct() { >>> 14 $this->age = 10 + rand(1,7); >>> 15 $this->gender = $this->roll_gender(50); >>> 16 return true; >>> 17 } >>> 18 >>> 19 protected function roll_age($min, $max) { >>> 20 return 17 + rand($min, $max); >>> 21 } >>> 22 >>> 23 protected function roll_gender($trigger) { >>> 24 if (rand(1, 100) < $trigger) { >>> 25 return "Male"; >>> 26 } else { >>> 27 return "Female"; >>> 28 } >>> 29 } >>> 30 >>> 31 protected function add_skill(&$skill_array, $skill) { >>> 32 // Note the array pass by reference, per ##php >>> fluffypony >>> 33 if (array_key_exists($skill, $skill_array)) { >>> 34 $skill_array[$skill] = $skill_array[$skill] >>> + 1; >>> 35 } else { >>> 36 $skill_array[$skill] = 1; >>> 37 } >>> 38 return $skill_array; >>> 39 } >>> 40 } >>> 41 >>> 42 class Trooper extends Person { >>> 43 >>> 44 private $rank_min = 1; >>> 45 private $rank_max = 2; >>> 46 protected $rank_class = 'rank_enlisted'; >>> 47 public $rank; >>> 48 public function __construct($params) { >>> 49 $this->roles[] = 'troop'; >>> 50 $this->age = $this->roll_age($this->rank___min, 3 >>> + $this->rank_max); >>> 51 $this->gender = >>> $this->roll_gender($params['__percent_male']); >>> 52 $this->rank = >>> >>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>> $this->rank_max)]; >>> 53 foreach($this->roles as $role) { >>> 54 $this->add_skill($this->__skills, >>> $params['base_skill'][$role]); >>> 55 } >>> 56 >>> 57 >>> 58 return true; >>> 59 } >>> 60 >>> 61 protected function get_rank($rank_min, $rank_max) { >>> 62 return rand($rank_min, $rank_max); >>> 63 } >>> 64 >>> 65 } >>> 66 >>> 67 class Corporal extends Trooper { >>> 68 private $rank_min = 3; >>> 69 private $rank_max = 4; >>> 70 >>> 71 public function __construct($params) { >>> 72 $this->age = $this->roll_age($this->rank___min , >>> 5 + $this->rank_max); >>> 73 $this->gender = >>> $this->roll_gender($params['__percent_male']); >>> 74 $this->rank = >>> >>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>> $this->rank_max)]; >>> 75 } >>> 76 } >>> 77 >>> 78 class NCO extends Corporal { >>> 79 private $rank_min = 4; >>> 80 private $rank_max = 6; >>> 81 >>> 82 public function __construct($params) { >>> 83 $this->roles[] = 'nco'; >>> 84 $this->age = $this->roll_age($this->rank___min , >>> 7 + $this->rank_max); >>> 85 $this->gender = >>> $this->roll_gender($params['__percent_male']); >>> 86 $this->rank = >>> >>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>> $this->rank_max)]; >>> 87 foreach($this->roles as $role) { >>> 88 $this->add_skill($this->__skills, >>> $params['base_skill'][$role]); >>> 89 } >>> 90 >>> 91 } >>> 92 } >>> 93 >>> 94 class SNCO extends NCO { >>> 95 private $rank_min = 6; >>> 96 private $rank_max = 9; >>> 97 >>> 98 public function __construct($params) { >>> 99 $this->age = $this->roll_age($this->rank___min , >>> 10 + $this->rank_max); >>> 100 $this->gender = >>> $this->roll_gender($params['__percent_male']); >>> 101 $this->rank = >>> >>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>> $this->rank_max)]; >>> 102 } >>> 103 } >>> 105 class Platoon_Officer extends Trooper { >>> 106 private $rank_min = 1; >>> 107 private $rank_max = 2; >>> 108 protected $rank_class = 'rank_officer'; >>> 109 >>> 110 public function __construct($params) { >>> 111 $this->age = $this->roll_age($this->rank___min , >>> 4 + $this->rank_max); >>> 112 $this->gender = >>> $this->roll_gender($params['__percent_male']); >>> 113 $this->rank = >>> >>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>> $this->rank_max)]; >>> 114 } >>> 115 } >>> 116 >>> 117 >>> 118 class Company_Officer extends Platoon_Officer { >>> 119 private $rank_min = 3; >>> 120 private $rank_max = 4; >>> 121 >>> 122 public function __construct($params) { >>> 123 $this->age = $this->roll_age($this->rank___min , >>> 7 + $this->rank_max); >>> 124 $this->gender = >>> $this->roll_gender($params['__percent_male']); >>> 125 $this->rank = >>> >>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>> $this->rank_max)]; >>> 126 } >>> 127 } >>> 128 >>> 129 >>> 130 ?> >>> >>> >>> _________________________________________________ >>> New York PHP User Group Community Talk Mailing List >>> http://lists.nyphp.org/__mailman/listinfo/talk >>> >>> >>> http://www.nyphp.org/show-__participation >>> >>> >>> >>> _______________________________________________ >>> New York PHP User Group Community Talk Mailing List >>> http://lists.nyphp.org/mailman/listinfo/talk >>> >>> http://www.nyphp.org/show-participation >> >> _______________________________________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/mailman/listinfo/talk >> >> http://www.nyphp.org/show-participation >> >> >> >> >> _______________________________________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/mailman/listinfo/talk >> >> http://www.nyphp.org/show-participation >> From dsteplight at gmail.com Fri Jan 25 19:06:19 2013 From: dsteplight at gmail.com (Darryle Steplight) Date: Fri, 25 Jan 2013 19:06:19 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: <51031BF4.3040405@gmail.com> References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> Message-ID: Take a look at PHP traits, its a PHP 5.4 feature and PHP's solution to multi-inheritance. On Fri, Jan 25, 2013 at 6:57 PM, Leam Hall wrote: > Err...until I remember to put parent::__construct() in B. :) > > Leam > > > On 01/25/2013 06:51 PM, Leam Hall wrote: >> >> Interesting. The parent isn't multi-generational, far as I can see. That >> is, if C extends B which extends A, parent::__construct() in C does not >> have access to stuff constructed in A. >> >> I can make it work by making C extend A, but need to google a way to >> inherit further up the chain. >> >> Thanks! >> >> Leam >> >> >> On 01/25/2013 06:42 PM, Joey Derrico wrote: >>> >>> As Jeff said you have to call it explicitly >>> >>> class Trooper extends Person >>> { >>> public function _construct($parms) >>> { >>> parent::_construct(); >>> //Whatever else is here >>> } >>> } >>> >>> Joey Derrico >>> >>> On Fri, Jan 25, 2013 at 5:57 PM, Rob Marscher >>> > wrote: >>> >>> Here's where the info is for that in the php docs: >>> http://php.net/manual/en/language.oop5.decon.php >>> >>> >>> On Jan 25, 2013, at 5:51 PM, Jeff Slutz >> > wrote: >>> >>>> I think you're looking for parent::__construct(); >>>> >>>> The child's __construct() will replace the parent's. So if you >>>> want to run the parent's you have to call it explicitly. >>>> >>>> JS| >>>> | >>>> >>>> -- >>>> Jeff Slutz >>>> JSLEUTH LLC >>>> 3242 44th ST APT 3F >>>> Astoria, NY 11103 >>>> c. 970.443.9390 >>>> jeff at jeffslutz.com >>>> >>>> >>>> On Fri, Jan 25, 2013 at 5:47 PM, Leam Hall >>> > wrote: >>>> >>>> Okay, OOP newbie time again. In line 11 I declare an array. >>>> Per IRC conversations a day or so ago, line 49 has to go into >>>> the __construct function. However, the hope is that line 83 >>>> would add to what was done in line 49. It seems not to. >>>> >>>> I think because the extends doesn't actually call the >>>> __construct. Is my understanding correct? How would I achieve >>>> the goal of adding line 83 so that $roles included 'troop' and >>>> 'nco' for an object of class NCO? >>>> >>>> Thanks! >>>> >>>> Leam >>>> >>>> #### >>>> >>>> 1 >>> 2 >>>> 3 require_once 'stat_array.php'; >>>> 4 >>>> 5 class Person { >>>> 6 >>>> 7 public $name; >>>> 8 public $age; >>>> 9 public $gender = "Female"; >>>> 10 public $skills = array(); >>>> 11 public $roles = array(); >>>> 12 >>>> 13 public function __construct() { >>>> 14 $this->age = 10 + rand(1,7); >>>> 15 $this->gender = $this->roll_gender(50); >>>> 16 return true; >>>> 17 } >>>> 18 >>>> 19 protected function roll_age($min, $max) { >>>> 20 return 17 + rand($min, $max); >>>> 21 } >>>> 22 >>>> 23 protected function roll_gender($trigger) { >>>> 24 if (rand(1, 100) < $trigger) { >>>> 25 return "Male"; >>>> 26 } else { >>>> 27 return "Female"; >>>> 28 } >>>> 29 } >>>> 30 >>>> 31 protected function add_skill(&$skill_array, $skill) { >>>> 32 // Note the array pass by reference, per ##php >>>> fluffypony >>>> 33 if (array_key_exists($skill, $skill_array)) { >>>> 34 $skill_array[$skill] = $skill_array[$skill] >>>> + 1; >>>> 35 } else { >>>> 36 $skill_array[$skill] = 1; >>>> 37 } >>>> 38 return $skill_array; >>>> 39 } >>>> 40 } >>>> 41 >>>> 42 class Trooper extends Person { >>>> 43 >>>> 44 private $rank_min = 1; >>>> 45 private $rank_max = 2; >>>> 46 protected $rank_class = 'rank_enlisted'; >>>> 47 public $rank; >>>> 48 public function __construct($params) { >>>> 49 $this->roles[] = 'troop'; >>>> 50 $this->age = $this->roll_age($this->rank___min, 3 >>>> + $this->rank_max); >>>> 51 $this->gender = >>>> $this->roll_gender($params['__percent_male']); >>>> 52 $this->rank = >>>> >>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>> $this->rank_max)]; >>>> 53 foreach($this->roles as $role) { >>>> 54 $this->add_skill($this->__skills, >>>> $params['base_skill'][$role]); >>>> 55 } >>>> 56 >>>> 57 >>>> 58 return true; >>>> 59 } >>>> 60 >>>> 61 protected function get_rank($rank_min, $rank_max) { >>>> 62 return rand($rank_min, $rank_max); >>>> 63 } >>>> 64 >>>> 65 } >>>> 66 >>>> 67 class Corporal extends Trooper { >>>> 68 private $rank_min = 3; >>>> 69 private $rank_max = 4; >>>> 70 >>>> 71 public function __construct($params) { >>>> 72 $this->age = $this->roll_age($this->rank___min , >>>> 5 + $this->rank_max); >>>> 73 $this->gender = >>>> $this->roll_gender($params['__percent_male']); >>>> 74 $this->rank = >>>> >>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>> $this->rank_max)]; >>>> 75 } >>>> 76 } >>>> 77 >>>> 78 class NCO extends Corporal { >>>> 79 private $rank_min = 4; >>>> 80 private $rank_max = 6; >>>> 81 >>>> 82 public function __construct($params) { >>>> 83 $this->roles[] = 'nco'; >>>> 84 $this->age = $this->roll_age($this->rank___min , >>>> 7 + $this->rank_max); >>>> 85 $this->gender = >>>> $this->roll_gender($params['__percent_male']); >>>> 86 $this->rank = >>>> >>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>> $this->rank_max)]; >>>> 87 foreach($this->roles as $role) { >>>> 88 $this->add_skill($this->__skills, >>>> $params['base_skill'][$role]); >>>> 89 } >>>> 90 >>>> 91 } >>>> 92 } >>>> 93 >>>> 94 class SNCO extends NCO { >>>> 95 private $rank_min = 6; >>>> 96 private $rank_max = 9; >>>> 97 >>>> 98 public function __construct($params) { >>>> 99 $this->age = $this->roll_age($this->rank___min , >>>> 10 + $this->rank_max); >>>> 100 $this->gender = >>>> $this->roll_gender($params['__percent_male']); >>>> 101 $this->rank = >>>> >>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>> $this->rank_max)]; >>>> 102 } >>>> 103 } >>>> 105 class Platoon_Officer extends Trooper { >>>> 106 private $rank_min = 1; >>>> 107 private $rank_max = 2; >>>> 108 protected $rank_class = 'rank_officer'; >>>> 109 >>>> 110 public function __construct($params) { >>>> 111 $this->age = $this->roll_age($this->rank___min , >>>> 4 + $this->rank_max); >>>> 112 $this->gender = >>>> $this->roll_gender($params['__percent_male']); >>>> 113 $this->rank = >>>> >>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>> $this->rank_max)]; >>>> 114 } >>>> 115 } >>>> 116 >>>> 117 >>>> 118 class Company_Officer extends Platoon_Officer { >>>> 119 private $rank_min = 3; >>>> 120 private $rank_max = 4; >>>> 121 >>>> 122 public function __construct($params) { >>>> 123 $this->age = $this->roll_age($this->rank___min , >>>> 7 + $this->rank_max); >>>> 124 $this->gender = >>>> $this->roll_gender($params['__percent_male']); >>>> 125 $this->rank = >>>> >>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>> $this->rank_max)]; >>>> 126 } >>>> 127 } >>>> 128 >>>> 129 >>>> 130 ?> >>>> >>>> >>>> _________________________________________________ >>>> New York PHP User Group Community Talk Mailing List >>>> http://lists.nyphp.org/__mailman/listinfo/talk >>>> >>>> >>>> http://www.nyphp.org/show-__participation >>>> >>>> >>>> >>>> _______________________________________________ >>>> New York PHP User Group Community Talk Mailing List >>>> http://lists.nyphp.org/mailman/listinfo/talk >>>> >>>> http://www.nyphp.org/show-participation >>> >>> >>> _______________________________________________ >>> New York PHP User Group Community Talk Mailing List >>> http://lists.nyphp.org/mailman/listinfo/talk >>> >>> http://www.nyphp.org/show-participation >>> >>> >>> >>> >>> _______________________________________________ >>> New York PHP User Group Community Talk Mailing List >>> http://lists.nyphp.org/mailman/listinfo/talk >>> >>> http://www.nyphp.org/show-participation >>> > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation -- ---------------------------------------------- "May the source be with you." From leamhall at gmail.com Fri Jan 25 19:34:14 2013 From: leamhall at gmail.com (Leam Hall) Date: Fri, 25 Jan 2013 19:34:14 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> Message-ID: <51032486.3020209@gmail.com> Will do. Right now I'm trying to figure out how to override a variable set in the parent class. On 01/25/2013 07:06 PM, Darryle Steplight wrote: > Take a look at PHP traits, its a PHP 5.4 feature and PHP's solution to > multi-inheritance. > > On Fri, Jan 25, 2013 at 6:57 PM, Leam Hall wrote: >> Err...until I remember to put parent::__construct() in B. :) >> >> Leam >> >> >> On 01/25/2013 06:51 PM, Leam Hall wrote: >>> >>> Interesting. The parent isn't multi-generational, far as I can see. That >>> is, if C extends B which extends A, parent::__construct() in C does not >>> have access to stuff constructed in A. >>> >>> I can make it work by making C extend A, but need to google a way to >>> inherit further up the chain. >>> >>> Thanks! >>> >>> Leam >>> >>> >>> On 01/25/2013 06:42 PM, Joey Derrico wrote: >>>> >>>> As Jeff said you have to call it explicitly >>>> >>>> class Trooper extends Person >>>> { >>>> public function _construct($parms) >>>> { >>>> parent::_construct(); >>>> //Whatever else is here >>>> } >>>> } >>>> >>>> Joey Derrico >>>> >>>> On Fri, Jan 25, 2013 at 5:57 PM, Rob Marscher >>>> > wrote: >>>> >>>> Here's where the info is for that in the php docs: >>>> http://php.net/manual/en/language.oop5.decon.php >>>> >>>> >>>> On Jan 25, 2013, at 5:51 PM, Jeff Slutz >>> > wrote: >>>> >>>>> I think you're looking for parent::__construct(); >>>>> >>>>> The child's __construct() will replace the parent's. So if you >>>>> want to run the parent's you have to call it explicitly. >>>>> >>>>> JS| >>>>> | >>>>> >>>>> -- >>>>> Jeff Slutz >>>>> JSLEUTH LLC >>>>> 3242 44th ST APT 3F >>>>> Astoria, NY 11103 >>>>> c. 970.443.9390 >>>>> jeff at jeffslutz.com >>>>> >>>>> >>>>> On Fri, Jan 25, 2013 at 5:47 PM, Leam Hall >>>> > wrote: >>>>> >>>>> Okay, OOP newbie time again. In line 11 I declare an array. >>>>> Per IRC conversations a day or so ago, line 49 has to go into >>>>> the __construct function. However, the hope is that line 83 >>>>> would add to what was done in line 49. It seems not to. >>>>> >>>>> I think because the extends doesn't actually call the >>>>> __construct. Is my understanding correct? How would I achieve >>>>> the goal of adding line 83 so that $roles included 'troop' and >>>>> 'nco' for an object of class NCO? >>>>> >>>>> Thanks! >>>>> >>>>> Leam >>>>> >>>>> #### >>>>> >>>>> 1 >>>> 2 >>>>> 3 require_once 'stat_array.php'; >>>>> 4 >>>>> 5 class Person { >>>>> 6 >>>>> 7 public $name; >>>>> 8 public $age; >>>>> 9 public $gender = "Female"; >>>>> 10 public $skills = array(); >>>>> 11 public $roles = array(); >>>>> 12 >>>>> 13 public function __construct() { >>>>> 14 $this->age = 10 + rand(1,7); >>>>> 15 $this->gender = $this->roll_gender(50); >>>>> 16 return true; >>>>> 17 } >>>>> 18 >>>>> 19 protected function roll_age($min, $max) { >>>>> 20 return 17 + rand($min, $max); >>>>> 21 } >>>>> 22 >>>>> 23 protected function roll_gender($trigger) { >>>>> 24 if (rand(1, 100) < $trigger) { >>>>> 25 return "Male"; >>>>> 26 } else { >>>>> 27 return "Female"; >>>>> 28 } >>>>> 29 } >>>>> 30 >>>>> 31 protected function add_skill(&$skill_array, $skill) { >>>>> 32 // Note the array pass by reference, per ##php >>>>> fluffypony >>>>> 33 if (array_key_exists($skill, $skill_array)) { >>>>> 34 $skill_array[$skill] = $skill_array[$skill] >>>>> + 1; >>>>> 35 } else { >>>>> 36 $skill_array[$skill] = 1; >>>>> 37 } >>>>> 38 return $skill_array; >>>>> 39 } >>>>> 40 } >>>>> 41 >>>>> 42 class Trooper extends Person { >>>>> 43 >>>>> 44 private $rank_min = 1; >>>>> 45 private $rank_max = 2; >>>>> 46 protected $rank_class = 'rank_enlisted'; >>>>> 47 public $rank; >>>>> 48 public function __construct($params) { >>>>> 49 $this->roles[] = 'troop'; >>>>> 50 $this->age = $this->roll_age($this->rank___min, 3 >>>>> + $this->rank_max); >>>>> 51 $this->gender = >>>>> $this->roll_gender($params['__percent_male']); >>>>> 52 $this->rank = >>>>> >>>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>>> $this->rank_max)]; >>>>> 53 foreach($this->roles as $role) { >>>>> 54 $this->add_skill($this->__skills, >>>>> $params['base_skill'][$role]); >>>>> 55 } >>>>> 56 >>>>> 57 >>>>> 58 return true; >>>>> 59 } >>>>> 60 >>>>> 61 protected function get_rank($rank_min, $rank_max) { >>>>> 62 return rand($rank_min, $rank_max); >>>>> 63 } >>>>> 64 >>>>> 65 } >>>>> 66 >>>>> 67 class Corporal extends Trooper { >>>>> 68 private $rank_min = 3; >>>>> 69 private $rank_max = 4; >>>>> 70 >>>>> 71 public function __construct($params) { >>>>> 72 $this->age = $this->roll_age($this->rank___min , >>>>> 5 + $this->rank_max); >>>>> 73 $this->gender = >>>>> $this->roll_gender($params['__percent_male']); >>>>> 74 $this->rank = >>>>> >>>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>>> $this->rank_max)]; >>>>> 75 } >>>>> 76 } >>>>> 77 >>>>> 78 class NCO extends Corporal { >>>>> 79 private $rank_min = 4; >>>>> 80 private $rank_max = 6; >>>>> 81 >>>>> 82 public function __construct($params) { >>>>> 83 $this->roles[] = 'nco'; >>>>> 84 $this->age = $this->roll_age($this->rank___min , >>>>> 7 + $this->rank_max); >>>>> 85 $this->gender = >>>>> $this->roll_gender($params['__percent_male']); >>>>> 86 $this->rank = >>>>> >>>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>>> $this->rank_max)]; >>>>> 87 foreach($this->roles as $role) { >>>>> 88 $this->add_skill($this->__skills, >>>>> $params['base_skill'][$role]); >>>>> 89 } >>>>> 90 >>>>> 91 } >>>>> 92 } >>>>> 93 >>>>> 94 class SNCO extends NCO { >>>>> 95 private $rank_min = 6; >>>>> 96 private $rank_max = 9; >>>>> 97 >>>>> 98 public function __construct($params) { >>>>> 99 $this->age = $this->roll_age($this->rank___min , >>>>> 10 + $this->rank_max); >>>>> 100 $this->gender = >>>>> $this->roll_gender($params['__percent_male']); >>>>> 101 $this->rank = >>>>> >>>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>>> $this->rank_max)]; >>>>> 102 } >>>>> 103 } >>>>> 105 class Platoon_Officer extends Trooper { >>>>> 106 private $rank_min = 1; >>>>> 107 private $rank_max = 2; >>>>> 108 protected $rank_class = 'rank_officer'; >>>>> 109 >>>>> 110 public function __construct($params) { >>>>> 111 $this->age = $this->roll_age($this->rank___min , >>>>> 4 + $this->rank_max); >>>>> 112 $this->gender = >>>>> $this->roll_gender($params['__percent_male']); >>>>> 113 $this->rank = >>>>> >>>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>>> $this->rank_max)]; >>>>> 114 } >>>>> 115 } >>>>> 116 >>>>> 117 >>>>> 118 class Company_Officer extends Platoon_Officer { >>>>> 119 private $rank_min = 3; >>>>> 120 private $rank_max = 4; >>>>> 121 >>>>> 122 public function __construct($params) { >>>>> 123 $this->age = $this->roll_age($this->rank___min , >>>>> 7 + $this->rank_max); >>>>> 124 $this->gender = >>>>> $this->roll_gender($params['__percent_male']); >>>>> 125 $this->rank = >>>>> >>>>> $params[$this->rank_class][$__this->get_rank($this->rank___min, >>>>> $this->rank_max)]; >>>>> 126 } >>>>> 127 } >>>>> 128 >>>>> 129 >>>>> 130 ?> >>>>> >>>>> >>>>> _________________________________________________ >>>>> New York PHP User Group Community Talk Mailing List >>>>> http://lists.nyphp.org/__mailman/listinfo/talk >>>>> >>>>> >>>>> http://www.nyphp.org/show-__participation >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> New York PHP User Group Community Talk Mailing List >>>>> http://lists.nyphp.org/mailman/listinfo/talk >>>>> >>>>> http://www.nyphp.org/show-participation >>>> >>>> >>>> _______________________________________________ >>>> New York PHP User Group Community Talk Mailing List >>>> http://lists.nyphp.org/mailman/listinfo/talk >>>> >>>> http://www.nyphp.org/show-participation >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> New York PHP User Group Community Talk Mailing List >>>> http://lists.nyphp.org/mailman/listinfo/talk >>>> >>>> http://www.nyphp.org/show-participation >>>> >> _______________________________________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/mailman/listinfo/talk >> >> http://www.nyphp.org/show-participation > > > From leamhall at gmail.com Fri Jan 25 19:52:04 2013 From: leamhall at gmail.com (Leam Hall) Date: Fri, 25 Jan 2013 19:52:04 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: <51032486.3020209@gmail.com> References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> <51032486.3020209@gmail.com> Message-ID: <510328B4.7080604@gmail.com> And that would be to make the variables public. On 01/25/2013 07:34 PM, Leam Hall wrote: > Will do. Right now I'm trying to figure out how to override a variable > set in the parent class. > From gatzby3jr at gmail.com Fri Jan 25 19:55:24 2013 From: gatzby3jr at gmail.com (Brian O'Connor) Date: Fri, 25 Jan 2013 19:55:24 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: <510328B4.7080604@gmail.com> References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> <51032486.3020209@gmail.com> <510328B4.7080604@gmail.com> Message-ID: You can also use 'protected' to only allow sub-classes to access the variable. On Fri, Jan 25, 2013 at 7:52 PM, Leam Hall wrote: > And that would be to make the variables public. > > > On 01/25/2013 07:34 PM, Leam Hall wrote: > >> Will do. Right now I'm trying to figure out how to override a variable >> set in the parent class. >> >> ______________________________**_________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/**mailman/listinfo/talk > > http://www.nyphp.org/show-**participation > -- Brian O'Connor -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeff at jeffslutz.com Fri Jan 25 21:18:54 2013 From: jeff at jeffslutz.com (Jeff Slutz) Date: Fri, 25 Jan 2013 21:18:54 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> <51032486.3020209@gmail.com> <510328B4.7080604@gmail.com> Message-ID: Yes, as Brian said, go with protected. If you need to change the value of the attribute from outside of the class then provide a public setter method to set a new value. This approach makes the control of the objects a lot easier to manage. Best, Jeff -- Jeff Slutz JSLEUTH LLC 3242 44th ST APT 3F Astoria, NY 11103 c. 970.443.9390 jeff at jeffslutz.com On Fri, Jan 25, 2013 at 7:55 PM, Brian O'Connor wrote: > You can also use 'protected' to only allow sub-classes to access the > variable. > > > On Fri, Jan 25, 2013 at 7:52 PM, Leam Hall wrote: > >> And that would be to make the variables public. >> >> >> On 01/25/2013 07:34 PM, Leam Hall wrote: >> >>> Will do. Right now I'm trying to figure out how to override a variable >>> set in the parent class. >>> >>> ______________________________**_________________ >> New York PHP User Group Community Talk Mailing List >> http://lists.nyphp.org/**mailman/listinfo/talk >> >> http://www.nyphp.org/show-**participation >> > > > > -- > Brian O'Connor > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From consult at covenantedesign.com Sat Jan 26 11:08:26 2013 From: consult at covenantedesign.com (CED) Date: Sat, 26 Jan 2013 08:08:26 -0800 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> <51032486.3020209@gmail.com> <510328B4.7080604@gmail.com> Message-ID: <5103FF7A.4090107@covenantedesign.com> And I would say more secure. :) On 1/25/2013 6:18 PM, Jeff Slutz wrote: > Yes, as Brian said, go with protected. If you need to change the > value of the attribute from outside of the class then provide a public > setter method to set a new value. This approach makes the control of > the objects a lot easier to manage. > > Best, > Jeff > > -- > Jeff Slutz > JSLEUTH LLC > 3242 44th ST APT 3F > Astoria, NY 11103 > c. 970.443.9390 > jeff at jeffslutz.com > > > On Fri, Jan 25, 2013 at 7:55 PM, Brian O'Connor > wrote: > > You can also use 'protected' to only allow sub-classes to access > the variable. > > > On Fri, Jan 25, 2013 at 7:52 PM, Leam Hall > wrote: > > And that would be to make the variables public. > > > On 01/25/2013 07:34 PM, Leam Hall wrote: > > Will do. Right now I'm trying to figure out how to > override a variable > set in the parent class. > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > > > > > -- > Brian O'Connor > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > > > > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation -- 995 Maple Hill Road Castleton, New York 12033 518-331-5061 Consult at CovenanteDesign.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at davidmintz.org Tue Jan 29 09:34:42 2013 From: david at davidmintz.org (David Mintz) Date: Tue, 29 Jan 2013 09:34:42 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: <5103FF7A.4090107@covenantedesign.com> References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> <51032486.3020209@gmail.com> <510328B4.7080604@gmail.com> <5103FF7A.4090107@covenantedesign.com> Message-ID: This might be little more than a matter of style, but I would add that I don't think Person's __construct() should return a boolean. By definition it returns an instance of the Person class, so you need not explicitly return anything. -- David Mintz http://davidmintz.org/ Fight for social equality: http://socialequality.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ircmaxell at gmail.com Tue Jan 29 09:43:46 2013 From: ircmaxell at gmail.com (Anthony Ferrara) Date: Tue, 29 Jan 2013 09:43:46 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> <51032486.3020209@gmail.com> <510328B4.7080604@gmail.com> <5103FF7A.4090107@covenantedesign.com> Message-ID: The constructor's return value is always ignored internally. So the only time the constructor's return is ever used is in a child-class. if (parent::__construct()) { // blah } But I'd argue that if you need to do that, inheritance isn't what you need, but another form of composition... Anthony On Tue, Jan 29, 2013 at 9:34 AM, David Mintz wrote: > This might be little more than a matter of style, but I would add that I > don't think Person's __construct() should return a boolean. By definition > it returns an instance of the Person class, so you need not explicitly > return anything. > > > -- > David Mintz > http://davidmintz.org/ > Fight for social equality: > http://socialequality.com/ > > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at davidmintz.org Tue Jan 29 12:18:06 2013 From: david at davidmintz.org (David Mintz) Date: Tue, 29 Jan 2013 12:18:06 -0500 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> <51032486.3020209@gmail.com> <510328B4.7080604@gmail.com> <5103FF7A.4090107@covenantedesign.com> Message-ID: On Tue, Jan 29, 2013 at 9:43 AM, Anthony Ferrara wrote: > The constructor's return value is always ignored internally. So the only > time the constructor's return is ever used is in a child-class. > > if (parent::__construct()) { > // blah > } > > You lost me there. If it's always ignored... always means always, right? -- David Mintz http://davidmintz.org/ Fight for social equality: http://socialequality.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From justin at justinhileman.info Tue Jan 29 12:55:37 2013 From: justin at justinhileman.info (justin) Date: Tue, 29 Jan 2013 09:55:37 -0800 Subject: [nycphp-talk] OOP Newbie Building arrays in extended classes In-Reply-To: References: <51030B73.2080205@gmail.com> <51031A89.50809@gmail.com> <51031BF4.3040405@gmail.com> <51032486.3020209@gmail.com> <510328B4.7080604@gmail.com> <5103FF7A.4090107@covenantedesign.com> Message-ID: On Tue, Jan 29, 2013 at 9:18 AM, David Mintz wrote: > On Tue, Jan 29, 2013 at 9:43 AM, Anthony Ferrara wrote: > >> The constructor's return value is always ignored internally. So the only >> time the constructor's return is ever used is in a child-class. >> >> if (parent::__construct()) { >> // blah >> } >> >> > You lost me there. If it's always ignored... always means always, right? > It's always ignored *internally*, i.e. you'll never get a return value from `new Foo()`. PHP just ignores whatever you return, and hands you your new instance of Foo. But if you call parent::__construct() from inside a constructor, you can get the return value from the parent constructor. I wouldn't though :) -- justin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ajai at bitblit.net Tue Jan 29 16:03:16 2013 From: ajai at bitblit.net (Ajai Khattri) Date: Tue, 29 Jan 2013 16:03:16 -0500 (EST) Subject: [nycphp-talk] Gearman Message-ID: Anybody here using Gearman with PHP ? Specifically I have a problem which I have been unable to resolve: when I start Gearman with my workers I get a "Failed to set option exception". And yes Ive Googled extensively on this error and gone through all the checks and solutions I could find. I am using the PECL extension (1.1.1) along with Gearmand 1.1.1 (so yeah, they're the same version which is supposed to fix the problem... :-) Any ideas? -- Aj. From klederson at klederson.com Tue Jan 29 16:37:18 2013 From: klederson at klederson.com (Klederson Bueno) Date: Tue, 29 Jan 2013 19:37:18 -0200 Subject: [nycphp-talk] Gearman In-Reply-To: References: Message-ID: Don't know your php version but you should install at least 1.1.3 ( latest is 1.1.4 ) to work in php 5.4 i had the same problem but solved in this way. Good Luck! -- /** * *PHP Architect/Consultant* * *@author* Klederson Bueno * *@see* http://www.phpburn.com * *@see* http://github.com/klederson * *@see* http://www.twitter.com/klederson * *@about *http://about.me/klederson */ On Tue, Jan 29, 2013 at 7:03 PM, Ajai Khattri wrote: > > Anybody here using Gearman with PHP ? > > Specifically I have a problem which I have been unable to resolve: when I > start Gearman with my workers I get a "Failed to set option exception". > > And yes Ive Googled extensively on this error and gone through all the > checks and solutions I could find. I am using the PECL extension (1.1.1) > along with Gearmand 1.1.1 (so yeah, they're the same version which is > supposed to fix the problem... :-) > > Any ideas? > > > -- > Aj. > > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ajai at bitblit.net Tue Jan 29 18:31:24 2013 From: ajai at bitblit.net (Ajai Khattri) Date: Tue, 29 Jan 2013 18:31:24 -0500 (EST) Subject: [nycphp-talk] Gearman In-Reply-To: Message-ID: On Tue, 29 Jan 2013, Klederson Bueno wrote: > Don't know your php version but you should install at least 1.1.3 ( latest > is 1.1.4 ) to work in php 5.4 i had the same problem but solved in this way. Im on 5.3. But the latest PECL extension is 1.1.1 which is supposed to be tied to the same version libgearman... -- Aj. From klederson at klederson.com Tue Jan 29 18:50:53 2013 From: klederson at klederson.com (Klederson Bueno) Date: Tue, 29 Jan 2013 21:50:53 -0200 Subject: [nycphp-talk] Gearman In-Reply-To: References: Message-ID: Once you install the new version you'll get the right libgearman linked. vagrant at dev:~$ php --info | grep gearman /etc/php5/cli/conf.d/20-gearman.ini, gearman gearman support => enabled libgearman version => 1.1.3 vagrant at dev:~$ -- /** * *PHP Architect/Consultant* * *@author* Klederson Bueno * *@see* http://www.phpburn.com * *@see* http://github.com/klederson * *@see* http://www.twitter.com/klederson * *@about *http://about.me/klederson */ On Tue, Jan 29, 2013 at 9:31 PM, Ajai Khattri wrote: > On Tue, 29 Jan 2013, Klederson Bueno wrote: > > > Don't know your php version but you should install at least 1.1.3 ( > latest > > is 1.1.4 ) to work in php 5.4 i had the same problem but solved in this > way. > > Im on 5.3. > > But the latest PECL extension is 1.1.1 which is supposed to be tied to the > same version libgearman... > > > -- > Aj. > > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ajai at bitblit.net Wed Jan 30 18:16:43 2013 From: ajai at bitblit.net (Ajai Khattri) Date: Wed, 30 Jan 2013 18:16:43 -0500 (EST) Subject: [nycphp-talk] Gearman In-Reply-To: Message-ID: On Tue, 29 Jan 2013, Klederson Bueno wrote: > Once you install the new version you'll get the right libgearman linked. So far Ive tested the PECL gearman (1.1.1) extension by building against v1.1.1, v1.1.3 and v1.1.4 of libgearman. All give me the same error whenever I try to run gearmand. -- Aj. From zaunere at gmail.com Wed Jan 30 19:22:37 2013 From: zaunere at gmail.com (Hans Z) Date: Wed, 30 Jan 2013 19:22:37 -0500 Subject: [nycphp-talk] Gearman In-Reply-To: References: Message-ID: >> Once you install the new version you'll get the right libgearman linked. > > So far Ive tested the PECL gearman (1.1.1) extension by building against > v1.1.1, v1.1.3 and v1.1.4 of libgearman. All give me the same error > whenever I try to run gearmand. It may not be pointing to the library you think it is - what's the error message? What's the log of the compile? H From klederson at klederson.com Wed Jan 30 21:54:50 2013 From: klederson at klederson.com (Klederson Bueno) Date: Thu, 31 Jan 2013 00:54:50 -0200 Subject: [nycphp-talk] Gearman In-Reply-To: References: Message-ID: Please let me know your steps to install it, php version, linux distro, etc... Maybe i can assemble a vagrant machine to test it here and reproduce your error. -- /** * *PHP Architect/Consultant* * *@author* Klederson Bueno * *@see* http://www.phpburn.com * *@see* http://github.com/klederson * *@see* http://www.twitter.com/klederson * *@about *http://about.me/klederson */ On Wed, Jan 30, 2013 at 10:22 PM, Hans Z wrote: > >> Once you install the new version you'll get the right libgearman linked. > > > > So far Ive tested the PECL gearman (1.1.1) extension by building against > > v1.1.1, v1.1.3 and v1.1.4 of libgearman. All give me the same error > > whenever I try to run gearmand. > > It may not be pointing to the library you think it is - what's the > error message? What's the log of the compile? > > H > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ajai at bitblit.net Thu Jan 31 11:37:09 2013 From: ajai at bitblit.net (Ajai Khattri) Date: Thu, 31 Jan 2013 11:37:09 -0500 (EST) Subject: [nycphp-talk] Gearman In-Reply-To: Message-ID: On Wed, 30 Jan 2013, Hans Z wrote: > It may not be pointing to the library you think it is - what's the > error message? What's the log of the compile? Actually, it is linked against the version I built from source: # ldd /usr/lib64/php/modules/gearman.so `/usr/lib64/php/modules/gearman.so' linux-vdso.so.1 => (0x00007fffe67ff000) libgearman.so.8 => /usr/local/lib/libgearman.so.8 (0x00007f60d84e2000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f60d82ce000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f60d80ca000) libc.so.6 => /lib64/libc.so.6 (0x00007f60d7d3a000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f60d7a33000) libm.so.6 => /lib64/libm.so.6 (0x00007f60d77af000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f60d7599000) /lib64/ld-linux-x86-64.so.2 (0x0000003516200000) # /usr/local/sbin/gearmand --version gearmand 1.1.4 - https://bugs.launchpad.net/gearmand -- Aj. From ajai at bitblit.net Thu Jan 31 11:43:48 2013 From: ajai at bitblit.net (Ajai Khattri) Date: Thu, 31 Jan 2013 11:43:48 -0500 (EST) Subject: [nycphp-talk] Gearman In-Reply-To: Message-ID: On Thu, 31 Jan 2013, Klederson Bueno wrote: > Please let me know your steps to install it, php version, linux distro, > etc... Im running on PHP 5.3.3 under CentOS 6.2. (Apache and PHP are both just the standard packages installed via YUM). Basic install steps: 1) Download and install Gearman 1.1.4, i.e. # cd /usr/local/src # wget "https://launchpad.net/gearmand/1.2/1.1.1/+download/gearmand-1.1.4.tar.gz" # tar -zxvf gearmand-1.1.4.tar.gz # cd gearman-1.1.4 # make -j 1 install 2) Install PECL extension # pecl install gearman (edit php.ini, add extension to PHP) 3) Restart Apache, i.e. # service httpd stop # service httpd start 4) Verify for CLI, i.e. # php -i | grep gearman gearman gearman support => enabled libgearman version => 1.1.4 -- Aj. From ajai at bitblit.net Thu Jan 31 11:49:06 2013 From: ajai at bitblit.net (Ajai Khattri) Date: Thu, 31 Jan 2013 11:49:06 -0500 (EST) Subject: [nycphp-talk] Gearman In-Reply-To: Message-ID: On Wed, 30 Jan 2013, Hans Z wrote: > It may not be pointing to the library you think it is - what's the > error message? What's the log of the compile? The error when running Gearman: Daemon started with PID 9875 (Daemon) Created worker number 1 with PID 9876 (Worker) Starting worker (Worker) Creating Gearman worker Failed to set exception option Failed to set exception option -- Aj.