<commit_before><?php

class Language_Types_TypeJugglingTest extends PHPUnit_Framework_TestCase
{
    public function testFalseToArray()
    {
        $var = false;
        $var['foo'] = 10;
        $this->assertInternalType('array', $var);
    }

    public function testFalseToObject()
    {
        if (version_compare(PHP_VERSION, '5.3', '>='))
            $this->setExpectedException('PHPUnit_Framework_Error_Notice');
        if (version_compare(PHP_VERSION, '5.4', '>='))
            $this->setExpectedException('PHPUnit_Framework_Error_Warning');
        $var = false;
        $var->name = 'bob';
    }

    public function testNullToObject()
    {
        $var = (object) null;
        $this->assertInternalType('object', $var);
    }

    public function testNullToArray()
    {
        $var = null;
        $var['foo'] = 10;
        $this->assertInternalType('array', $var);
    }

    public function testNullToString()
    {
        $this->assertSame('', (string) null);
    }

    /**
     * @expectedException PHPUnit_Framework_Error_Warning
     * @expectedExceptionMessage Cannot use a scalar value as an array
     */
    public function testTrueToArray()
    {
        $var = true;
        $var['foo'] = 10;
        $this->assertInternalType('array', $var);
    }

    /**
     * @expectedException PHPUnit_Framework_Error_Warning
     */
    public function testStringToArray()
    {
        $this->markTestSkipped('This crash my (and Travis) PHP cli');
        // ... but PHP 5.4.6 on Ubuntu and PHPUnit 3.6.10 is ok, mmm
        $var = '2.5';
        $var['foo'] = 10;
    }

    public function testCastStringToArray()
    {
        $this->assertSame(array("foo"), (array) "foo");
    }

    public function testCastArrayToArray()
    {
        $data = array("foo");
        $this->assertSame($data, (array) $data);
    }
}
<commit_msg>Add cast boolean to object test<commit_after><?php

class Language_Types_TypeJugglingTest extends PHPUnit_Framework_TestCase
{
    public function testFalseToArray()
    {
        $var = false;
        $var['foo'] = 10;
        $this->assertInternalType('array', $var);
    }

    public function testFalseToObject()
    {
        if (version_compare(PHP_VERSION, '5.3', '>='))
            $this->setExpectedException('PHPUnit_Framework_Error_Notice');
        if (version_compare(PHP_VERSION, '5.4', '>='))
            $this->setExpectedException('PHPUnit_Framework_Error_Warning');
        $var = false;
        $var->name = 'bob';
    }

    public function testNullToObject()
    {
        $var = (object) null;
        $this->assertInternalType('object', $var);
    }

    public function testNullToArray()
    {
        $var = null;
        $var['foo'] = 10;
        $this->assertInternalType('array', $var);
    }

    public function testNullToString()
    {
        $this->assertSame('', (string) null);
    }

    /**
     * @expectedException PHPUnit_Framework_Error_Warning
     * @expectedExceptionMessage Cannot use a scalar value as an array
     */
    public function testTrueToArray()
    {
        $var = true;
        $var['foo'] = 10;
        $this->assertInternalType('array', $var);
    }

    /**
     * @expectedException PHPUnit_Framework_Error_Warning
     */
    public function testStringToArray()
    {
        $this->markTestSkipped('This crash my (and Travis) PHP cli');
        // ... but PHP 5.4.6 on Ubuntu and PHPUnit 3.6.10 is ok, mmm
        $var = '2.5';
        $var['foo'] = 10;
    }

    public function testCastStringToArray()
    {
        $this->assertSame(array("foo"), (array) "foo");
    }

    public function testCastArrayToArray()
    {
        $data = array("foo");
        $this->assertSame($data, (array) $data);
    }

    public function testCastBooleanToObject()
    {
        $expected = new stdClass();
        $expected->scalar = false; // expect weird shit
        $this->assertEquals($expected, (object) false);
        $expected->scalar = true;
        $this->assertEquals($expected, (object) true);
    }

    public function testCastNullToObject()
    {
        $this->assertEquals(new stdClass(), (object) null);
    }
}

{'fraction_non_alphanumeric': 0.14037626628075253, 'fraction_numerical': 0.010130246020260492, 'mean_word_length': 2.4472152950955945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, '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': '1999499', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1232, 'n_words': 259}