Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/CallRerouting.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ function getInstantiator($class, $calledClass)

class State
{
static $routes = [];
static $queue = [];
static $preprocessedFiles = [];
static $routeStack = [];
public static $routes = [];
public static $queue = [];
public static $preprocessedFiles = [];
public static $routeStack = [];
}
8 changes: 4 additions & 4 deletions src/CodeManipulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ function onImport($listeners)

class State
{
static $actions = [];
static $importListeners = [];
static $cacheIndex = [];
static $cacheIndexFile;
public static $actions = [];
public static $importListeners = [];
public static $cacheIndex = [];
public static $cacheIndexFile;
}
2 changes: 1 addition & 1 deletion src/CodeManipulation/Actions/RedefinitionOfNew.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,5 @@ function suspendFor(callable $function)

class State
{
static $enabled = true;
public static $enabled = true;
}
54 changes: 27 additions & 27 deletions src/CodeManipulation/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

class Source
{
const TYPE_OFFSET = 0;
const STRING_OFFSET = 1;
public const TYPE_OFFSET = 0;
public const STRING_OFFSET = 1;

const PREPEND = 'PREPEND';
const APPEND = 'APPEND';
const OVERWRITE = 'OVERWRITE';
public const PREPEND = 'PREPEND';
public const APPEND = 'APPEND';
public const OVERWRITE = 'OVERWRITE';

const ANY = null;
public const ANY = null;

public $tokens;
public $tokensByType;
Expand All @@ -37,13 +37,13 @@ class Source
public $tokensByLevelAndType;
public $cache;

function __construct($string)
public function __construct($string)
{
$this->code = $string;
$this->initialize();
}

function initialize()
public function initialize()
{
$this->tokens = Utils\tokenize($this->code);
$this->tokens[] = [T_WHITESPACE, ""];
Expand All @@ -55,15 +55,15 @@ function initialize()
$this->cache = [];
}

function indexTokensByType()
public function indexTokensByType()
{
$this->tokensByType = [];
foreach ($this->tokens as $offset => $token) {
$this->tokensByType[$token[self::TYPE_OFFSET]][] = $offset;
}
}

function collectBracketMatchings()
public function collectBracketMatchings()
{
$this->matchingBrackets = [];
$stack = [];
Expand All @@ -89,7 +89,7 @@ function collectBracketMatchings()
}
}

function collectLevelInfo()
public function collectLevelInfo()
{
$level = 0;
$this->levels = [];
Expand Down Expand Up @@ -123,7 +123,7 @@ function collectLevelInfo()
Utils\appendUnder($this->levelEndings, 0, count($this->tokens) - 1);
}

