nikic / scalar_objects

Extension that adds support for method calls on primitive types in PHP
MIT License
1.13k stars 44 forks source link

Warning: Handler for type "string" already exists, overriding in /var/www/index.php on line 9 #5

Closed rsvasyliev closed 11 years ago

rsvasyliev commented 11 years ago

In CLI SAPI extension works fine, but under apache2 I get this message: Warning: Handler for type "string" already exists, overriding in /var/www/index.php on line 9

Code what I run:

<?php

class StringHandler {
    public function length() {
        return strlen($this);
    }
}

register_primitive_type_handler('string', 'StringHandler');

$str = "hello";
var_dump($str->length());

This bug doesn't appear when I load page first time, but further attempts throw warning. When I change any line of code, page shows normally again.

Sorry for my bad English.

nikic commented 11 years ago

Thanks, fixed in https://github.com/nikic/scalar_objects/commit/78b2d26fd3f869b51424d3438ee9330c0f547e76 :)