-
-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix marking falsy default values as required (#2186)
* Add test to verify failure of falsy defaults * Add default value from reflection This change provides a means to add the default value from the reflection of a property should the default value not have been set previously via a `default` parameter of an attribute or annotation. Also we check before setting anything to nullable whether a default has been set either via the reflection of via the default property of the schema. In those cases we do not add the property to the required properties as it does have a default * Set defaults only on PHP8 or above The used ReflectionProperty methods are not available before PHP8, therefore we can only execute them there. Affected tests will be skipped on PHP7 * Make class usable in PHP8 and PHP7 This makes sure that the class does not have typehinted properties as those do not work unless PHP7.4 * move upstream changes to required generation to RequiredPropertyDescriber * move upstream changes to required generation to RequiredPropertyDescriber * fix baseline * move reflection logic to ReflectionReader * use isDefault method * use isDefault method * Revert "use isDefault method" This reverts commit 69c5e04. * use PHP_VERSION_ID * use simpler retrieval of default property values * update falsy defaults test * remove test skip --------- Co-authored-by: DjordyKoert <[email protected]>
- Loading branch information
1 parent
b200bc1
commit f43a4ba
Showing
10 changed files
with
150 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the NelmioApiDocBundle package. | ||
* | ||
* (c) Nelmio | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; | ||
|
||
class EntityWithFalsyDefaults | ||
{ | ||
/** @var int */ | ||
public $zero = 0; | ||
|
||
/** @var float */ | ||
public $float = 0.0; | ||
|
||
/** @var string */ | ||
public $empty = ''; | ||
|
||
/** @var bool */ | ||
public $false = false; | ||
|
||
/** @var string|null */ | ||
public $nullString = null; | ||
|
||
/** @var string[] */ | ||
public $array = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters