php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60711 Ability to emit custom tags
Submitted: 2012-01-11 11:59 UTC Modified: 2012-03-13 04:47 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: alpacagm at gmail dot com Assigned: bd808 (profile)
Status: Closed Package: yaml (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alpacagm at gmail dot com
New email:
PHP Version: OS:

 

 [2012-01-11 11:59 UTC] alpacagm at gmail dot com
Description:
------------
Missed ability to emit tagged elements on yaml_emit.
see example as possible use-case solution

Test script:
---------------
class SampleClass {
   public $data;    // data may be in any pecl/yaml suitable type
   /**
    * Yaml emit callback function, referred on yaml_emit call by class name
    */
   public static function yamlEmit(SampleClass $obj){
      return array('tag'=>'!sample','data'=>$obj->data);
   }
}

$t=new SampleClass();
$t->data=array ('a','b','c');
$r=yaml_emit(array('our_val'=>$t),YAML_ANY_ENCODING,YAML_ANY_BREAK,
   array('SampleClass'=>array('SampleClass','yamlEmit')));
echo $r;

Expected result:
----------------
---
our_val: !sample
  - a
  - b
  - c


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-26 22:54 UTC] bd808@php.net
-Assigned To: +Assigned To: bd808
 [2012-02-27 07:52 UTC] bd808@php.net
Automatic comment from SVN on behalf of bd808
Revision: http://svn.php.net/viewvc/?view=revision&revision=323574
Log: Issue #60711: Support callbacks for object representation in emit.
 [2012-03-13 04:47 UTC] bd808@php.net
-Status: Assigned +Status: Closed
 [2012-03-13 04:47 UTC] bd808@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Feature added in Yaml 1.1.0. An RC1 build is available for testing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 14:01:29 2024 UTC