php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73899 mongodb\bson\fromphp namespace cassing deviation
Submitted: 2017-01-09 21:21 UTC Modified: 2021-02-15 13:22 UTC
From: raat1979 at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: mongodb (PECL)
PHP Version: 7.0.14 OS: linux (ubuntu)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: raat1979 at gmail dot com
New email:
PHP Version: OS:

 

 [2017-01-09 21:21 UTC] raat1979 at gmail dot com
Description:
------------
the casing of the mongodb functions is inconsistent with the MongoDB classes

I know php is not case sensitive when it comes comes to namespaces however comparing string does raise issues and mixing namespace casings like this does not seem like a good practice.

Test script:
---------------
<pre>
<?php

print_r(array_values(array_filter(get_declared_classes(),function($var){
    return strcasecmp(strstr($var,'\\',true) ,'mongodb') == 0;
})));

print_r(array_values(array_filter(get_defined_functions()['internal'],function($var){
    return strcasecmp(strstr($var,'\\',true) ,'mongodb') == 0;
})));
?>
</pre>

Expected result:
----------------
(the general opinion)

Array
(
    [0] => MongoDB\BSON\Binary
    [1] => MongoDB\BSON\Decimal128
  ...
    [31] => MongoDB\Driver\Exception\ExecutionTimeoutException
    [32] => MongoDB\Driver\Exception\ConnectionTimeoutException
)


Array
(
    [0] => MongoDB\BSON\fromphp
    [1] => MongoDB\BSON\tophp
    [2] => MongoDB\BSON\tojson
    [3] => MongoDB\BSON\fromjson
)

-- OR -- 

(personally I prefer camel-case/lower-case over studly-caps for namespaces (so you can see if its a namespace or class (in use statements for example)))

Array
(
    [0] => mongodb\bson\Binary
    [1] => mongodb\bson\Decimal128
  ...
    [31] => mongodb\driver\exception\ExecutionTimeoutException
    [32] => mongodb\driver\exception\ConnectionTimeoutException
)


Array
(
    [0] => mongodb\bson\fromphp
    [1] => mongodb\bson\tophp
    [2] => mongodb\bson\tojson
    [3] => mongodb\bson\fromjson
)


anyway I would expect them to match independent of the chosen casing

Actual result:
--------------

Array
(
    [0] => MongoDB\BSON\Binary
    [1] => MongoDB\BSON\Decimal128
  ...
    [31] => MongoDB\Driver\Exception\ExecutionTimeoutException
    [32] => MongoDB\Driver\Exception\ConnectionTimeoutException
)


Array
(
    [0] => mongodb\bson\fromphp
    [1] => mongodb\bson\tophp
    [2] => mongodb\bson\tojson
    [3] => mongodb\bson\fromjson
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-11 04:48 UTC] krakjoe@php.net
-Assigned To: +Assigned To: derick
 [2021-02-15 13:22 UTC] cmb@php.net
-Status: Assigned +Status: Not a bug -Assigned To: derick +Assigned To: cmb
 [2021-02-15 13:22 UTC] cmb@php.net
Please report MongoDB related issues in the appropriate bug
tracker[1].

[1] <https://jira.mongodb.org/browse/PHPC>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC