comparison vendor/psy/psysh/src/Output/ShellOutput.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 5fb285c0d0e3
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
39 39
40 $this->initFormatters(); 40 $this->initFormatters();
41 41
42 if ($pager === null) { 42 if ($pager === null) {
43 $this->pager = new PassthruPager($this); 43 $this->pager = new PassthruPager($this);
44 } elseif (is_string($pager)) { 44 } elseif (\is_string($pager)) {
45 $this->pager = new ProcOutputPager($this, $pager); 45 $this->pager = new ProcOutputPager($this, $pager);
46 } elseif ($pager instanceof OutputPager) { 46 } elseif ($pager instanceof OutputPager) {
47 $this->pager = $pager; 47 $this->pager = $pager;
48 } else { 48 } else {
49 throw new \InvalidArgumentException('Unexpected pager parameter: ' . $pager); 49 throw new \InvalidArgumentException('Unexpected pager parameter: ' . $pager);
63 * @param string|array|\Closure $messages A string, array of strings or a callback 63 * @param string|array|\Closure $messages A string, array of strings or a callback
64 * @param int $type (default: 0) 64 * @param int $type (default: 0)
65 */ 65 */
66 public function page($messages, $type = 0) 66 public function page($messages, $type = 0)
67 { 67 {
68 if (is_string($messages)) { 68 if (\is_string($messages)) {
69 $messages = (array) $messages; 69 $messages = (array) $messages;
70 } 70 }
71 71
72 if (!is_array($messages) && !is_callable($messages)) { 72 if (!\is_array($messages) && !\is_callable($messages)) {
73 throw new \InvalidArgumentException('Paged output requires a string, array or callback'); 73 throw new \InvalidArgumentException('Paged output requires a string, array or callback');
74 } 74 }
75 75
76 $this->startPaging(); 76 $this->startPaging();
77 77
78 if (is_callable($messages)) { 78 if (\is_callable($messages)) {
79 $messages($this); 79 $messages($this);
80 } else { 80 } else {
81 $this->write($messages, true, $type); 81 $this->write($messages, true, $type);
82 } 82 }
83 83
120 } 120 }
121 121
122 $messages = (array) $messages; 122 $messages = (array) $messages;
123 123
124 if ($type & self::NUMBER_LINES) { 124 if ($type & self::NUMBER_LINES) {
125 $pad = strlen((string) count($messages)); 125 $pad = \strlen((string) \count($messages));
126 $template = $this->isDecorated() ? "<aside>%{$pad}s</aside>: %s" : "%{$pad}s: %s"; 126 $template = $this->isDecorated() ? "<aside>%{$pad}s</aside>: %s" : "%{$pad}s: %s";
127 127
128 if ($type & self::OUTPUT_RAW) { 128 if ($type & self::OUTPUT_RAW) {
129 $messages = array_map(['Symfony\Component\Console\Formatter\OutputFormatter', 'escape'], $messages); 129 $messages = \array_map(['Symfony\Component\Console\Formatter\OutputFormatter', 'escape'], $messages);
130 } 130 }
131 131
132 foreach ($messages as $i => $line) { 132 foreach ($messages as $i => $line) {
133 $messages[$i] = sprintf($template, $i, $line); 133 $messages[$i] = \sprintf($template, $i, $line);
134 } 134 }
135 135
136 // clean this up for super. 136 // clean this up for super.
137 $type = $type & ~self::NUMBER_LINES & ~self::OUTPUT_RAW; 137 $type = $type & ~self::NUMBER_LINES & ~self::OUTPUT_RAW;
138 } 138 }