Issues (66)

src/helpers.php (3 issues)

Labels
Severity
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2017
6
 * @package laravel
7
 */
8
9
10
if( !function_exists( 'aiconfig' ) )
11
{
12
	/**
13
	 * Returns the configuration setting for the given key
14
	 *
15
	 * @param string $key Configuration key
16
	 * @param mixed $default Default value if the configuration key isn't found
17
	 * @return mixed Configuration value
18
	 */
19
	function aiconfig( $key, $default = null )
20
	{
21
		return app( '\Aimeos\Shop\Base\Config' )->get()->get( $key, $default );
0 ignored issues
show
The call to Illuminate\Container\Container::get() has too few arguments starting with id. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
		return app( '\Aimeos\Shop\Base\Config' )->/** @scrutinizer ignore-call */ get()->get( $key, $default );

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
22
	}
23
}
24
25
26
if( !function_exists( 'aitrans' ) )
27
{
28
	/**
29
	 * Translates the given message
30
	 *
31
	 * @param string $singular Message to translate
32
	 * @param array $params List of paramters for replacing the placeholders in that order
33
	 * @param string $domain Translation domain
34
	 * @param string $locale ISO language code, maybe combine with ISO currency code, e.g. "en_US"
35
	 * @return string Translated string
36
	 */
37
	function aitrans( $singular, array $params = array(), $domain = 'client', $locale = null )
38
	{
39
		$i18n = app( '\Aimeos\Shop\Base\Context' )->get()->getI18n( $locale );
0 ignored issues
show
The call to Illuminate\Container\Container::get() has too few arguments starting with id. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
		$i18n = app( '\Aimeos\Shop\Base\Context' )->/** @scrutinizer ignore-call */ get()->getI18n( $locale );

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
40
41
		return vsprintf( $i18n->dt( $domain, $singular ), $params );
42
	}
43
}
44
45
46
if( !function_exists( 'aitransplural' ) )
47
{
48
	/**
49
	 * Translates the given messages based on the number
50
	 *
51
	 * @param string $singular Message to translate
52
	 * @param string $plural Message for plural translations
53
	 * @param integer $number Count of items to chose the correct plural translation
54
	 * @param array $params List of paramters for replacing the placeholders in that order
55
	 * @param string $domain Translation domain
56
	 * @param string $locale ISO language code, maybe combine with ISO currency code, e.g. "en_US"
57
	 * @return string Translated string
58
	 */
59
	function aitransplural( $singular, $plural, $number, array $params = array(), $domain = 'client', $locale = null )
60
	{
61
		$i18n = app( '\Aimeos\Shop\Base\Context' )->get()->getI18n( $locale );
0 ignored issues
show
The call to Illuminate\Container\Container::get() has too few arguments starting with id. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

61
		$i18n = app( '\Aimeos\Shop\Base\Context' )->/** @scrutinizer ignore-call */ get()->getI18n( $locale );

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
62
63
		return vsprintf( $i18n->dn( $domain, $singular, $plural, $number ), $params );
64
	}
65
}
66