php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #81334 Rename imagettfbbox/text string/text parameter
Submitted: 2021-08-06 08:46 UTC Modified: 2025-01-05 13:40 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: admin at kapsonfire dot de Assigned: cmb (profile)
Status: Wont fix Package: GD related
PHP Version: 8.0.9 OS: -
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: admin at kapsonfire dot de
New email:
PHP Version: OS:

 

 [2021-08-06 08:46 UTC] admin at kapsonfire dot de
Description:
------------
Since PHP supports spreading named parameters, i'd like to see 
imagettfbbox and imagettftext using the same paramater names.

imagettfbbox uses $string for the text
imagettfbbox uses $text   for the text



Test script:
---------------
<?php
//header("Content-Type: image/png");
$im = @imagecreate(200, 200)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 50, 50, 200);
$text_color = imagecolorallocate($im, 255,255,255);

$fontConfig = [
    'size' => 75,
    'angle' => 0,
    'font_filename' => "Roboto-Regular.ttf",
    'string'    => 'PA',
];

$bb = imagettfbbox(...$fontConfig);
$w = $bb[2] - $bb[0];
$h = $bb[3] - $bb[1];
imagettftext(...([
        'image' => $im,
        'color' => $text_color,
        'x' => (100-$w/2),
        'y' => (100-$h/2),

             ]+$fontConfig));

imagepng($im);
imagedestroy($im);

Expected result:
----------------
No Error

Actual result:
--------------
Fatal error: Uncaught Error: Unknown named parameter $string in image.php:24

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-06 08:47 UTC] admin at kapsonfire dot de
sorry, misswrote
imagettfbbox uses $string for the text
imagettftext uses $text   for the text
 [2021-08-06 08:55 UTC] cmb@php.net
-Summary: - +Summary: Rename imagettfbbox/text string/text parameter
 [2021-08-06 08:55 UTC] cmb@php.net
Oh, that's indeed unfortunate.  I'm not sure whether we still
can change that in a minor version for BC reasons.
 [2025-01-05 13:40 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2025-01-05 13:40 UTC] cmb@php.net
Well, that ship has sailed.  I'm closing this, since changing the
parameter name now would likely do more harm than good.  If you,
or anybody else still would prefer to change the name for PHP 9
(where such BC break might be okay), please open a ticket on
Github.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Feb 10 14:01:30 2025 UTC