@param string $before
@param string $after

@return string[]
481794
private function diff(string $before, string $after): array
    {
        $diff = $this->differ->diffToArray(
            $before,
            $after
        );

        return \array_map(static function (array $element) {
            static $templates = [
                0 => ' %s',
                1 => '<fg=green>+%s</>',
                2 => '<fg=red>-%s</>',
            ];

            [$token, $status] = $element;

            $template = $templates[$status];

            return \sprintf(
                $template,
                $token
            );
        }, $diff);
    }
358422
public function listNotifications(bool $all = false, bool $participating = false, string $since = 'now',
                                      string $before = null): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/notifications?:args', http_build_query([
            'all'           => $all,
            'participating' => $participating,
            'since'         => (new DateTime($since))->format(DateTime::ATOM),
            'before'        => (new DateTime($before))->format(DateTime::ATOM)
        ])));
    }
811779
public function getRepliesTo(DataObject $to, $sortBy = 'ID', $since = 0, $before = false, $topLevelOnly = false, $tags = array(), $offset = 0, $number = 100) {
		$filter = array(
			'ParentID'			=> $to->ID, 
		);
		return $this->microPostList($filter, $sortBy, $since, $before, $topLevelOnly, $tags, $offset, $number);
	}
696065
public function getLastOccurrence($before_timestamp = null) {
		if ($before_timestamp === null) {
			$before_timestamp = time();
		}
		
		$before_timestamp = (int) $before_timestamp;
		
		$prev = false;
		if ($this->isRecurring()) {
			$starttimes = $this->getStartTimes($this->getStartTimestamp(), $before_timestamp);
			
			if ($starttimes) {
				$prev = end($starttimes);
			}
		}
		else {
			$prev = $this->getStartTimestamp();
			
			if ($prev > $before_timestamp) {
				$prev = false; // there is no occurrence before the timestamp
			}
		}
		
		return $prev;
	}
837243
protected function buildBeforeAfter(
        /*# string */ $beforeOrAfter,
        /*# string */ $position,
        array $settings
    )/*# : string */ {
        $clause = &$this->getClause($beforeOrAfter);
        if (isset($clause[$position])) {
            $line = $clause[$position];
            $sepr = $settings['seperator'];
            return $sepr . join($sepr, $line);
        } else {
            return '';
        }
    }
1150914
private function getRealLinesAfterLastUse(int $lastUseEndPos): array
    {
        $file = $this->getFile();
        $tokens = $file->getTokens();
        $whitespaceEnd = TokenHelper::findNextExcluding($file, T_WHITESPACE, $lastUseEndPos + 1) - 1;

        if ($lastUseEndPos !== $whitespaceEnd && $tokens[$whitespaceEnd]['content'] !== $file->eolChar) {
            $lastEolPos = TokenHelper::findPreviousContent(
                $file,
                T_WHITESPACE,
                $file->eolChar,
                $whitespaceEnd - 1,
                $lastUseEndPos
            );
            $whitespaceEnd = $lastEolPos ?? $lastUseEndPos;
        }

        $whitespaceAfterLastUse = TokenHelper::getContent($file, $lastUseEndPos + 1, $whitespaceEnd);

        $realLinesAfterUse = substr_count($whitespaceAfterLastUse, $file->eolChar) - 1;

        return [$realLinesAfterUse, $whitespaceEnd];
    }
1251778
public static function before($arr, $i) {
		$res = [];
		foreach($arr as $k=>$v) {
			if($k === $i)
				return $res;
			$res[$k] = $v;
		}
		return $res;
	}
754461
protected function buffer(&$buffer, $elements, $item, $after, $current)
    {
        foreach ($elements as $keyname => $element) {
            $found = last(explode('.', $after));
            if ($keyname == $found) {
                $buffer[$current][$keyname]  = $element;
                $buffer[$current][$item->id] = $item;
            } else {
                $buffer[$current][$keyname] = $element;
            }
        }
        return $buffer;
    }
87378
protected function resolveBefore($before)
    {
        $getBefore = $this->resolveMiddleware($before);

        return function (Request $request, Application $app) use ($getBefore) {
            $callback = $getBefore($request);
            if (!is_callable($callback)) {
                return null;
            }

            return $callback($request, $app);
        };
    }
1223577
public function getMiddlewares(string $type = self::BEFORE) : array
  {
    $type = self::validateMiddlewareType($type);
    return $this->middlewares[$type];
  }
