<commit_before><?php
namespace rg\typewriter;

class TypeCheckerTest extends \PHPUnit_Framework_TestCase {

    public function testConstructorMethodBoundToObject() {
        $this->markTestIncomplete();
        // stub needed
        $obj = null;
        $checker = new TypeChecker([$obj, 'methodName']);
    }

    public function testConstructorMethodBoundToClass() {
        $this->markTestIncomplete();
        $checker = new TypeChecker(['className', 'methodName']);
    }

    public function testConstructorStaticMethodAsString() {
        $this->markTestIncomplete();
        // stub needed
        $checker = new TypeChecker('SomeClass::methodName');
    }

    public function testConstructorClosure() {
        /**
         * @return string
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
    }

    public function testConstructorNamedFunction() {
        $checker = new TypeChecker('rg\typewriter\stub\strlen');
    }

    public function testValidateReturnTypeBool() {
        /**
         * @return bool
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
        $this->assertTrue($checker->isValueValidReturnType(true));
        $this->assertFalse($checker->isValueValidReturnType('foo'));
    }

    public function testValidateReturnTypeString() {
        /**
         * @return string
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
        $this->assertTrue($checker->isValueValidReturnType('foo'));
        $this->assertFalse($checker->isValueValidReturnType(null));
    }

    public function testValidateCompositeReturnType() {
        /**
         * @return int|bool
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
        $this->assertTrue($checker->isValueValidReturnType(0));
        $this->assertTrue($checker->isValueValidReturnType(2));
        $this->assertTrue($checker->isValueValidReturnType(true));
        $this->assertTrue($checker->isValueValidReturnType(false));
        $this->assertFalse($checker->isValueValidReturnType('foo'));
    }

    public function testValidateReturnTypeCollection() {
        /**
         * @return int[]
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
        $this->assertTrue($checker->isValueValidReturnType([1, 2, 3]));
        $this->assertFalse($checker->isValueValidReturnType([1, 2, 'foo']));
    }
}<commit_msg>ensure collection validation also works for iterators (and other non-array traversables)<commit_after><?php
namespace rg\typewriter;

class TypeCheckerTest extends \PHPUnit_Framework_TestCase {

    public function testConstructorMethodBoundToObject() {
        $this->markTestIncomplete();
        // stub needed
        $obj = null;
        $checker = new TypeChecker([$obj, 'methodName']);
    }

    public function testConstructorMethodBoundToClass() {
        $this->markTestIncomplete();
        $checker = new TypeChecker(['className', 'methodName']);
    }

    public function testConstructorStaticMethodAsString() {
        $this->markTestIncomplete();
        // stub needed
        $checker = new TypeChecker('SomeClass::methodName');
    }

    public function testConstructorClosure() {
        /**
         * @return string
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
    }

    public function testConstructorNamedFunction() {
        $checker = new TypeChecker('rg\typewriter\stub\strlen');
    }

    public function testValidateReturnTypeBool() {
        /**
         * @return bool
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
        $this->assertTrue($checker->isValueValidReturnType(true));
        $this->assertFalse($checker->isValueValidReturnType('foo'));
    }

    public function testValidateReturnTypeString() {
        /**
         * @return string
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
        $this->assertTrue($checker->isValueValidReturnType('foo'));
        $this->assertFalse($checker->isValueValidReturnType(null));
    }

    public function testValidateCompositeReturnType() {
        /**
         * @return int|bool
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
        $this->assertTrue($checker->isValueValidReturnType(0));
        $this->assertTrue($checker->isValueValidReturnType(2));
        $this->assertTrue($checker->isValueValidReturnType(true));
        $this->assertTrue($checker->isValueValidReturnType(false));
        $this->assertFalse($checker->isValueValidReturnType('foo'));
    }

    public function testValidateReturnTypeCollection() {
        /**
         * @return int[]
         */
        $callback = function() {};
        $checker = new TypeChecker($callback);
        $this->assertTrue($checker->isValueValidReturnType([1, 2, 3]));
        $this->assertFalse($checker->isValueValidReturnType([1, 2, 'foo']));
        $this->assertTrue($checker->isValueValidReturnType(new \ArrayIterator([1, 2, 3])));
        $this->assertFalse($checker->isValueValidReturnType(new \ArrayIterator([1, 2, 'foo'])));
    }
}
{'fraction_non_alphanumeric': 0.1410498489425982, 'fraction_numerical': 0.0035876132930513596, 'mean_word_length': 2.849563953488372, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4214218', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1423, 'n_words': 232}