Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Ini scanner mode #10

Merged
merged 4 commits into from
Feb 11, 2021
Merged

Ini scanner mode #10

merged 4 commits into from
Feb 11, 2021

Conversation

jcsanyi
Copy link
Contributor

@jcsanyi jcsanyi commented Sep 8, 2020

Q A
Documentation yes
Bugfix no
BC Break no
New Feature yes
RFC no
QA yes

Description

Adds a typedMode flag to the INI Reader to support the built-in INI_SCANNER_TYPED flag on parse_ini_file().
This allows integer, boolean, and null values to be returned as the appropriate types, rather than all being returned as strings.

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

Minor changes needed, bit otherwise seems OK.

My biggest issue with the patch is that, in order to follow consistency with pre-existing code, setters/getters are used to enable this behaviour, instead of relying on the Reader\Ini constructor.

* @param bool $typedMode
* @return $this
*/
public function setTypedMode($typedMode)
Copy link
Member

Choose a reason for hiding this comment

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

This should just accept bool as an input (no cast in method)

Copy link
Member

Choose a reason for hiding this comment

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

Return type is to be specified

* @see https://www.php.net/parse_ini_file
* @return bool
*/
public function getTypedMode()
Copy link
Member

Choose a reason for hiding this comment

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

Return type to be specified

* @see https://www.php.net/parse_ini_file
* @return int
*/
public function getScannerMode()
Copy link
Member

Choose a reason for hiding this comment

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

Return type to be specified

@jcsanyi
Copy link
Contributor Author

jcsanyi commented Sep 10, 2020

I added the type hinting you requested.

My biggest issue with the patch is that, in order to follow consistency with pre-existing code, setters/getters are used to enable this behaviour, instead of relying on the Reader\Ini constructor.

I agree - I was thinking I should add constructor support for all 3 options as a follow-up PR.

Signed-off-by: Jonathan Csanyi <jdc@csanyi.ca>
Signed-off-by: Jonathan Csanyi <jdc@csanyi.ca>
@weierophinney weierophinney changed the base branch from develop to 3.5.x February 11, 2021 14:06
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
- Removes annotations where typehints exist
- Use `self`, not class name as a return type
- Indent here/nowdocs (available since PHP 7.3)

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney added this to the 3.5.0 milestone Feb 11, 2021
@weierophinney weierophinney merged commit f91cd6f into laminas:3.5.x Feb 11, 2021
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