[PHP-DEV] Fatal error: Call to a member function on a non-object
Hej, I use PHP 5.2.6. I am refactoring some code to use more object-orientation. I encounter a problem, where the new object-oriented version results in a fatal error, where the old array-oriented version didn't. I fetch records a database. Sometime it happens that a record does not exist anymore. Let's assume it's a user, then $user will be NULL. echo $user['fullname']; // no error at all, $user['fullname'] === NULL Shouldn't this at least trigger a Notice? echo $user-get_fullname(); // Fatal error I agree this should trigger an error, but a Fatal error is a little too much, I think. It terminates the script leaving the html-document incomplete. I would prefer a Warning and NULL instead. Is there any reason against it? Best regards Christopher -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Fatal error: Call to a member function on a non-object
Hi 2008/11/17 Christopher Vogt [EMAIL PROTECTED]: Hej, I use PHP 5.2.6. I am refactoring some code to use more object-orientation. I encounter a problem, where the new object-oriented version results in a fatal error, where the old array-oriented version didn't. I fetch records a database. Sometime it happens that a record does not exist anymore. Let's assume it's a user, then $user will be NULL. echo $user['fullname']; // no error at all, $user['fullname'] === NULL Shouldn't this at least trigger a Notice? echo $user-get_fullname(); // Fatal error I agree this should trigger an error, but a Fatal error is a little too much, I think. It terminates the script leaving the html-document incomplete. I would prefer a Warning and NULL instead. Is there any reason against it? I personally don't really mind it, as you got the instanceof and typehinting to check for whenever a variable is an object, so I would say its more of a user design issue. Fatal errors just requires you to refactor your code so your code shouldn't emit such things which I'm alright with. Best regards Christopher -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- Kalle Sommer Nielsen -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] PHP 5 Bug Summary Report
PHP 5 Bug Database summary - http://bugs.php.net/ Num Status Summary (1204 total -- which includes 744 feature requests) ===[*General Issues]== 42294 To be documented round will not use PHP_ROUND_FUZZ on 64bit CPUs ===[*Math Functions]== 46587 Assigned mt_/rand produce out of range numbers when min = 0 and max get_randmax ===[Apache2 related]== 32220 Assigned [PATCH] thread_resources for thread not getting freed when apache kills thread 38141 Suspended $_SERVER['SCRIPT_NAME'] set incorrectly with mod_rewrite 42473 Open ob_start php://output and headers 46005 Open [PATCH] User not consistently logged under Apache2 46479 Open virtual() prints output to browser ===[Arrays related]=== 44182 Open extract($a, EXTR_REFS) can fail to split copy-on-write references 45126 Open array_merge_recursive() reference 46283 Feedback array_merge_recursive() Warning recursion detected in... ===[BC math related]== 44995 Open bcpowmod() using a scale function always returns 0 46564 Open bcmod( '1071', '357.5' ) returns '0' ===[Bzip2 Related] 29521 Assigned compress.bzip2 wrapper ===[Calendar related]= 40213 Suspended easter_date() returns wrong timestamp if ... 44474 Open GregorianToJD wrong return value ===[CGI related]== 43313 Assigned getopt doesn't handle unknown parameters. 44114 Assigned [PATH=] in php.ini on windows does not account for case-insensitive FS 44967 Assigned FastCGI broken in 5.2.6 NTS on IIS 45217 Open crash if -z and -m are used together 46305 Open Exception handler not invoked when using -r command line option 46366 Assigned bad cwd with / as pathinfo ===[Class/Object related]= 45199 Assigned Serializing objects with private properties 45281 Assigned each on objects shows private and protected properties 45331 Assigned Imagick::clone with trailing space results in ParserError 46140 Open Unserializing with __wakeup that removes child causes subsequent refs to shift ===[COM related]== 31327 Assigned chinese char and word problem 32099 Assigned After opening ADO connection and closing it repeatedly, Apache stops service 34253 Assigned COM binary object/array issue (question marks?) 35875 Assigned IE event failure upon scheduling script 36360 Assigned PHP crashes when accessing an object that was just create by parent object 36959 Assigned ReadRecords Method (Crystal Reports XI) Hangs 37562 Assigned Unable to lookup ParameterFieldDefinitions 37899 Assigned [PATCH] php_char_to _OLECHAR copies junk bytes 37965 Assigned Multi-dimensional array between PHP and COM 38719 Assigned COM Error during accessing function VirtualMachines 40424 Assigned Fatal error when setting the value of COM object's property array 40581 Assigned Pass Struct type to COM object from PHP 40664 Assigned String conversion functions wrong for multibyte chars 41055 Assigned DOTNET not instantiating fully-pathed assembly 41078 Assigned Its not possible to call Static dotNet Classes with dotnet 41189 Assigned Multi-dimensional array in COM function causes hang 41368 Assigned ADODB.Recordset ActiveConnection property - can't set with PHP 5.2.1+ 41388 Assigned Error in COM Object results 41577 Assigned DOTNET is successful once per server run 42413 Assigned Cannot iterate IE's event object 42551 Assigned new COM(HTMLFile) = warnings 42585 Assigned die() in event handler = PHP hangs 43275 Open get_class problem with COM objects 43432 Open Fatal error when setting the value of COM object's Attribute property 43470 Open COM API fails to correctly return [OUT] VT_PTR references 43506 Open com_get_active_object always fails 43521 Open Problem with Variant/Parameters 43838 Open variant_set with IE leads to hang 43897 Open $ie not cleared on IE quit 44256 Open Pb with COM in PHP5 44578 Open Strange Behavior of PHP using COM Object 45280 Open Reflection of instantiated COM classes causes PHP to crash. 45704 Open $exception-getCode() always return 0x80020009 even when it shouldn't 45855 Open COM-Problem with GET/SET, using same method name (but with different arg count) 46224 Open Cannot instantiate .Net object (ABCpdf 6.1 .Net) 46522 Open Problem using new com ===[Compile Failure]== 39372 Suspended
[PHP-DEV] Re: Fatal error: Call to a member function on a non-object
Hi. Christopher Vogt wrote: I fetch records a database. Sometime it happens that a record does not exist anymore. Let's assume it's a user, then $user will be NULL. echo $user['fullname']; // no error at all, $user['fullname'] === NULL Shouldn't this at least trigger a Notice? Check your error handling settings, probably warnings/notices are disabled. echo $user-get_fullname(); // Fatal error Well, is $user an object? If not, well, better not call a method on it. Regards, Karsten PS: I am not sure this is a topic for php.internals... -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Fatal error: Call to a member function on a non-object
Hi Kalle, I personally don't really mind it, as you got the instanceof and typehinting to check for whenever a variable is an object, so I would say its more of a user design issue. Fatal errors just requires you to refactor your code so your code shouldn't emit such things which I'm alright with. fatal error can also happen caused by a bug. The case described in my Mail is even rather likely. However a fatal error prevents me from handling the error using an error_handler. THAT is the problem. Best regards Christopher -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] PHP 6 Bug Summary Report
PHP 6 Bug Database summary - http://bugs.php.net/ Num Status Summary (66 total -- which includes 32 feature requests) ===[*General Issues]== 26771 Suspended register_tick_funtions crash under threaded webservers ===[Apache2 related]== 44083 Open virtual() not outputting results if zlib.output_compression = On ===[Arrays related]=== 35277 Suspended incorrect recursion detection 41758 Assigned SORT_LOCALE_STRING broken for sort() in PHP6 43109 Open array_intersect() emits unexpected no of notices when 2d array is passed as arg ===[Class/Object related]= 41461 Assigned E_STRICT notice when overriding methods not defined by an Interface in hierarchy ===[COM related]== 45836 Open cannot use com ===[Compile Failure]== 42606 Open unicode/constants.c relies on ICU draft api 44502 Suspended Compiling ok with MySQL 5.0 ===[Filesystem function related]== 42110 Open fgetcsv doesn't handle \n correctly in multiline csv record 44034 Open FILE_IGNORE_NEW_LINES in FILE does not work as expected when lines end in \r\n ===[GD related]=== 34670 Assigned imageTTFText for Indian scripts (Devanagari) 34992 Assigned imageconvolution does not respect alpha ===[I18N and L10N related] 42471 Open locale_set_default returns true on invalid locales ===[mbstring related]= 44868 Open Replaces UTF-8 symbol with incorrect symbol ===[MySQL related] 44076 Open mysql_result returns nothing with blob 45246 Open make error after ./configure --with-mysql ===[ODBC related]= 39756 Open Crashes in fetching resultsets with LONG ASCII columns from MaxDB ===[OpenSSL related]== 25614 Suspended openssl_pkey_get_public() fails when given a private key ===[Other web server]= 26495 Suspended Using WebSite Pro 2.5 with ISAPI, cookies are not working ===[PDO related]== 35368 Suspended PDO query does not work properly with serialize ===[Performance problem]== 42528 Open Out of char(8-bit) range value doesn't roll back, with uni-code ON. ===[Program Execution] 39992 Open proc_terminate() leaves children of child running 43784 Assigned escapeshellarg removes % from given string ===[Regexps related]== 44923 Open ereg functions are not unicode aware: provide wrapper functions in PCRE ===[Reproducible crash]=== 45107 Open setting ext_dir to ./ (and other ini settings) causes apache crash ===[Scripting Engine problem]= 42194 Open $argc/$argv[] won't work when .php extension is assigned to php.exe ===[Session related]== 44860 Open session_encode() fails for php_binary serializer ===[Strings related]== 44075 Verified strtok misbehaving 45566 Open Strict comparision on $_SERVER values fail ===[Unicode Engine related]=== 45087 Open Illegal or truncated character in input ===[URL related]== 45602 Open urlencode/urldecode should use ASCII encoding ===[XSLT related]= 38218 Assigned php:functionString tries to access objects with their names in lowercase ===[Zlib Related]= 30153 Suspended FATAL erealloc() error when using gzinflate() Assigned bugs and feature requests (reminders sent): andrei 41758: SORT_LOCALE_STRING broken for sort() in PHP6 helly 41461: E_STRICT notice when overriding methods not defined by an Interface in hierarchy dmitry 33487: Memory allocated for objects created in object methods is not released dmitry 41019: auto update feature for FastCGI for IIS pajoye 34670: imageTTFText for Indian scripts (Devanagari) pajoye
Re: [PHP-DEV] Fatal error: Call to a member function on a non-object
W liście Christopher Vogt z dnia poniedziałek 17 listopada 2008: I have a good understanding of OOP. This is not a start for me. I am just refactoring existing PHP code to be object-oriented. You say there are plenty of reasons for a Fatal error, so please tell me a few, so I understand the reasons. You're calling a method. This requires code execution, but the code isn't there. If you were accessing a property of non-existing object (that is, if you were doing $user-fullname;) then you'd get a warning and NULL. It's not so for functions, as they're request for code execution, not for value (remember, not all functions return values as they most important effect - it's not Haskell). Calling non-existing function returns in fatal error in PHP; it's the same for: $object-iHaveNoSuchMethod(); $null-method(); nosuchfunction(); -- Paweł Stradomski -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] CVS Account Request: magicaltux
On 16.11.2008, at 11:40, Mark Karpeles wrote: As most my [PATCH] mails sent to the internals mailing list were ignored (as of today, at least), I'm requesting an access to the PHP CVS, fully aware of what this means. My contributions (ordered by priority) would include: - The WDDX extension (http://bugs.php.net/46496) My fix for WDDX would allow closing the following forever-waiting bugs: http://bugs.php.net/45037 http://bugs.php.net/45314 I also intend later (and after some discussions, if anyone has any interest in WDDX) to add a feature to WDDX to provide the ability to stream a packet (create a packet ressource while providing a stream descriptor, send the XML code for the variables when added, then close the packet with an end of packet instruction). Providing the reverse process would also have to be done at the same time, using event-based xml parsing. This would allow memory-efficient creation of large packets. Andrei is the maintainer for the WDDX extension. Could you give Mark some feedback here? regards, Lukas Kahwe Smith [EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: Namespace resolution rules has been changed?
true, however i have a counter example: classes from more general namespace that use further nested classes (think some kind of behaviour and different drivers/plugins for example). so while it's true that more nested classes usually extend the less nested ones it also common for more generic code to use it's namespace descendants. in sutch condition possibility to use just the remaining namespace part is a big help and i'd say it's usage would be more comon than single extends at class definition where you're obligated to supply FQN [1]. The more generic code (i.e. application code) is located usually in its own namespace, so it must use FQN. FQN with leading backslash. DG. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: Namespace resolution rules has been changed?
Try to answer the question: what is the $obj instance of? namespace foo; $obj = $factory-loadClass('bar\class'); --- $factory is implemented cca this way: namespace ?; class Factory { function loadClass($class) { return new $class; } } With absolute FQN is the answer evident. With relative FQN it is very esoteric. With relative FQN developers will have to implement save loadClass() this way: function loadClass($class) { if (strpos($class, '\\') !== FALSE strncmp($class, '\\', 1)) { $class = '\\' . $class; } return new $class; } OMG David Grudl -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: Namespace resolution rules has been changed?
David Grudl wrote: Try to answer the question: what is the $obj instance of? namespace foo; $obj = $factory-loadClass('bar\class'); bar\class dynamic class names are always FQN. Greg -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] quick polls for 5.3 (sorry missed a couple votes, but they did not affect the results)
Lukas Kahwe Smith wrote: 7) should Output buffering rewrite MFH? this one comes with some baggage, we need enough people to actually have a look at how things are in HEAD and make it clear that they will be available for bug fixing and BC issues resolving. the risk here is obviously that any BC issues will be hard to isolate for end users. -1 Lukas -1 David +1 Hannes +0 Matt Wilson +0 Greg +0 Derick +1 Elizabeth +0 Lars -1 Stas for now Need more explanation why we need rewrite, what the rewrite does, etc. If there's a good reason and maintainer, then maybe +1. -1 Ilia +0.5 Steph I'd really like to see it in 5.3 because it was supposed to fix several OB issues, but it's probably too late in the cycle now +0 Scott +1 Kalle -1 David S.P. for now Need more explanation why we need rewrite, what the rewrite does, etc. If there's a good reason and maintainer, then maybe +1. -1 Rob +1 Pierre (if it creates non fixable issues during the alpha/RC phases, it can always be reverted. However the code is much cleaner and easier to maintain, if I can use the word easy for the OB code) +0 Arnaud Le Blanc +0 Larry Garfield +0 Lester Caine +0 Konstantin Leboev +1 Jani +0 Jonathan Bond-Caron +0 George Antoniadis +1 Felipe +1 Moriyoshi +0 Karsten Dambekalns +0 Alexey Zakhlestin +1 Guilherme Blanco +1 Marcus = no MFH, very unclear vote result and nobody that raised their hand to take responsibility (yes Pierre I know that you raised your hand on IRC) Hm... I'm still alive, but I feel blamed for not reading a mailing list which has become unmanageable to read. I wrote the code, so I'm probably responsible for it, too. And again, I was asked several times to back port it, so it can be included in 5.3--which doesn't mean I'm insisting on that matter, just to make it clear. I've still got some email addresses which--despite of spam--I am able to read and respond in a reasonable time span. Usually you can even hit me on IRC. Feel free to ask me any questions per mail or on IRC, but don't expect me to read a quadrillion of mails on [EMAIL PROTECTED] Cheers, Mike -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] a stupid question
Hi everybody, sorry this is a greenhand's stupid question. Why isn't 0.0 false? I know it is a string but I still think it equals to 0. Thanks ahead, green green~~ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] a stupid question
2008/11/17 Ting Chen [EMAIL PROTECTED]: Hi everybody, sorry this is a greenhand's stupid question. Why isn't 0.0 false? I know it is a string but I still think it equals to 0. I think you answered your own question there. Andrew -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] a stupid question
Andrew Rose wrote: 2008/11/17 Ting Chen [EMAIL PROTECTED]: Hi everybody, sorry this is a greenhand's stupid question. Why isn't 0.0 false? I know it is a string but I still think it equals to 0. I think you answered your own question there. Andrew What he means is that == is not transitive. That is, 0 == false 0 == 0.0 But false != 0.0 The answer to why is, well, that's the way it is. 0.0 just looks too much like a string, maybe, to be made into a boolean. You can just cast it into int like (int) 0.0 to make it work, however. Federico Lebron -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] a stupid question
i am recently studying Php5 manul. This is one of the examinations in the book. The answer is 0.0 is true rather than false. I am very curious about why if the answer is not wrong. green geen still green~ On 11/17/08, Andrew Rose [EMAIL PROTECTED] wrote: 2008/11/17 Ting Chen [EMAIL PROTECTED]: Hi everybody, sorry this is a greenhand's stupid question. Why isn't 0.0 false? I know it is a string but I still think it equals to 0. I think you answered your own question there. Andrew -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] a stupid question
maybe because 0 evaluating to false is already enough and everything after that would be forcing too much. If 0.0 evaluates to false then I would ask, why 0.0E1 doesn't ? What about 0.0E2 ? 0.0E10 ? etc. Just my opinion. regards, Igor. On Mon, Nov 17, 2008 at 11:22 AM, Ting Chen [EMAIL PROTECTED] wrote: i am recently studying Php5 manul. This is one of the examinations in the book. The answer is 0.0 is true rather than false. I am very curious about why if the answer is not wrong. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: Namespace resolution rules has been changed?
Zend_Acl == Zend_Acl_Resource_Interface, Zend_Acl_Role_Interface, Zend_Acl_Role_Registry, Zend_Acl_Assert_Registry... Regard, Stan Vassilev Stan, ZF doesn't use namespaces yet. This is not namespaced code. Namespaced code requires different convention (http://framework.zend.com/wiki/display/ZFPROP/Naming+conventions+for+2.0+-+Matthew+Ratzloff). In namespaced code there cannot be class Interface in namespace Zend\Acl\Role. There must be class RoleInterface in Zend\Acl namespace. Similary class Zend_Acl become Acl in Zend\Acl namespace. So look at the code with namespace-eyes. Classes Zend_Acl, Zend_Acl_Resource_Interface, Zend_Acl_Role_Interface... will exist in one namespace. I've checked that wiki page before, and I'm following with interest how they end up naming those, but that changes nothing. Today, Zend_Acl uses Zend_Acl_Resource_Interface. Tommorow, Zend\Acl uses Zend\Acl\ResourceInterface (or similar). The fact is, PHP frameworks and especially Zend use plenty of factories and facade classes, which by definition reach into inner-more classes and provide simplified paradigm to the outside world. The Interface and Exception classes won't stay like this, but they'll still be inside a subnamespace. Regards, Stan Vassilev -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] PostgreSQL pg_query_params, PHP locales, and double data types
Hi all, I'm trying to get a PHP bug in the PostgreSQL pg_query_params function reopened; it's been marked bogus (incorrectly IMO). There are lots of details at http://bugs.php.net/bug.php?id=46408. If this is in fact bogus, I'd appreciate a little bit of feedback. Many thanks! Alec Smecher Public Knowledge Project Team -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Re: Namespace resolution rules has been changed
I have downloaded last Mono source code (http://www.mono-project.com/, version 2.0.1), the open source version of one of the most complex and mature framework in the world, the .NET framework. Framework is written using namespaces (as opposite to current version of Zend). And I have analysed source codes. The results are: Directory /mcs/class/ Files: 11500 Namespace: 529 Class extends from more inner class: 4 Function accepting as arguments more inner classes: 0 Count of using clauses: - nested: 1031 - non-nested: 34673 (34 times more!) If you agree, that 34673 1031, please revert namespace behaviour back to alpha2. The 34times more developers will thank you ;) DG. p.s. if you'd like, I send you source code of analyzer. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] array_key_exists BC break
Felipe Pena wrote: So as suggested and wished, here is a patch that add a modifier '%' to 'a' in parameter parsing API, where it allows object that implements ArrayAccess to be accept. Although it doesn't invoke any their methods, i.e. just how it works nowdays. A list of functions that allow object on current 5.2: . end . prev . next . reset . current . key . array_key_exists . array_unique . array_flip . array_walk_recursive . array_walk . uksort . uasort . usort . natcasesort . natsort Hence, I added such modifier to this functions in the patch. 5.3: http://felipe.ath.cx/diff/arg_arrayaccess.diff It should probably be '#', because that modifier means 'alternate representation'. -Andrei -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] array_key_exists BC break
I meant '' actually. -Andrei -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PHP testsuite failures in Linux/ppc64
El sáb, 18-10-2008 a las 22:24 +0400, Antony Dovgal escribió: On 15.10.2008 22:36, Thiago Jung Bauermann wrote: This leaves me with the integer overflow failure and the array slice failure, but they seem to be very specific, and wouldn't normaly bite the PHP developer. Right. That said, we would still appreciate if you figure out the reasons of these test failures. Thank you very much for your opinion! I agree, will put this on my TODO list. (Sorry for the late response, BTW). -- []'s Thiago Jung Bauermann IBM Linux Technology Center -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php