algoliasearch-client-php icon indicating copy to clipboard operation
algoliasearch-client-php copied to clipboard

File existance check for Version class

Open stawip opened this issue 12 years ago • 0 comments

Please add check for existance before trying to get value (line 34) to prevent "failed to open stream: No such file or directory" warning in some cases. Maybe simply something like this:

    $vpath = dirname( __FILE__ ) . "/../../composer.json";
    if ( file_exists($vpath) ) {

        $composerJson = file_get_contents( $vpath );
        if ( $composerJson != FALSE ) {
            $composer = json_decode( $composerJson );
            if ( $composer != NULL ) {
                self::$value = $composer->version;

                return self::$value;
            }
        }
    }

stawip avatar Nov 24 '14 08:11 stawip