Strict typing applies to non-scalar types too
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Affected page
https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict
Issue description
Strict typing is only defined for scalar type declarations.
However, that's not true (at least in PHP 8.4, not sure if that was different before)
Steps to reproduce
<?php
declare(strict_types=1);
class Foo {}
function type_null( null $a ) {
return $a;
}
function type_array( array $a ) {
return $a;
}
function type_Foo( Foo $a ) {
return $a;
}
function return_type_array( array $a ): array {
return null;
}
function return_type_null( array $a ): null {
return $a;
}
type_null( 'a' );
//type_array( 'a' );
//type_Foo( new stdClass() );
//return_type_array( array() );
//return_type_null( array() );
Suggested fix
Remove that Note: from docs
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the affected PHP manual page at language.types.declarations.php#language.types.declarations.strict and review the Note stating that strict typing only applies to scalar declarations. Check the linked 3v4l.org reproduction against PHP 8.4, then remove that Note; the page should no longer make the incorrect claim.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100