diff --git a/.travis.yml b/.travis.yml index 85ae617..f7a522f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,6 @@ language: php sudo: false -php: - - 7 - - 7.1 - - 7.2 - - nightly - env: TMPDIR=/tmp USE_XDEBUG=false branches: @@ -16,7 +10,7 @@ branches: install: - phpenv rehash - - travis_retry composer install --no-interaction --prefer-source + - travis_retry composer update --no-interaction --prefer-source $COMPOSER_ARGS stages: - test @@ -35,20 +29,39 @@ script: jobs: fast_finish: true allow_failures: + - php: 7.4snapshot - php: nightly include: + - php: 7.1 + env: COMPOSER_ARGS="--prefer-lowest" + - php: 7.1 + - php: 7.2 + env: COMPOSER_ARGS="--prefer-lowest" + - php: 7.2 + - php: 7.3 + env: COMPOSER_ARGS="--prefer-lowest" + - php: 7.3 + - php: 7.4snapshot + env: COMPOSER_ARGS="--ignore-platform-reqs --prefer-lowest" + - php: 7.4snapshot + env: COMPOSER_ARGS="--ignore-platform-reqs" + - php: nightly + env: COMPOSER_ARGS="--ignore-platform-reqs --prefer-lowest" + - php: nightly + env: COMPOSER_ARGS="--ignore-platform-reqs" + - stage: style check - php: 7.1 + php: 7.2 env: TMPDIR=/tmp USE_XDEBUG=false script: - composer style-check - stage: phpstan analysis - php: 7.1 + php: 7.2 env: TMPDIR=/tmp USE_XDEBUG=false script: - composer phpstan - stage: test with coverage - php: 7.1 + php: 7.2 env: TMPDIR=/tmp USE_XDEBUG=true CC_TEST_REPORTER_ID=42d486c369d750a2096422ea0fee5e92328f218dfc6e857d84697ee9b112b01a before_script: - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter diff --git a/composer.json b/composer.json index 8aaa1ad..7f17da6 100644 --- a/composer.json +++ b/composer.json @@ -40,11 +40,11 @@ } ], "require-dev": { - "phpunit/phpunit": "^6.0", - "phpstan/phpstan": "^0.9.2", + "phpunit/phpunit": "^7.0", + "phpstan/phpstan": "^0.11.2", "jetbrains/phpstorm-stubs": "dev-phpstan", "friendsofphp/php-cs-fixer": "^2.11", - "maglnet/composer-require-checker": "^0.1.6 | ^0.2.1", + "maglnet/composer-require-checker": "^1.1.0", "phpro/grumphp": "^0.14.0" }, "include-path": [ @@ -59,7 +59,7 @@ "scripts": { "test": "phpunit", "test-with-coverage": "phpunit --coverage-clover=clover.xml", - "phpstan": "phpstan analyze -l1 -c phpstan.neon --no-progress ./ --ansi", + "phpstan": "phpstan analyze -c phpstan.neon --no-progress --ansi", "style-check": "php-cs-fixer fix --dry-run -vv" }, "suggest": { diff --git a/grumphp.yml.dist b/grumphp.yml.dist index 560aea7..0dbe337 100644 --- a/grumphp.yml.dist +++ b/grumphp.yml.dist @@ -9,7 +9,6 @@ parameters: allow_risky: true config: .php_cs phpstan: - level: 1 configuration: phpstan.neon phpunit: metadata: diff --git a/phpstan.neon b/phpstan.neon index 3d8068a..5fb1021 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,7 @@ parameters: + level: 1 + paths: + - ./ excludes_analyse: - %rootDir%/../../../tests/* - %rootDir%/../../../vendor/* @@ -9,3 +12,7 @@ parameters: - '#Call to an undefined method Zend_Db_Statement::_bindParam\(\)\.#' - '#Call to an undefined method Zend_Db_Statement::_execute\(\)\.#' - '#Variable \$.+ might not be defined\.#' + # __unset's return is not void, it's $this + - + message: '#Result of method Zend_Db_Table_Row_Abstract::__unset\(\) \(void\) is used\.#' + path: %currentWorkingDirectory%/src/Zend/Db/Table/Row/Abstract.php diff --git a/src/Zend/Db/Adapter/Oracle.php b/src/Zend/Db/Adapter/Oracle.php index beabc9e..5892069 100644 --- a/src/Zend/Db/Adapter/Oracle.php +++ b/src/Zend/Db/Adapter/Oracle.php @@ -110,10 +110,10 @@ protected function _connect() $connectionFuncName = ($this->_config['persistent'] == true) ? 'oci_pconnect' : 'oci_connect'; $this->_connection = @$connectionFuncName( - $this->_config['username'], - $this->_config['password'], - $this->_config['dbname'], - $this->_config['charset'] + $this->_config['username'], + $this->_config['password'], + $this->_config['dbname'], + $this->_config['charset'] ); // check the connection diff --git a/src/Zend/Db/Profiler/Firebug.php b/src/Zend/Db/Profiler/Firebug.php index cb1d5e3..1ed6e58 100644 --- a/src/Zend/Db/Profiler/Firebug.php +++ b/src/Zend/Db/Profiler/Firebug.php @@ -141,10 +141,10 @@ protected function updateMessageLabel() array('%label%', '%totalCount%', '%totalDuration%'), - array($this->_label, + array($this->_label, $this->getTotalNumQueries(), (string)round($this->_totalElapsedTime, 5)), - $this->_label_template + $this->_label_template )); } } diff --git a/src/Zend/Db/Table/Abstract.php b/src/Zend/Db/Table/Abstract.php index 0564030..8f477c1 100644 --- a/src/Zend/Db/Table/Abstract.php +++ b/src/Zend/Db/Table/Abstract.php @@ -410,7 +410,7 @@ public function addReference( $columns, $refTableClass, $refColumns, - $onDelete = null, + $onDelete = null, $onUpdate = null ) { $reference = array(self::COLUMNS => (array) $columns, diff --git a/src/Zend/Db/Table/Row/Abstract.php b/src/Zend/Db/Table/Row/Abstract.php index d2b42cf..62e61d2 100644 --- a/src/Zend/Db/Table/Row/Abstract.php +++ b/src/Zend/Db/Table/Row/Abstract.php @@ -977,7 +977,7 @@ public function findManyToManyRowset( $matchTable, $intersectionTable, $callerRefRule = null, - $matchRefRule = null, + $matchRefRule = null, Zend_Db_Table_Select $select = null ) { $db = $this->_getTable()->getAdapter(); diff --git a/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php b/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php index 2839c09..9d984db 100644 --- a/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php +++ b/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php @@ -197,7 +197,7 @@ public function testAdapterCharacterVarying() { $this->_util->createTable( 'zf_pgsql_charvary', - array('pg_id' => 'character varying(4) NOT NULL', + array('pg_id' => 'character varying(4) NOT NULL', 'pg_info' => "character varying(1) NOT NULL DEFAULT 'A'::character varying") ); $description = $this->_db->describeTable('zf_pgsql_charvary'); @@ -213,7 +213,7 @@ public function testAdapterBpchar() { $this->_util->createTable( 'zf_pgsql_bpchar', - array('pg_name' => "character(100) DEFAULT 'Default'::bpchar") + array('pg_name' => "character(100) DEFAULT 'Default'::bpchar") ); $description = $this->_db->describeTable('zf_pgsql_bpchar'); $this->_util->dropTable('zf_pgsql_bpchar'); diff --git a/tests/Zend/Db/Adapter/TestCommon.php b/tests/Zend/Db/Adapter/TestCommon.php index 6c1a053..97c72f2 100644 --- a/tests/Zend/Db/Adapter/TestCommon.php +++ b/tests/Zend/Db/Adapter/TestCommon.php @@ -1538,14 +1538,14 @@ public function testAdapterQuoteTypeBigInt() public function testAdapterQuoteTypeFloat() { foreach ($this->_numericDataTypes as $typeName => $type) { - if ($type != 2) { + if ($type != Zend_Db::FLOAT_TYPE) { continue; } $value = $this->_db->quote(12.34, $typeName); $this->assertInternalType('string', $value); $this->assertEquals( - '12.34', + '12.340000', $value, 'Incorrect quote() FLOAT_TYPE result' ); @@ -1553,7 +1553,7 @@ public function testAdapterQuoteTypeFloat() $value = $this->_db->quote('12.34', $typeName); $this->assertInternalType('string', $value); $this->assertEquals( - '12.34', + '12.340000', $value, 'Incorrect quote() FLOAT_TYPE result' ); @@ -1561,7 +1561,7 @@ public function testAdapterQuoteTypeFloat() $value = $this->_db->quote('+12.34', $typeName); $this->assertInternalType('string', $value); $this->assertEquals( - '12.34', + '12.340000', $value, 'Incorrect quote() FLOAT_TYPE result' ); @@ -1569,7 +1569,7 @@ public function testAdapterQuoteTypeFloat() $value = $this->_db->quote('-12.34', $typeName); $this->assertInternalType('string', $value); $this->assertEquals( - '-12.34', + '-12.340000', $value, 'Incorrect quote() FLOAT_TYPE result' ); @@ -1577,7 +1577,7 @@ public function testAdapterQuoteTypeFloat() $value = $this->_db->quote('12.34abcd', $typeName); $this->assertInternalType('string', $value); $this->assertEquals( - '12.34', + '12.340000', $value, 'Incorrect quote() FLOAT_TYPE result' ); @@ -1585,7 +1585,7 @@ public function testAdapterQuoteTypeFloat() $value = $this->_db->quote('abcd', $typeName); $this->assertInternalType('string', $value); $this->assertEquals( - '0', + '0.000000', $value, 'Incorrect quote() FLOAT_TYPE result' ); @@ -1973,8 +1973,8 @@ public function testAdapterUpdateWithLongColumnIdentifier() //try to update $this->_db->update( $tableName, - array('veryveryveryverylongidentifier' => 3), - array($this->_db->quoteIdentifier('id') . ' = 1') + array('veryveryveryverylongidentifier' => 3), + array($this->_db->quoteIdentifier('id') . ' = 1') ); // check if the row was inserted as expected diff --git a/tests/Zend/Db/Profiler/FirebugTest.php b/tests/Zend/Db/Profiler/FirebugTest.php index 3071a91..271a3a2 100644 --- a/tests/Zend/Db/Profiler/FirebugTest.php +++ b/tests/Zend/Db/Profiler/FirebugTest.php @@ -68,7 +68,7 @@ public function setUp() $this->_profiler = new Zend_Db_Profiler_Firebug(); $this->_db = Zend_Db::factory( 'PDO_SQLITE', - array('dbname' => ':memory:', + array('dbname' => ':memory:', 'profiler' => $this->_profiler) ); $this->_db->getConnection()->exec('CREATE TABLE foo ( @@ -109,7 +109,7 @@ public function testEnable() $this->assertEquals( substr($messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE] [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0], 0, 55), - '[{"Type":"TABLE","Label":"Zend_Db_Profiler_Firebug (1 @' + '[{"Type":"TABLE","Label":"Zend_Db_Profiler_Firebug (1 @' ); } @@ -146,7 +146,7 @@ public function testCustomLabel() $this->assertEquals( substr($messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE] [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0], 0, 38), - '[{"Type":"TABLE","Label":"Label 1 (1 @' + '[{"Type":"TABLE","Label":"Label 1 (1 @' ); } diff --git a/tests/Zend/Db/Select/StaticTest.php b/tests/Zend/Db/Select/StaticTest.php index a661c11..d151759 100644 --- a/tests/Zend/Db/Select/StaticTest.php +++ b/tests/Zend/Db/Select/StaticTest.php @@ -872,8 +872,8 @@ public function testIfInColumn() $select->from('table1', '*'); $select->join( array('table2'), - 'table1.id = table2.id', - array('bar' => 'IF(table2.id IS NOT NULL, 1, 0)') + 'table1.id = table2.id', + array('bar' => 'IF(table2.id IS NOT NULL, 1, 0)') ); $this->assertEquals("SELECT \"table1\".*, IF(table2.id IS NOT NULL, 1, 0) AS \"bar\" FROM \"table1\"\n INNER JOIN \"table2\" ON table1.id = table2.id", $select->assemble()); } @@ -1061,7 +1061,7 @@ public function testAssembleQueryWithSubqueryInSelectBlock() $this->assertEquals( $expected, $select->assemble(), - 'Assembling query with subquery with join failed' + 'Assembling query with subquery with join failed' ); } @@ -1077,7 +1077,7 @@ public function testAssembleQueryWithRawSubqueryInSelectBlock() $this->assertEquals( $expected, $select->assemble(), - 'Assembling query with raw subquery with "new line" char failed' + 'Assembling query with raw subquery with "new line" char failed' ); } @@ -1092,7 +1092,7 @@ public function testAssembleQueryWithExpressionInSelectBlock() $this->assertEquals( $expected, $select->assemble(), - 'Assembling query with raw subquery with "new line" char failed' + 'Assembling query with raw subquery with "new line" char failed' ); } } diff --git a/tests/Zend/Db/Select/TestCommon.php b/tests/Zend/Db/Select/TestCommon.php index f20f286..21a9995 100644 --- a/tests/Zend/Db/Select/TestCommon.php +++ b/tests/Zend/Db/Select/TestCommon.php @@ -341,7 +341,7 @@ public function testSelectColumnsResetBeforeFrom() } catch (Zend_Exception $e) { $this->assertTrue( $e instanceof Zend_Db_Select_Exception, - 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e) + 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e) ); $this->assertEquals('No table has been specified for the FROM clause', $e->getMessage()); } @@ -636,7 +636,7 @@ public function testSelectMagicMethod() } catch (Zend_Exception $e) { $this->assertTrue( $e instanceof Zend_Db_Select_Exception, - 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e) + 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e) ); $this->assertEquals("Unrecognized method 'foo()'", $e->getMessage()); } @@ -684,7 +684,7 @@ public function testSelectJoinInnerUsingException() } catch (Zend_Exception $e) { $this->assertTrue( $e instanceof Zend_Db_Select_Exception, - 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e) + 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e) ); $this->assertEquals("Unrecognized method 'joinFooUsing()'", $e->getMessage()); } @@ -712,7 +712,7 @@ public function testSelectJoinCrossUsing() } catch (Zend_Exception $e) { $this->assertTrue( $e instanceof Zend_Db_Select_Exception, - 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e) + 'Expected exception of type "Zend_Db_Select_Exception", got ' . get_class($e) ); $this->assertEquals("Cannot perform a joinUsing with method 'joinCrossUsing()'", $e->getMessage()); } diff --git a/tests/Zend/Db/Table/Relationships/TestCommon.php b/tests/Zend/Db/Table/Relationships/TestCommon.php index 4f35868..e404bca 100644 --- a/tests/Zend/Db/Table/Relationships/TestCommon.php +++ b/tests/Zend/Db/Table/Relationships/TestCommon.php @@ -233,7 +233,7 @@ public function testTableRelationshipFindManyToManyRowsetSelect() $destRows = $originRow1->findManyToManyRowset( 'My_ZendDbTable_TableProducts', 'My_ZendDbTable_TableBugsProducts', - null, + null, null, $select ); @@ -673,9 +673,8 @@ public function testTableRelationshipCascadingDeleteUsageBasicArray() $this->assertCount( 0, - - $tableBugsCustom->fetchAll( - $tableBugsCustom->getAdapter() + $tableBugsCustom->fetchAll( + $tableBugsCustom->getAdapter() ->quoteInto("$reported_by = ?", 'mmouse') ), 'Expecting cascading delete to have reduced dependent rows to zero' diff --git a/tests/Zend/Db/Table/Row/OracleTest.php b/tests/Zend/Db/Table/Row/OracleTest.php index 1f5ae64..46cf5c7 100644 --- a/tests/Zend/Db/Table/Row/OracleTest.php +++ b/tests/Zend/Db/Table/Row/OracleTest.php @@ -45,7 +45,7 @@ protected function _testTableRowSetReadOnlyGetTableBugs() { return $this->_getTable( 'My_ZendDbTable_TableBugs', - array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq') + array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq') ); } diff --git a/tests/Zend/Db/Table/Row/Pdo/OciTest.php b/tests/Zend/Db/Table/Row/Pdo/OciTest.php index 419bfff..5d83af2 100644 --- a/tests/Zend/Db/Table/Row/Pdo/OciTest.php +++ b/tests/Zend/Db/Table/Row/Pdo/OciTest.php @@ -45,7 +45,7 @@ protected function _testTableRowSetReadOnlyGetTableBugs() { return $this->_getTable( 'My_ZendDbTable_TableBugs', - array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq') + array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq') ); } diff --git a/tests/Zend/Db/Table/TestCommon.php b/tests/Zend/Db/Table/TestCommon.php index cc6833d..ddba0dd 100644 --- a/tests/Zend/Db/Table/TestCommon.php +++ b/tests/Zend/Db/Table/TestCommon.php @@ -69,7 +69,7 @@ public function testAddReference() $products->addReference( 'Reporter', 'reported_by', - 'My_ZendDbTable_TableAccounts', + 'My_ZendDbTable_TableAccounts', 'account_name' ); @@ -410,7 +410,7 @@ public function testTableWithNoAdapterAndNoDefaultAdapter() $this->fail('Zend_Db_Table_Exception should be thrown'); } catch (Zend_Exception $e) { $this->assertTrue( - $e instanceof Zend_Db_Table_Exception, + $e instanceof Zend_Db_Table_Exception, 'Expecting object of type Zend_Db_Table_Exception, got ' . get_class($e) ); } @@ -1936,7 +1936,7 @@ public function testCacheIdGeneratedToMetadata() Zend_Db_Table::setDefaultAdapter($this->_db); $dbConfig = $this->_db->getConfig(); $cacheId = md5( - (isset($dbConfig['port']) ? ':' . $dbConfig['port'] : null) + (isset($dbConfig['port']) ? ':' . $dbConfig['port'] : null) . (isset($dbConfig['host']) ? ':' . $dbConfig['host'] : null) . '/' . $dbConfig['dbname'] . ':.cache_metadata' ); diff --git a/tests/Zend/Db/Table/_files/My/ZendDbTable/Row/TestMockRow.php b/tests/Zend/Db/Table/_files/My/ZendDbTable/Row/TestMockRow.php index 6c657e2..dd83a9f 100644 --- a/tests/Zend/Db/Table/_files/My/ZendDbTable/Row/TestMockRow.php +++ b/tests/Zend/Db/Table/_files/My/ZendDbTable/Row/TestMockRow.php @@ -55,7 +55,7 @@ public function findManyToManyRowset( $matchTable, $intersectionTable, $callerRefRule = null, - $matchRefRule = null, + $matchRefRule = null, Zend_Db_Table_Select $select = null ) { $this->matchTable = $matchTable;