for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Deprecated new reference sniff test file
*
* @package PHPCompatibility
*/
* Deprecated new reference sniff tests
* @uses BaseSniffTest
* @author Jansen Price <[email protected]>
class DeprecatedNewReferenceSniffTest extends BaseSniffTest
You can fix this by adding a namespace to your class:
namespace YourVendor; class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
{
const TEST_FILE = 'sniff-examples/deprecated_new_reference.php';
* testDeprecatedNewReference
* @dataProvider dataDeprecatedNewReference
* @param int $line The line number.
* @return void
public function testDeprecatedNewReference($line)
$file = $this->sniffFile(self::TEST_FILE, '5.2');
$this->assertNoViolation($file, $line);
$file = $this->sniffFile(self::TEST_FILE, '5.3');
$this->assertWarning($file, $line, 'Assigning the return value of new by reference is deprecated in PHP 5.3');
$file = $this->sniffFile(self::TEST_FILE, '7.0');
$this->assertError($file, $line, 'Assigning the return value of new by reference is deprecated in PHP 5.3 and forbidden in PHP 7.0');
}
* Data provider.
* @see testDeprecatedNewReference()
* @return array
public function dataDeprecatedNewReference()
return array(
array(9),
array(10),
);
* testNoReference
public function testNoReference()
$this->assertNoViolation($file, 8);
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.