davideme / libphonenumber-for-PHP

PHP version of Google's phone number handling library
125 stars 71 forks source link

PhoneNumberUtil.php fails to recognize extensions #14

Open Nephele opened 11 years ago

Nephele commented 11 years ago

If PhoneNumberUtil is asked to parse a number containing an extension, it fails to recognize the extension for nearly all extension formats ('x', 'ext.', '#', etc.).

The problem is that the initialization functions in getInstance() are called in the wrong order. self::initCapturingExtnDigits() needs to be called before self::initExtnPatterns(). Otherwise the extension patterns are created using a blank value for self::$CAPTURING_EXTN_DIGITS, i.e., the part of the pattern that is supposed to match the extension number is missing.

One of the attached commits fixes this issue. The other commit incorporates several bug fixes previously posted by resscode.

dcbarans commented 11 years ago

I would love to see this get into the library