Browse Source

Merge pull request #13366 from cakephp/4.x-fixtures

Update typehint for methods of TableSchemaAwareInterface.
Mark Story 6 years ago
parent
commit
f4751fdce8

+ 0 - 2
phpstan.neon

@@ -23,7 +23,6 @@ parameters:
         - '#Call to an undefined method Cake\\Chronos\\DifferenceFormatterInterface::dateAgoInWords\(\)#'
         - '#Call to an undefined method Cake\\Chronos\\DifferenceFormatterInterface::timeAgoInWords\(\)#'
         - '#Return type \(void\) of method Cake\\Shell\\[A-Za-z]+Shell::main\(\) should be compatible with return type \(bool|int|null\) of method Cake\\Console\\Shell::main\(\)#'
-        - '#Property Cake\\TestSuite\\Fixture\\TestFixture::\$_schema \(Cake\\Database\\Schema\\SqlGeneratorInterface&Cake\\Database\\Schema\\TableSchemaInterface\) does not accept Cake\\Database\\Schema\\TableSchemaInterface#'
         - '#Return type \(null\) of method Cake\\Collection\\Iterator\\NoChildrenIterator::getChildren\(\) should be compatible with return type \(RecursiveIterator\) of method RecursiveIterator::getChildren\(\)#'
         - '#Call to an undefined method DateTimeInterface::setTimezone\(\)#'
         - '#Parameter \#1 \$filename of function fopen expects string, resource given.#'
@@ -33,7 +32,6 @@ parameters:
         - '#Parameter \#2 \$assoc of method Cake\\ORM\\Marshaller::_mergeBelongsToMany\(\) expects .+BelongsToMany, Cake\\ORM\\Association given.#'
         - '#Parameter \#1 \$table of method Cake\\ORM\\Query::addDefaultTypes\(\) expects Cake\\ORM\\Table, .+RepositoryInterface given.#'
         - '#Parameter \#1 \$table of method Cake\\ORM\\Query::_addAssociationsToTypeMap\(\) expects Cake\\ORM\\Table, .+RepositoryInterface given.#'
-        - '#Parameter \#1 \$connection of method Cake\\Database\\Schema\\SqlGeneratorInterface::(create|drop|truncate)Sql\(\) expects Cake\\Database\\Connection, Cake\\Datasource\\ConnectionInterface given#'
         - '#Property Cake\\Controller\\Controller::\$response \(Cake\\Http\\Response\) does not accept Psr\\Http\\Message\\ResponseInterface#'
         -
             message: '#Right side of && is always false#'

+ 0 - 11
psalm-baseline.xml

@@ -2061,17 +2061,6 @@
       <code>$test-&gt;fixtureManager</code>
     </NoInterfaceProperties>
   </file>
-  <file src="src/TestSuite/Fixture/TestFixture.php">
-    <InvalidPropertyAssignmentValue occurrences="1">
-      <code>$schema</code>
-    </InvalidPropertyAssignmentValue>
-    <MismatchingDocblockReturnType occurrences="1">
-      <code>TableSchemaInterface</code>
-    </MismatchingDocblockReturnType>
-    <PropertyNotSetInConstructor occurrences="1">
-      <code>$_schema</code>
-    </PropertyNotSetInConstructor>
-  </file>
   <file src="src/TestSuite/IntegrationTestTrait.php">
     <InvalidCatch occurrences="1"/>
     <MissingClosureParamType occurrences="4">

+ 4 - 4
src/Database/Schema/TableSchemaAwareInterface.php

@@ -24,15 +24,15 @@ interface TableSchemaAwareInterface
     /**
      * Get and set the schema for this fixture.
      *
-     * @return \Cake\Database\Schema\TableSchemaInterface|null
+     * @return \Cake\Database\Schema\TableSchemaInterface&\Cake\Database\Schema\SqlGeneratorInterface
      */
-    public function getTableSchema(): ?TableSchemaInterface;
+    public function getTableSchema();
 
     /**
      * Get and set the schema for this fixture.
      *
-     * @param \Cake\Database\Schema\TableSchemaInterface $schema The table to set.
+     * @param \Cake\Database\Schema\TableSchemaInterface$schema $schema The table to set.
      * @return $this
      */
-    public function setTableSchema(TableSchemaInterface $schema);
+    public function setTableSchema($schema);
 }

+ 3 - 3
src/TestSuite/Fixture/TestFixture.php

@@ -19,7 +19,6 @@ use Cake\Core\Exception\Exception as CakeException;
 use Cake\Database\ConstraintsInterface;
 use Cake\Database\Schema\TableSchema;
 use Cake\Database\Schema\TableSchemaAwareInterface;
-use Cake\Database\Schema\TableSchemaInterface;
 use Cake\Datasource\ConnectionInterface;
 use Cake\Datasource\ConnectionManager;
 use Cake\Datasource\FixtureInterface;
@@ -84,6 +83,7 @@ class TestFixture implements ConstraintsInterface, FixtureInterface, TableSchema
      * The schema for this fixture.
      *
      * @var \Cake\Database\Schema\TableSchemaInterface&\Cake\Database\Schema\SqlGeneratorInterface
+     * @psalm-suppress PropertyNotSetInConstructor
      */
     protected $_schema;
 
@@ -442,7 +442,7 @@ class TestFixture implements ConstraintsInterface, FixtureInterface, TableSchema
     /**
      * @inheritDoc
      */
-    public function getTableSchema(): TableSchemaInterface
+    public function getTableSchema()
     {
         return $this->_schema;
     }
@@ -450,7 +450,7 @@ class TestFixture implements ConstraintsInterface, FixtureInterface, TableSchema
     /**
      * @inheritDoc
      */
-    public function setTableSchema(TableSchemaInterface $schema)
+    public function setTableSchema($schema)
     {
         $this->_schema = $schema;