Skip to content

Commit f855002

Browse files
authored
Merge pull request #5 from nikic/is-resource
Don't use is_resource() for xml_parser resources
2 parents c9fc042 + 61ae89d commit f855002

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

XML/Parser.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ function setHandlerObj($obj)
273273
*/
274274
function _initHandlers()
275275
{
276-
if (!is_resource($this->parser)) {
276+
if (!$this->parser) {
277277
return false;
278278
}
279279

@@ -333,7 +333,7 @@ function _create()
333333
} else {
334334
$xp = @xml_parser_create($this->srcenc);
335335
}
336-
if (is_resource($xp)) {
336+
if ($xp) {
337337
if ($this->tgtenc !== null) {
338338
if (!@xml_parser_set_option($xp, XML_OPTION_TARGET_ENCODING,
339339
$this->tgtenc)
@@ -544,7 +544,7 @@ function _parseString($data, $eof = false)
544544
*/
545545
function parseString($data, $eof = false)
546546
{
547-
if (!isset($this->parser) || !is_resource($this->parser)) {
547+
if (!$this->parser) {
548548
$this->reset();
549549
}
550550

@@ -569,9 +569,9 @@ function parseString($data, $eof = false)
569569
**/
570570
function free()
571571
{
572-
if (isset($this->parser) && is_resource($this->parser)) {
572+
if ($this->parser) {
573573
xml_parser_free($this->parser);
574-
unset( $this->parser );
574+
$this->parser = null;
575575
}
576576
if (isset($this->fp) && is_resource($this->fp)) {
577577
fclose($this->fp);
@@ -734,7 +734,7 @@ class XML_Parser_Error extends PEAR_Error
734734
*/
735735
function __construct($msgorparser = 'unknown error', $code = 0, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE)
736736
{
737-
if (is_resource($msgorparser)) {
737+
if (!is_string($msgorparser)) {
738738
$code = xml_get_error_code($msgorparser);
739739
$msgorparser = sprintf('%s at XML input line %d:%d',
740740
xml_error_string($code),

0 commit comments

Comments
 (0)