294910
protected function getRecursiveSections($obj, $before = null)
    {
        if (!isset($obj->parts)) {
            return;
        }
        $countParts = count($obj->parts);
        $out = array();
        $beforeSave = $before;
        foreach ($obj->parts as $key => $subObj) {
            if (!isset($beforeSave)) {
                $before = ($key + 1);
            } else {
                $before = $beforeSave.'.'.($key + 1);
            }
            $this->getRecursiveSections($subObj, $before);
            $out[] = (string) $before;
        }
        $this->section[] = $out;
    }
603379
protected function prepNewItem($item, $_deps)
    {
        if ($item instanceof Dependable) {
            $_deps = $item->getDependencies();
            $item  = $item->getHandle();
        } elseif ($_deps instanceof Dependable) {
            $_deps = $_deps->getDependencies();
        }
        if (empty($_deps)) {
            $_deps = [];
        } elseif (is_string($_deps)) {
            $_deps = (array)preg_split('/,\s?/', $_deps);
        }

        return [$item, $_deps];
    }
32406
protected function createAfterFilter() {
    $after = $this->after;

    return function ($request, $response) use ($after) {
      foreach ($after as $filter) {
        $filter->onAfter($request, $response);
      }
    };
  }
331085
protected function lookInDeep(array $elements, $after, $item, &$buffer = [], &$return = '', $current = null)
    {
        $branch = array();

        foreach ($elements as $key => $element) {
            $return = strlen($return) <= 0 ? $current : $return . '.' . $current;
            if ($return . '.' . $key == $after) {
                $this->buffer($buffer, $elements, $item, $after, $current);
            }
            if ($element instanceof Fluent) {
                $element = $element->toArray();
            }
            if (!empty($element['childs'])) {
                $children = $this->lookInDeep($element['childs'], $after, $item, $buffer, $return, $key);
                if ($children) {
                    $element[$key]['childs'] = $children;
                }
            } else {
                $return = '';
            }

            $branch[$key] = $element;
        }

        return $branch;
    }
1055483
public function adopt($child, $before=false) {
		// adopt, or adopt before
		$this->content = $before ? $child . $this->content : $this->content . $child;
		// return self
		return($this);
	}
444586
private function getNotationCommonAspects($field, $before)
    {
        $aspects = [
            'Field'    => null,
            'Key'      => '',
            'Type'     => '',
            'Null'     => 'YES',
            'Extra'    => '',
            'Default'  => '',
            'Relation' => null,
        ];

        if (!is_null($field)) {
            $aspects['Field'] = $field;
        }

        if (!is_null($before)) {
            $aspects['First'] = !$before;
            $aspects['Before'] = $before;
        }

        return $aspects;
    }
123408
public function addKey($key, $after=null) {

        // Detect duplicates first
        if ($this->getKey($key->getName())) {
            throw new coding_exception('Duplicate key '.$key->getName().' specified in table '.$this->getName());
        }

        // Make sure there are no indexes with the key column specs because they would collide.
        $newfields = $key->getFields();
        $allindexes = $this->getIndexes();
        foreach ($allindexes as $index) {
            $fields = $index->getFields();
            if ($fields === $newfields) {
                throw new coding_exception('Index '.$index->getName().' collides with key'.$key->getName().' specified in table '.$this->getName());
            }
        }

        // Calculate the previous and next keys
        $prevkey = null;
        $nextkey = null;

        if (!$after) {
            $allkeys = $this->getKeys();
            if (!empty($allkeys)) {
                end($allkeys);
                $prevkey = $allkeys[key($allkeys)];
            }
        } else {
            $prevkey = $this->getKey($after);
        }
        if ($prevkey && $prevkey->getNext()) {
            $nextkey = $this->getKey($prevkey->getNext());
        }

        // Set current key previous and next attributes
        if ($prevkey) {
            $key->setPrevious($prevkey->getName());
            $prevkey->setNext($key->getName());
        }
        if ($nextkey) {
            $key->setNext($nextkey->getName());
            $nextkey->setPrevious($key->getName());
        }
        // Some more attributes
        $key->setLoaded(true);
        $key->setChanged(true);
        // Add the new key
        $this->keys[] = $key;
        // Reorder the keys
        $this->orderKeys($this->keys);
        // Recalculate the hash
        $this->calculateHash(true);
        // We have one new field, so the table has changed
        $this->setChanged(true);
    }