| 1: | <?php | 
| 2: |  | 
| 3: |  | 
| 4: |  | 
| 5: |  | 
| 6: |  | 
| 7: |  | 
| 8: |  | 
| 9: |  | 
| 10: |  | 
| 11: |  | 
| 12: |  | 
| 13: |  | 
| 14: |  | 
| 15: |  | 
| 16: |  | 
| 17: |  | 
| 18: |  | 
| 19: |  | 
| 20: |  | 
| 21: |  | 
| 22: |  | 
| 23: |  | 
| 24: |  | 
| 25: |  | 
| 26: | namespace Kint\Parser; | 
| 27: |  | 
| 28: | use Kint\Object\BasicObject; | 
| 29: | use Kint\Object\Representation\Representation; | 
| 30: | use Kint\Object\ResourceObject; | 
| 31: | use Kint\Object\StreamObject; | 
| 32: |  | 
| 33: | class StreamPlugin extends Plugin | 
| 34: | { | 
| 35: | public function getTypes() | 
| 36: | { | 
| 37: | return array('resource'); | 
| 38: | } | 
| 39: |  | 
| 40: | public function getTriggers() | 
| 41: | { | 
| 42: | return Parser::TRIGGER_SUCCESS; | 
| 43: | } | 
| 44: |  | 
| 45: | public function parse(&$var, BasicObject &$o, $trigger) | 
| 46: | { | 
| 47: | if (!$o instanceof ResourceObject || 'stream' !== $o->resource_type) { | 
| 48: | return; | 
| 49: | } | 
| 50: |  | 
| 51: | if (!$meta = \stream_get_meta_data($var)) { | 
| 52: | return; | 
| 53: | } | 
| 54: |  | 
| 55: | $rep = new Representation('Stream'); | 
| 56: | $rep->implicit_label = true; | 
| 57: |  | 
| 58: | $base_obj = new BasicObject(); | 
| 59: | $base_obj->depth = $o->depth; | 
| 60: |  | 
| 61: | if ($o->access_path) { | 
| 62: | $base_obj->access_path = 'stream_get_meta_data('.$o->access_path.')'; | 
| 63: | } | 
| 64: |  | 
| 65: | $rep->contents = $this->parser->parse($meta, $base_obj); | 
| 66: |  | 
| 67: | if (!\in_array('depth_limit', $rep->contents->hints, true)) { | 
| 68: | $rep->contents = $rep->contents->value->contents; | 
| 69: | } | 
| 70: |  | 
| 71: | $o->addRepresentation($rep, 0); | 
| 72: | $o->value = $rep; | 
| 73: |  | 
| 74: | $stream = new StreamObject($meta); | 
| 75: | $stream->transplant($o); | 
| 76: | $o = $stream; | 
| 77: | } | 
| 78: | } | 
| 79: |  |