align-toparrow-leftarrow-rightbackbellblockcalendarcamerachatcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-crosscrosseditfacebookglobegoogleimagesinstagramlocation-pinmagnifying-glassmailmoremuplabelShape 3 + Rectangle 1outlookpersonplusImported LayersImported LayersImported Layersshieldstartwitteryahoo

Re: [php-49] Type hinting exp4ect class if string is used?

From: Jd D.
Sent on: Tuesday, February 12, 2013 10:43 AM
Jeremy what do you think of doing this then (maybe?)

    public function setIniSection(array $sections = array())
    {
        if ($iniArray = parse_ini_file((self::CONFIG_INI), true))
        {
            if (0 >= count($sections))
            {
                foreach ($sections as $section) {
                    foreach ($iniArray[$section] as $definitor => $value) {
                        if (!defined($definitor)) define($definitor, $value);
                    }
                }
                return true;
            }
           self::_throwException('Empty array passed as arg on (' . __LINE__ . ') of ' . __FILE__);
        }
       self::_throwException('Configuration Ini does not exist: '. self::CONFIG_INI);
    }



On Tue, Feb 12, 2013 at 10:30 AM, Jd Daniel <[address removed]> wrote:
Yeah I figured =( *sigh... C'mon php 6!!!


On Tue, Feb 12, 2013 at 10:22 AM, Jeremy Cole Lindblom <[address removed]> wrote:
You can't typehint on scalars... *cries*.

--
Jeremy Lindblom
PHP Software Development Engineer & Web Application Developer
Amazon Web Services – AWS SDK for PHP

@jeremeamia • https://github.com/jeremeamia


On Tue, Feb 12, 2013 at 10:18 AM, Jd Daniel <[address removed]> wrote:
Sounds familiar guys?

if I try public function setIniSection(string $section)
it expects a Class named string =( Any info? Code below even though it doesn't matter...


    /**
     * Cannibalize an Ini file and create definitions of a sub-selected content
     * @param   string $section   subsection of ini file
     * @return  definitions
     */
    public function setIniSection($section)
    {

        // fast primitive, because type hinting thinks string $section
        // means instanceof Class string =P Really PHP, really?
        if (!is_string($section)) trigger_error('Argument passed myst be of type string ' . gettype($section) . ' passed.');

        if (! file_exists(self::CONFIG_INI) {
            self::_throwException("Configuration Ini does not exist: " __DIR__ .'/' . self::CONFIG_INI);
        }

        $iniArray = parse_ini_file((__DIR__ . '/' . self::CONFIG_INI), true);
        foreach ($iniArray[$section] as $definitor => $value) {
            if (!defined($definitor)) define($definitor, $value);
        }

        return true;
    }

--
Jd Daniel || ERADO
Senior Applications Architect
7901 Delridge Way SW #36D, Seattle

C.    [masked]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jd Daniel ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Jd Daniel, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jeremy Cole Lindblom ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Jeremy Cole Lindblom, visit his/her member profile



--
Jd Daniel || ERADO
Senior Applications Architect
7901 Delridge Way SW #36D, Seattle

C.    [masked]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jd Daniel ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Jd Daniel, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]



--
Jd Daniel || ERADO
Senior Applications Architect
7901 Delridge Way SW #36D, Seattle

C.   [masked]

Our Sponsors

  • TUNE

    Meeting space and food

  • PluralSight

    PluralSight subscriptions for developer training

  • Siteground

    Information coming Soon

  • O'Reilly

    Disc Code: PCBW is good for 40% off print and 50% off ebooks and videos

  • JetBrains PhpStorm

    Occasional free licenses to raffle off at meetups

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy