
Hi, To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve? Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php. This code works fine in PHP4. -- Regards, Brian Ngure

Hi Brian, I have to admit, I have never encountered that.. I have tried to figure it out but cant.. but came across this link, http://www.pear-forum.org/topic1627.html. hope it helps -Alex On Tue, Sep 15, 2009 at 3:37 PM, Brian Ngure < brian@mystique.boldlygoingnowhere.org> wrote:
Hi,
To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve?
Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context
The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php.
This code works fine in PHP4.
-- Regards,
Brian Ngure _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Am staying informed, and earning from it @ www.jumuika.co.ke

Hi Alex, I had already tried that. Did not work. Thanks anyway. On Tue, Sep 15, 2009 at 4:38 PM, Alex Wanjohi <wanjohialex@gmail.com> wrote:
Hi Brian,
I have to admit, I have never encountered that.. I have tried to figure it out but cant.. but came across this link, http://www.pear-forum.org/topic1627.html. hope it helps
-Alex
On Tue, Sep 15, 2009 at 3:37 PM, Brian Ngure <brian@mystique.boldlygoingnowhere.org> wrote:
Hi,
To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve?
Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context
The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php.
This code works fine in PHP4.
-- Regards,
Brian Ngure _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Am staying informed, and earning from it @ www.jumuika.co.ke
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Regards, Brian Ngure

Try create an instance of Mail like so myMail=new Mail(); myMail->factory(); ..... alternatively if you have the source for mail class, add public static to the factory definition like public static function factory() ..... Regards, Oj The optimist sees the doughnut; the pessimist the hole. --- On Tue, 9/15/09, Brian Ngure <brian@mystique.boldlygoingnowhere.org> wrote: From: Brian Ngure <brian@mystique.boldlygoingnowhere.org> Subject: Re: [Skunkworks] PHP Pear Problem To: "Skunkworks forum" <skunkworks@lists.my.co.ke> Date: Tuesday, September 15, 2009, 6:45 AM Hi Alex, I had already tried that. Did not work. Thanks anyway. On Tue, Sep 15, 2009 at 4:38 PM, Alex Wanjohi <wanjohialex@gmail.com> wrote:
Hi Brian,
I have to admit, I have never encountered that.. I have tried to figure it out but cant.. but came across this link, http://www.pear-forum.org/topic1627.html. hope it helps
-Alex
On Tue, Sep 15, 2009 at 3:37 PM, Brian Ngure <brian@mystique.boldlygoingnowhere.org> wrote:
Hi,
To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve?
Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context
The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php.
This code works fine in PHP4.
-- Regards,
Brian Ngure _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Am staying informed, and earning from it @ www.jumuika.co.ke
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Regards, Brian Ngure _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general

Hi Oj, I did try that but just came up with another error message. Don't remember exactly what it was now. That's why I decided to write my own implementation. Thanks for your input. On Sat, Sep 19, 2009 at 7:03 PM, Oj G <ojiwaj@yahoo.com> wrote:
Try create an instance of Mail like so
myMail=new Mail(); myMail->factory();
.....
alternatively if you have the source for mail class, add
public static to the factory definition
like
public static function factory()
.....
Regards, Oj
The optimist sees the doughnut; the pessimist the hole.
--- On *Tue, 9/15/09, Brian Ngure <brian@mystique.boldlygoingnowhere.org>*wrote:
From: Brian Ngure <brian@mystique.boldlygoingnowhere.org> Subject: Re: [Skunkworks] PHP Pear Problem To: "Skunkworks forum" <skunkworks@lists.my.co.ke> Date: Tuesday, September 15, 2009, 6:45 AM
Hi Alex,
I had already tried that. Did not work. Thanks anyway.
On Tue, Sep 15, 2009 at 4:38 PM, Alex Wanjohi <wanjohialex@gmail.com<http://mc/compose?to=wanjohialex@gmail.com>> wrote:
Hi Brian,
I have to admit, I have never encountered that.. I have tried to figure it out but cant.. but came across this link, http://www.pear-forum.org/topic1627.html. hope it helps
-Alex
On Tue, Sep 15, 2009 at 3:37 PM, Brian Ngure <brian@mystique.boldlygoingnowhere.org<http://mc/compose?to=brian@mystique.boldlygoingnowhere.org>> wrote:
Hi,
To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve?
Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context
The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php.
This code works fine in PHP4.
-- Regards,
Brian Ngure _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke<http://mc/compose?to=Skunkworks@lists.my.co.ke> http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Am staying informed, and earning from it @ www.jumuika.co.ke
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke<http://mc/compose?to=Skunkworks@lists.my.co.ke> http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Regards,
Brian Ngure _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke <http://mc/compose?to=Skunkworks@lists.my.co.ke> http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Regards, Brian Ngure

Brian welcome, Your class extending the Mail class that's a cool idea...enjoy coding :-) Regards, Oj The optimist sees the doughnut; the pessimist the hole. --- On Mon, 9/21/09, Brian Ngure <brian@mystique.boldlygoingnowhere.org> wrote: From: Brian Ngure <brian@mystique.boldlygoingnowhere.org> Subject: Re: [Skunkworks] PHP Pear Problem To: "Skunkworks Forum" <skunkworks@lists.my.co.ke> Date: Monday, September 21, 2009, 10:34 AM Hi Oj, I did try that but just came up with another error message. Don't remember exactly what it was now. That's why I decided to write my own implementation. Thanks for your input. On Sat, Sep 19, 2009 at 7:03 PM, Oj G <ojiwaj@yahoo.com> wrote: Try create an instance of Mail like so myMail=new Mail(); myMail->factory(); ..... alternatively if you have the source for mail class, add public static to the factory definition like public static function factory() ..... Regards, Oj The optimist sees the doughnut; the pessimist the hole. --- On Tue, 9/15/09, Brian Ngure <brian@mystique.boldlygoingnowhere.org> wrote: From: Brian Ngure <brian@mystique.boldlygoingnowhere.org> Subject: Re: [Skunkworks] PHP Pear Problem To: "Skunkworks forum" <skunkworks@lists.my.co.ke> Date: Tuesday, September 15, 2009, 6:45 AM Hi Alex, I had already tried that. Did not work. Thanks anyway. On Tue, Sep 15, 2009 at 4:38 PM, Alex Wanjohi <wanjohialex@gmail.com> wrote:
Hi Brian,
I have to admit, I have never encountered that.. I have tried to figure it out but cant.. but came across this link, http://www.pear-forum.org/topic1627.html.
hope it helps
-Alex
On Tue, Sep 15, 2009 at 3:37 PM, Brian Ngure <brian@mystique.boldlygoingnowhere.org> wrote:
Hi,
To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve?
Non-static method Mail::factory() should not be called statically,
assuming $this from incompatible context
The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php.
This code works fine in PHP4.
-- Regards,
Brian Ngure _______________________________________________ Skunkworks mailing list
Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce
Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Am staying informed, and earning from it @ www.jumuika.co.ke
_______________________________________________
Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce
Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Regards, Brian Ngure _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general -- Regards, Brian Ngure -----Inline Attachment Follows----- _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general

Hi Brian (and other skunks), *Short answer:* Upgrade to a more recent version of PEAR::Mail - namely a version higher than 1.1.7 in the version 1.1.7 change-log it states that they specifically fixed this issue: - Mail::factory() now returns object references without generating PHP warnings. See: http://pear.php.net/package/Mail/download/1.1.7 *Long answer:* I have not checked the code - but looking at the error message it seems as if they are accessing another static function/attribute from within the static factory function - however they are using the old/wrong way of doing this ( this::attributename ) instead of ( self::attributename ) In short the version of the code you are using have not been fixed (fully) to run with PHP5 Regards Michael Pedersen Brian Ngure wrote:
Hi,
To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve?
Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context
The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php.
This code works fine in PHP4.

Hi Michael, The version of Pear::Mail I was using was 1.1.14. I also tried updating to the latest beta version 1.2.0b2 but I still got the same error. I will try update my php version to the latest as well and see if that helps. Thanks. On Tue, Sep 15, 2009 at 5:44 PM, Michael Pedersen <sku@kaal.dk> wrote:
Hi Brian (and other skunks),
*Short answer:*
Upgrade to a more recent version of PEAR::Mail - namely a version higher than 1.1.7 in the version 1.1.7 change-log it states that they specifically fixed this issue:
- Mail::factory() now returns object references without generating PHP warnings.
See: http://pear.php.net/package/Mail/download/1.1.7
*Long answer:*
I have not checked the code - but looking at the error message it seems as if they are accessing another static function/attribute from within the static factory function - however they are using the old/wrong way of doing this ( this::attributename ) instead of ( self::attributename )
In short the version of the code you are using have not been fixed (fully) to run with PHP5
Regards Michael Pedersen
Brian Ngure wrote:
Hi,
To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve?
Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context
The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php.
This code works fine in PHP4.
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Regards, Brian Ngure

Hi Brian, Ok I looked at the problem in more details. *Short answer:* The warning is a strict warning indicating that you are calling a method as if it is a static method but the method is not declared static (despite what the documentation indicates). *Long answer:* Its small bug/glitch/feature in the implementation of the of the factory method - to be specific in the Mail.php the following line: function &factory($driver, $params = array()) should read: static function &factory($driver, $params = array()) By adding this "static" keyword the STRICT warning will disapear. I do not really think it is a bug but instead it is a feature - I believe they left out the static keyword since it was only introduced in PHP5, by not using they keyword they make the PEAR::Mail class compatible with PHP4 aswell - at the cost of getting a very small insignificant warning. Full details - I created the following test program: <?php error_reporting(E_STRICT); include "Mail/Mail-1.1.14/Mail.php"; $mail = Mail::factory("sendmail", array()); print "hello world"; ?> And was fully able to recreate the problem - i was using PEAR version 1.9 PEAR::Mail version 1.1.14 PHP version 5.2.10 I hope this helps. Regards Michael Pedersen Brian Ngure wrote:
Hi Michael,
The version of Pear::Mail I was using was 1.1.14. I also tried updating to the latest beta version 1.2.0b2 but I still got the same error. I will try update my php version to the latest as well and see if that helps. Thanks.
On Tue, Sep 15, 2009 at 5:44 PM, Michael Pedersen <sku@kaal.dk> wrote:
Hi Brian (and other skunks),
*Short answer:*
Upgrade to a more recent version of PEAR::Mail - namely a version higher than 1.1.7 in the version 1.1.7 change-log it states that they specifically fixed this issue:
- Mail::factory() now returns object references without generating PHP warnings.
See: http://pear.php.net/package/Mail/download/1.1.7
*Long answer:*
I have not checked the code - but looking at the error message it seems as if they are accessing another static function/attribute from within the static factory function - however they are using the old/wrong way of doing this ( this::attributename ) instead of ( self::attributename )
In short the version of the code you are using have not been fixed (fully) to run with PHP5
Regards Michael Pedersen
Brian Ngure wrote:
Hi,
To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve?
Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context
The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php.
This code works fine in PHP4.

Hi Michael, Thanks. That helps. I kind of came to same conclusion about the backwards compatibility with PHP4. I have decided to implement my version of Pear::Mail to overcome this. Many thanks for your input. On Wed, Sep 16, 2009 at 12:45 PM, Michael Pedersen <sku@kaal.dk> wrote:
Hi Brian,
Ok I looked at the problem in more details.
Short answer: The warning is a strict warning indicating that you are calling a method as if it is a static method but the method is not declared static (despite what the documentation indicates).
Long answer: Its small bug/glitch/feature in the implementation of the of the factory method - to be specific in the Mail.php the following line:
function &factory($driver, $params = array())
should read:
static function &factory($driver, $params = array())
By adding this "static" keyword the STRICT warning will disapear.
I do not really think it is a bug but instead it is a feature - I believe they left out the static keyword since it was only introduced in PHP5, by not using they keyword they make the PEAR::Mail class compatible with PHP4 aswell - at the cost of getting a very small insignificant warning.
Full details - I created the following test program: <?php error_reporting(E_STRICT); include "Mail/Mail-1.1.14/Mail.php";
$mail = Mail::factory("sendmail", array());
print "hello world";
?>
And was fully able to recreate the problem - i was using PEAR version 1.9 PEAR::Mail version 1.1.14 PHP version 5.2.10
I hope this helps.
Regards Michael Pedersen
Brian Ngure wrote:
Hi Michael,
The version of Pear::Mail I was using was 1.1.14. I also tried updating to the latest beta version 1.2.0b2 but I still got the same error. I will try update my php version to the latest as well and see if that helps. Thanks.
On Tue, Sep 15, 2009 at 5:44 PM, Michael Pedersen <sku@kaal.dk> wrote:
Hi Brian (and other skunks),
*Short answer:*
Upgrade to a more recent version of PEAR::Mail - namely a version higher than 1.1.7 in the version 1.1.7 change-log it states that they specifically fixed this issue:
- Mail::factory() now returns object references without generating PHP warnings.
See: http://pear.php.net/package/Mail/download/1.1.7
*Long answer:*
I have not checked the code - but looking at the error message it seems as if they are accessing another static function/attribute from within the static factory function - however they are using the old/wrong way of doing this ( this::attributename ) instead of ( self::attributename )
In short the version of the code you are using have not been fixed (fully) to run with PHP5
Regards Michael Pedersen
Brian Ngure wrote:
Hi,
To any PHP/Pear gurus. I am getting the following error in PHP5. Anyone know how to resolve?
Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context
The method factory is static as noted here: http://pear.php.net/manual/en/package.mail.mail.factory.php.
This code works fine in PHP4.
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
-- Regards, Brian Ngure
participants (4)
-
Alex Wanjohi
-
Brian Ngure
-
Michael Pedersen
-
Oj G