php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79050 Levenshteins third argument not implemented and typed as string
Submitted: 2019-12-31 12:54 UTC Modified: 2021-01-01 16:14 UTC
From: php at conscribo dot nl Assigned: cmb (profile)
Status: Closed Package: Strings related
PHP Version: 7.3.13 OS: Debian
Private report: No CVE-ID: None
 [2019-12-31 12:54 UTC] php at conscribo dot nl
Description:
------------
---
From manual page: https://php.net/function.levenshtein
---

The documentation states that arguments 3 to 5 support weights for various actions. These are not implemented (not documented).

The documentation states the weights should be integers. Running with php strict_types reveals it only accepts strings.



Test script:
---------------
<?php
declare(strict_types=1);

$str1 = 'abc';
$str2 = 'abcd';

echo levenshtein($str1, $str2, 0);

//output:
//PHP Fatal error:  Uncaught TypeError: levenshtein() expects parameter 3 to be //string, integer given 

------
<?php
declare(strict_types=1);

$str1 = 'abc';
$str2 = 'abcd';

echo levenshtein($str1, $str2, '0');

//output:
// PHP Warning:  levenshtein(): The general Levenshtein support is not there yet




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-31 13:44 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: Documentation problem +Package: Strings related
 [2019-12-31 13:44 UTC] cmb@php.net
levenshtein() has actually three alternative signatures; the one
you're using in the test script is

  levenshtein(string $str1, string $str2, string $callback_name): int

but this signature is still not implemented (that's why you're
getting the warning).  Note that $callback_name is indeed a
string, not a callable.
 [2019-12-31 14:03 UTC] cmb@php.net
There is also the related feature request #34835.
 [2021-01-01 16:14 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-01-01 16:14 UTC] cmb@php.net
Support for the third signature is completely removed as of PHP
8.0.0, so it doesn't make sense to document that signature, just
to state that it is not implemented.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC