Skip to content

Enable strict types#2854

Merged
morozov merged 1 commit intodoctrine:developfrom
Majkl578:strict-types
Apr 2, 2019
Merged

Enable strict types#2854
morozov merged 1 commit intodoctrine:developfrom
Majkl578:strict-types

Conversation

@Majkl578
Copy link
Copy Markdown
Contributor

No description provided.

@Majkl578 Majkl578 added this to the 3.0 milestone Sep 11, 2017
@Ocramius
Copy link
Copy Markdown
Member

Loads of string casts to be added 😅

@morozov morozov force-pushed the develop branch 2 times, most recently from 12fb8e1 to a14b808 Compare January 4, 2018 18:47
@morozov morozov force-pushed the develop branch 3 times, most recently from 7b7cffe to c5e8a7c Compare March 19, 2018 19:11
@morozov morozov force-pushed the develop branch 3 times, most recently from fd275f8 to c78e0e5 Compare April 9, 2018 15:30
@morozov morozov force-pushed the develop branch 2 times, most recently from 72cddfb to d8f1786 Compare June 6, 2018 21:46
@morozov morozov force-pushed the develop branch 3 times, most recently from 67bd64c to 7e5fb71 Compare July 2, 2018 00:52
@Ocramius
Copy link
Copy Markdown
Member

Ocramius commented Feb 9, 2019

One thing I didn't mention yet: this should have an UPGRADE.md in which we instruct people to run something like Psalm or PHPStan to detect type errors...

@Majkl578 Majkl578 force-pushed the strict-types branch 2 times, most recently from b207086 to e3373c1 Compare February 9, 2019 17:45
@morozov
Copy link
Copy Markdown
Member

morozov commented Feb 9, 2019

[…] something like Psalm or PHPStan to detect type errors...

We could only recommend Psalm if our own codebase passes its test. Otherwise, there will be lots of false-positives. What do you think about adopting Psalm/Phan in our CI? At a glance, it looks like a lot more work :-D

@Majkl578
Copy link
Copy Markdown
Contributor Author

Majkl578 commented Feb 9, 2019

I am skeptic towards Psalm, last time I saw it it required a lot of Psalm-specific annotations and stuff. :/

@Ocramius
Copy link
Copy Markdown
Member

Ocramius commented Feb 9, 2019

The end users only need to check the contact surface with DBAL, not DBAL itself, so any of these tools would guarantee decent safety. Psalm is way stricter than PHPStan, so that's up for discussion, but it is capable of much more interesting type additions: https://medium.com/vimeo-engineering-blog/uncovering-php-bugs-with-template-a4ca46eb9aeb

@Majkl578 Majkl578 force-pushed the strict-types branch 2 times, most recently from 253b936 to f62131a Compare February 13, 2019 16:15
@morozov morozov force-pushed the develop branch 2 times, most recently from 3850154 to 4fbe91a Compare February 22, 2019 00:01
@morozov morozov force-pushed the develop branch 3 times, most recently from a640b82 to e7b6c16 Compare March 18, 2019 06:13
@Majkl578 Majkl578 force-pushed the strict-types branch 2 times, most recently from ad01eea to beb6031 Compare March 30, 2019 01:56
@Majkl578 Majkl578 requested a review from morozov March 30, 2019 02:17
@@ -273,7 +275,7 @@ public function testGeneratesForeignKeySqlOnlyWhenSupportingForeignKeys()
}
}

protected function getBitAndComparisonExpressionSql($value1, $value2)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss the PHP 7.1 strictness.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, I added typehints.

Copy link
Copy Markdown
Member

@morozov morozov Apr 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. The change is correct. I was saying that this issue wouldn't be possible on PHP 7.1 which doesn't allow loosening argument types in subclasses. I oversaw it recently in #3498.

$extraParameters = array_slice(func_get_args(), 3);

if (count($extraParameters) !== 0) {
$extraParameters[0] = $extraParameters[0] ?? 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really see how we can improve here. Unlike the userland optional arguments defaulting to some value, the internal arguments are counted, so we have to respect the expected number of arguments being passed and their types.

Copy link
Copy Markdown
Member

@morozov morozov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the issue in OCI8Exception, I don't see anything else worth reworking.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants