Skip to content

Commit

Permalink
Fix typos, add @throws and remove unused import statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Janos Szurovecz committed Aug 30, 2015
1 parent 9fc479d commit a4559a7
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/precore/util/BufferedIterable.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public function limit($limit)
*
* @param int $limit
* @return BufferedIterable
* @throws \InvalidArgumentException if $limit is <= 0
*/
public function providerCallLimit($limit)
{
Expand Down
2 changes: 2 additions & 0 deletions src/precore/util/ComparisonChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
namespace precore\util;

use Closure;
use precore\lang\ClassCastException;
use precore\lang\Comparable;

/**
Expand Down Expand Up @@ -105,6 +106,7 @@ public function __construct(ComparisonChain $less, ComparisonChain $greater)
* @param $right
* @param Comparator $comparator
* @return ComparisonChain
* @throws ClassCastException if the arguments' types prevent them from being compared by this comparator
*/
public function withComparator($left, $right, Comparator $comparator)
{
Expand Down
5 changes: 5 additions & 0 deletions src/precore/util/FluentIterable.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public function map(callable $mapper)
}

/**
* Applies function to each element of this fluent iterable and returns a fluent iterable
* with the concatenated combination of results. Transformer returns a Traversable of results.
*
* @param callable $transformer
* @return FluentIterable
* @see flatMap
*/
public function transformAndConcat(callable $transformer)
Expand Down
3 changes: 3 additions & 0 deletions src/precore/util/Iterables.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public static function find(IteratorAggregate $iterable, callable $predicate, $d
* @param IteratorAggregate $iterable
* @param int $size
* @return IteratorAggregate
* @throws \InvalidArgumentException if $size is non positive
*/
public static function partition(IteratorAggregate $iterable, $size)
{
Expand All @@ -159,6 +160,7 @@ function () use ($element) {
* @param IteratorAggregate $iterable
* @param int $size
* @return IteratorAggregate
* @throws \InvalidArgumentException if $size is non positive
*/
public static function paddedPartition(IteratorAggregate $iterable, $size)
{
Expand Down Expand Up @@ -245,6 +247,7 @@ function () use ($fromIterable, $transformer) {
* @param IteratorAggregate $iterable
* @param $limitSize
* @return IteratorAggregate
* @throws \InvalidArgumentException if $limitSize is negative
*/
public static function limit(IteratorAggregate $iterable, $limitSize)
{
Expand Down
1 change: 1 addition & 0 deletions src/precore/util/Iterators.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public static function limit(Iterator $iterator, $limitSize)
* @param Iterator $iterator
* @param $numberToSkip
* @return integer
* @throws \InvalidArgumentException if $numberToSkip is < 0
*/
public static function advance(Iterator $iterator, $numberToSkip)
{
Expand Down
5 changes: 4 additions & 1 deletion src/precore/util/Joiner.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ abstract class Joiner extends Object
private $separator;

/**
* @param $separator
* @param string $separator
* @throws \InvalidArgumentException if separator is not a string
*/
protected function __construct($separator)
{
Expand All @@ -64,6 +65,7 @@ protected function __construct($separator)
*
* @param string $separator
* @return Joiner
* @throws \InvalidArgumentException if separator is not a string
*/
public static function on($separator)
{
Expand Down Expand Up @@ -105,6 +107,7 @@ protected abstract function modifyIterable(FluentIterable $iterable);
*
* @param array|Traversable $parts
* @return string
* @throws \InvalidArgumentException if $parts is not an array or a Traversable
*/
final public function join($parts)
{
Expand Down
2 changes: 1 addition & 1 deletion src/precore/util/Optional.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function map(callable $mapper)
public function orElseThrow(callable $exceptionSupplier = null)
{
$exception = call_user_func(Preconditions::checkNotNull($exceptionSupplier));
Preconditions::checkState($exception instanceof \Exception, '$exceptonSupplier must create an Exception');
Preconditions::checkState($exception instanceof \Exception, '$exceptionSupplier must create an Exception');
throw $exception;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/precore/util/Ordering.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public function min(Traversable $traversable)
*
* @param Traversable $traversable
* @return mixed
* @throws \OutOfBoundsException if $traversable is empty
*/
public function max(Traversable $traversable)
{
Expand Down
1 change: 1 addition & 0 deletions src/precore/util/ProfilerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static function instance()
/**
* @param $name
* @return Profiler
* @throws \OutOfBoundsException if there is no registered profiler with $name
*/
public function get($name)
{
Expand Down
1 change: 1 addition & 0 deletions src/precore/util/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public function __invoke($element)
/**
* @param $value
* @return bool
* @throws NullPointerException if $value is null
*/
public function contains($value)
{
Expand Down
8 changes: 6 additions & 2 deletions src/precore/util/Splitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public static function fixedLength($length)

protected function __construct($trimResult, $omitEmptyStrings)
{
$this->trimResults = $trimResult;
$this->omitEmptyStrings = $omitEmptyStrings;
$this->trimResults = (boolean) $trimResult;
$this->omitEmptyStrings = (boolean) $omitEmptyStrings;
}

/**
Expand Down Expand Up @@ -159,6 +159,7 @@ public final function omitEmptyStrings()
/**
* @param string $input
* @return Traversable
* @throws \InvalidArgumentException if $input is not a string
*/
public final function split($input)
{
Expand Down Expand Up @@ -220,6 +221,7 @@ final class SimpleSplitter extends Splitter
* @param $trimResult
* @param $omitEmptyStrings
* @param boolean $eager
* @throws \InvalidArgumentException if $delimiter is not a string
*/
public function __construct($delimiter, $trimResult, $omitEmptyStrings, $eager = false)
{
Expand Down Expand Up @@ -291,6 +293,7 @@ final class PatternSplitter extends Splitter
* @param string $pattern
* @param $trimResult
* @param $omitEmptyStrings
* @throws \InvalidArgumentException if $pattern is not a string
*/
public function __construct($pattern, $trimResult, $omitEmptyStrings)
{
Expand Down Expand Up @@ -349,6 +352,7 @@ final class FixedLengthSplitter extends Splitter
* @param int $length
* @param $trimResult
* @param $omitEmptyStrings
* @throws \InvalidArgumentException if $length is not a positive integer
*/
public function __construct($length, $trimResult, $omitEmptyStrings)
{
Expand Down
3 changes: 3 additions & 0 deletions src/precore/util/Stopwatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace precore\util;

use precore\lang\IllegalStateException;
use precore\lang\Object;
use precore\util\concurrent\TimeUnit;
use RuntimeException;
Expand Down Expand Up @@ -135,6 +136,7 @@ public static function createStartedWith(Ticker $ticker)
* Starts the stopwatch.
*
* @return $this
* @throws IllegalStateException if this Stopwatch is already running
*/
public function start()
{
Expand All @@ -150,6 +152,7 @@ public function start()
*
* @throw IllegalStateException if it is already stopped
* @return $this
* @throws IllegalStateException if this Stopwatch is already stopped
*/
public function stop()
{
Expand Down
3 changes: 1 addition & 2 deletions src/precore/util/ToStringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

use DateTime;
use ErrorException;
use Iterator;
use IteratorAggregate;
use precore\lang\Object;

/**
Expand Down Expand Up @@ -84,6 +82,7 @@ public static function valueToString($value)
*
* @param string $param
* @return ToStringHelper $this
* @throws \InvalidArgumentException if the number of parameters is not 1 or 2
*/
public function add($param)
{
Expand Down
10 changes: 5 additions & 5 deletions src/precore/util/concurrent/LockedRunnableWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use precore\lang\Runnable;

/**
* Usefull for cron jobs. The wrapped Runnable object
* Useful for cron jobs. The wrapped Runnable object
* cannot be executed more than once at the same time
* (if you use the same lock).
*
Expand Down Expand Up @@ -65,21 +65,21 @@ public function __construct(Runnable $runnable, Lock $lock)
*/
public function run()
{
$throwedException = null;
$thrownException = null;
try {
$this->lock->lock();
try {
$this->runnable->run();
} catch (Exception $e) {
self::getLogger()->error($e);
$throwedException = $e;
$thrownException = $e;
}
$this->lock->unLock();
} catch (LockException $e) {
throw new RunException('Lock error during running.', null, $e);
}
if ($throwedException !== null) {
throw new RunException('Error during execution wrapped Runnable object.', null, $throwedException);
if ($thrownException !== null) {
throw new RunException('Error during execution wrapped Runnable object.', null, $thrownException);
}
}
}

0 comments on commit a4559a7

Please sign in to comment.