function has($types)
public function has($types)
{
foreach ((array) $types as $type) {
if ($this->all($type) !== []) {
Expand All @@ -133,7 +133,7 @@ function has($types)
return false;
}

function is($types, $offset)
public function is($types, $offset)
{
foreach ((array) $types as $type) {
if ($this->tokens[$offset][self::TYPE_OFFSET] === $type) {
Expand All @@ -143,7 +143,7 @@ function is($types, $offset)
return false;
}

function skip($types, $offset, $direction = 1)
public function skip($types, $offset, $direction = 1)
{
$offset += $direction;
$types = (array) $types;
Expand All @@ -156,12 +156,12 @@ function skip($types, $offset, $direction = 1)
return ($direction > 0) ? INF : -1;
}

function skipBack($types, $offset)
public function skipBack($types, $offset)
{
return $this->skip($types, $offset, -1);
}

function within($types, $low, $high)
public function within($types, $low, $high)
{
$result = [];
foreach ((array) $types as $type) {
Expand All @@ -171,7 +171,7 @@ function within($types, $low, $high)
return $result;
}

function read($offset, $count = 1)
public function read($offset, $count = 1)
{
$result = '';
$pos = $offset;
Expand All @@ -186,7 +186,7 @@ function read($offset, $count = 1)
return $result;
}

function siblings($types, $offset)
public function siblings($types, $offset)
{
$level = $this->levels[$offset];
$begin = Utils\lastNotGreaterThan(Utils\access($this->levelBeginnings, $level, []), $offset);
Expand All @@ -203,7 +203,7 @@ function siblings($types, $offset)
}
}

function next($types, $offset)
public function next($types, $offset)
{
if (!is_array($types)) {
$candidates = Utils\access($this->tokensByType, $types, []);
Expand All @@ -216,7 +216,7 @@ function next($types, $offset)
return $result;
}

function all($types)
public function all($types)
{
if (!is_array($types)) {
return Utils\access($this->tokensByType, $types, []);
Expand All @@ -229,13 +229,13 @@ function all($types)
return $result;
}

function match($offset)
public function match($offset)
{
$offset = (string) $offset;
return isset($this->matchingBrackets[$offset]) ? $this->matchingBrackets[$offset] : INF;
}

function splice($splice, $offset, $length = 0, $policy = self::OVERWRITE)
public function splice($splice, $offset, $length = 0, $policy = self::OVERWRITE)
{
if ($policy === self::OVERWRITE) {
$this->splices[$offset] = $splice;
Expand All @@ -256,7 +256,7 @@ function splice($splice, $offset, $length = 0, $policy = self::OVERWRITE)
$this->code = null;
}

function createCodeFromTokens()
public function createCodeFromTokens()
{
$splices = $this->splices;
$code = "";
Expand All @@ -274,28 +274,28 @@ function createCodeFromTokens()
$this->code = $code;
}

static function junk()
public static function junk()
{
return [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT];
}

function __toString()
public function __toString()
{
if ($this->code === null) {
$this->createCodeFromTokens();
}
return (string) $this->code;
}

function flush()
public function flush()
{
$this->initialize(Utils\tokenize($this));
}

/**
* @since 2.1.0
*/
function cache(array $args, \Closure $function)
public function cache(array $args, \Closure $function)
{
$found = true;
$trace = debug_backtrace()[1];
Expand Down
6 changes: 3 additions & 3 deletions src/CodeManipulation/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class Stream
{
const STREAM_OPEN_FOR_INCLUDE = 128;
const STAT_MTIME_NUMERIC_OFFSET = 9;
const STAT_MTIME_ASSOC_OFFSET = 'mtime';
public const STREAM_OPEN_FOR_INCLUDE = 128;
public const STAT_MTIME_NUMERIC_OFFSET = 9;
public const STAT_MTIME_ASSOC_OFFSET = 'mtime';

protected static $protocols = ['file', 'phar'];
protected static $otherWrapperClass;
Expand Down
14 changes: 7 additions & 7 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ function getTimestamp()

class State
{
static $blacklist = [];
static $whitelist = [];
static $cachePath;
static $redefinableInternals = [];
static $redefinableLanguageConstructs = [];
static $newKeywordRedefinable = false;
static $timestamp = 0;
public static $blacklist = [];
public static $whitelist = [];
public static $cachePath;
public static $redefinableInternals = [];
public static $redefinableLanguageConstructs = [];
public static $newKeywordRedefinable = false;
public static $timestamp = 0;
}
12 changes: 6 additions & 6 deletions src/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StackEmpty extends Exception

abstract class CallbackException extends Exception
{
function __construct($callback)
public function __construct($callback)
{
parent::__construct(sprintf($this->message, Utils\callableToString($callback)));
}
Expand All @@ -39,7 +39,7 @@ class NotUserDefined extends CallbackException

class DefinedTooEarly extends CallbackException
{
function __construct($callback)
public function __construct($callback)
{
$this->message = "The file that defines %s() was included earlier than Patchwork. " .
"Please reverse this order to be able to redefine the function in question.";
Expand All @@ -62,7 +62,7 @@ class InternalsNotSupportedOnHHVM extends CallbackException

class CachePathUnavailable extends Exception
{
function __construct($location)
public function __construct($location)
{
parent::__construct(sprintf(
"The specified cache path is nonexistent or read-only: %s",
Expand All @@ -77,7 +77,7 @@ class ConfigException extends Exception

class ConfigMalformed extends ConfigException
{
function __construct($file, $message)
public function __construct($file, $message)
{
parent::__construct(sprintf(
'The configuration file %s is malformed: %s',
Expand All @@ -89,7 +89,7 @@ function __construct($file, $message)

class ConfigKeyNotRecognized extends ConfigException
{
function __construct($key, $list, $file)
public function __construct($key, $list, $file)
{
parent::__construct(sprintf(
"The key '%s' in the configuration file %s was not recognized. " .
Expand All @@ -103,7 +103,7 @@ function __construct($key, $list, $file)

class CachePathConflict extends ConfigException
{
function __construct($first, $second)
public function __construct($first, $second)
{
parent::__construct(sprintf(
"Detected configuration files provide conflicting cache paths: %s and %s",
Expand Down
2 changes: 1 addition & 1 deletion src/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ function allCalledClasses()

class State
{
static $items = [];
public static $items = [];
}
2 changes: 1 addition & 1 deletion src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,5 +385,5 @@ function tokenize($string)

class State
{
static $missedCallables = [];
public static $missedCallables = [];
}