idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
45,300 | protected function processDefinition ( $ countryCode , array $ definition ) { $ definition [ 'country_code' ] = $ countryCode ; $ definition += $ this -> getGenericDefinition ( ) ; $ definition [ 'required_fields' ] [ ] = AddressField :: GIVEN_NAME ; $ definition [ 'required_fields' ] [ ] = AddressField :: FAMILY_NAME ... | Processes the country s address format definition . |
45,301 | public static function match ( $ postalCode , $ includeRule , $ excludeRule = '' ) { $ matchIncluded = true ; if ( $ includeRule ) { $ matchIncluded = self :: matchRule ( $ postalCode , $ includeRule ) ; } $ matchExcluded = false ; if ( $ excludeRule ) { $ matchExcluded = self :: matchRule ( $ postalCode , $ excludeRul... | Checks whether the provided postal code matches the provided rules . |
45,302 | protected static function matchRule ( $ postalCode , $ rule ) { if ( substr ( $ rule , 0 , 1 ) == '/' && substr ( $ rule , - 1 , 1 ) == '/' ) { $ match = preg_match ( $ rule , $ postalCode ) ; } else { $ match = in_array ( $ postalCode , self :: buildList ( $ rule ) ) ; } return $ match ; } | Checks whether the provided postal code matches the provided rule . |
45,303 | protected static function buildList ( $ postalCodes ) { $ postalCodeList = [ ] ; foreach ( explode ( ',' , $ postalCodes ) as $ postalCode ) { $ postalCode = trim ( $ postalCode ) ; if ( strpos ( $ postalCode , ':' ) !== false ) { $ postalCodeRange = explode ( ':' , $ postalCode ) ; if ( is_numeric ( $ postalCodeRange ... | Builds a list of postal codes from the provided string . |
45,304 | public function getUsedFields ( ) { if ( empty ( $ this -> usedFields ) ) { $ this -> usedFields = [ ] ; foreach ( AddressField :: getAll ( ) as $ field ) { if ( strpos ( $ this -> format , '%' . $ field ) !== false ) { $ this -> usedFields [ ] = $ field ; } } } return $ this -> usedFields ; } | Gets the list of used fields . |
45,305 | public function getUsedSubdivisionFields ( ) { $ fields = [ AddressField :: ADMINISTRATIVE_AREA , AddressField :: LOCALITY , AddressField :: DEPENDENT_LOCALITY , ] ; $ fields = array_intersect ( $ fields , $ this -> getUsedFields ( ) ) ; $ fields = array_values ( $ fields ) ; return $ fields ; } | Gets the list of used subdivision fields . |
45,306 | protected function loadDefinitions ( $ locale ) { if ( ! isset ( $ this -> definitions [ $ locale ] ) ) { $ filename = $ this -> definitionPath . $ locale . '.json' ; $ this -> definitions [ $ locale ] = json_decode ( file_get_contents ( $ filename ) , true ) ; } return $ this -> definitions [ $ locale ] ; } | Loads the country definitions for the provided locale . |
45,307 | protected function hasData ( array $ parents ) { $ countryCode = $ parents [ 0 ] ; $ addressFormat = $ this -> addressFormatRepository -> get ( $ countryCode ) ; $ depth = $ addressFormat -> getSubdivisionDepth ( ) ; if ( $ depth == 0 ) { return false ; } $ hasData = true ; if ( count ( $ parents ) > 1 ) { $ grandparen... | Checks whether predefined subdivisions exist for the provided parents . |
45,308 | protected function loadDefinitions ( array $ parents ) { $ group = $ this -> buildGroup ( $ parents ) ; if ( isset ( $ this -> definitions [ $ group ] ) ) { return $ this -> definitions [ $ group ] ; } $ this -> definitions [ $ group ] = [ ] ; if ( $ this -> hasData ( $ parents ) ) { $ filename = $ this -> definitionPa... | Loads the subdivision definitions for the provided parents . |
45,309 | protected function processDefinitions ( array $ definitions ) { foreach ( $ definitions [ 'subdivisions' ] as $ code => & $ definition ) { $ definition [ 'country_code' ] = $ definitions [ 'country_code' ] ; if ( isset ( $ definitions [ 'locale' ] ) ) { $ definition [ 'locale' ] = $ definitions [ 'locale' ] ; } $ defin... | Processes the loaded definitions . |
45,310 | protected function buildGroup ( array $ parents ) { if ( empty ( $ parents ) ) { throw new \ InvalidArgumentException ( 'The $parents argument must not be empty.' ) ; } $ countryCode = array_shift ( $ parents ) ; $ group = strtoupper ( $ countryCode ) ; if ( $ parents ) { $ group .= str_repeat ( '-' , count ( $ parents... | Builds a group from the provided parents . |
45,311 | protected function createSubdivisionFromDefinitions ( $ code , array $ definitions ) { if ( ! isset ( $ definitions [ 'subdivisions' ] [ $ code ] ) ) { return null ; } $ definition = $ definitions [ 'subdivisions' ] [ $ code ] ; $ definitions += [ 'parents' => [ $ definitions [ 'country_code' ] ] , ] ; $ parents = $ de... | Creates a subdivision object from the provided definitions . |
45,312 | protected function insertValue ( $ value ) : void { $ currentItem = array_pop ( $ this -> stack ) ; if ( 'object' === $ currentItem [ 'type' ] ) { $ currentItem [ 'value' ] [ array_pop ( $ this -> keys ) ] = $ value ; } else { $ currentItem [ 'value' ] [ ] = $ value ; } $ this -> stack [ ] = $ currentItem ; } | based on whether that value is an array or an object . |
45,313 | public function value ( $ value ) : void { $ obj = array_pop ( $ this -> stack ) ; if ( ! empty ( $ this -> keys [ $ this -> level ] ) ) { $ obj [ $ this -> keys [ $ this -> level ] ] = $ value ; $ this -> keys [ $ this -> level ] = null ; } else { $ obj [ ] = $ value ; } $ this -> stack [ ] = $ obj ; } | Value may be a string integer boolean null . |
45,314 | public function forceEndDocument ( ) : void { if ( empty ( $ this -> stack ) ) { return ; } $ key = $ this -> keys ; for ( $ i = $ this -> level - 1 ; $ i > 0 ; -- $ i ) { $ value = array_pop ( $ this -> stack ) ; $ obj = array_pop ( $ this -> stack ) ; if ( ! empty ( $ key [ $ i ] ) ) { $ obj [ $ key [ $ i ] ] = $ val... | Forcefully finish the document end all objects and arrays and set final object to the json property . |
45,315 | public static function toString ( $ obj ) { return method_exists ( $ obj , '__toString' ) ? ( string ) $ obj : get_class ( $ obj ) . '@' . spl_object_hash ( $ obj ) ; } | Returns a string representation of an object . |
45,316 | public function getProxy ( $ className , array $ identifier ) { $ definition = isset ( $ this -> definitions [ $ className ] ) ? $ this -> definitions [ $ className ] : $ this -> getProxyDefinition ( $ className ) ; $ fqcn = $ definition -> proxyClassName ; $ proxy = new $ fqcn ( $ definition -> initializer , $ definit... | Gets a reference proxy instance for the entity of the given type and identified by the given identifier . |
45,317 | private function getProxyDefinition ( $ className ) { $ classMetadata = $ this -> metadataFactory -> getMetadataFor ( $ className ) ; $ className = $ classMetadata -> getName ( ) ; $ this -> definitions [ $ className ] = $ this -> createProxyDefinition ( $ className ) ; $ proxyClassName = $ this -> definitions [ $ clas... | Get a proxy definition for the given class name . |
45,318 | public function setPlaceholder ( $ name , $ placeholder ) { if ( ! is_string ( $ placeholder ) && ! is_callable ( $ placeholder ) ) { throw InvalidArgumentException :: invalidPlaceholder ( $ name ) ; } $ this -> placeholders [ $ name ] = $ placeholder ; } | Sets a placeholder to be replaced in the template . |
45,319 | private function generateProxyShortClassName ( ClassMetadata $ class ) { $ proxyClassName = ClassUtils :: generateProxyClassName ( $ class -> getName ( ) , $ this -> proxyNamespace ) ; $ parts = explode ( '\\' , strrev ( $ proxyClassName ) , 2 ) ; return strrev ( $ parts [ 0 ] ) ; } | Generates the proxy short class name to be used in the template . |
45,320 | private function generateLazyPropertiesDefaults ( ClassMetadata $ class ) { $ lazyPublicProperties = $ this -> getLazyLoadedPublicProperties ( $ class ) ; $ values = [ ] ; foreach ( $ lazyPublicProperties as $ key => $ value ) { $ values [ ] = var_export ( $ key , true ) . ' => ' . var_export ( $ value , true ) ; } ret... | Generates the array representation of lazy loaded public properties and their default values . |
45,321 | private function generateMagicGet ( ClassMetadata $ class ) { $ lazyPublicProperties = array_keys ( $ this -> getLazyLoadedPublicProperties ( $ class ) ) ; $ reflectionClass = $ class -> getReflectionClass ( ) ; $ hasParentGet = false ; $ returnReference = '' ; $ inheritDoc = '' ; if ( $ reflectionClass -> hasMethod ( ... | Generates the magic getter invoked when lazy loaded public properties are requested . |
45,322 | private function generateMethods ( ClassMetadata $ class ) { $ methods = '' ; $ methodNames = [ ] ; $ reflectionMethods = $ class -> getReflectionClass ( ) -> getMethods ( \ ReflectionMethod :: IS_PUBLIC ) ; $ skippedMethods = [ '__sleep' => true , '__clone' => true , '__wakeup' => true , '__get' => true , '__set' => t... | Generates decorated methods by picking those available in the parent class . |
45,323 | public function getProxyFileName ( $ className , $ baseDirectory = null ) { $ baseDirectory = $ baseDirectory ? : $ this -> proxyDirectory ; return rtrim ( $ baseDirectory , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . Proxy :: MARKER . str_replace ( '\\' , '' , $ className ) . '.php' ; } | Generates the Proxy file name . |
45,324 | private function isShortIdentifierGetter ( $ method , ClassMetadata $ class ) { $ identifier = lcfirst ( substr ( $ method -> getName ( ) , 3 ) ) ; $ startLine = $ method -> getStartLine ( ) ; $ endLine = $ method -> getEndLine ( ) ; $ cheapCheck = ( $ method -> getNumberOfParameters ( ) == 0 && substr ( $ method -> ge... | Checks if the method is a short identifier getter . |
45,325 | private function getLazyLoadedPublicProperties ( ClassMetadata $ class ) { $ defaultProperties = $ class -> getReflectionClass ( ) -> getDefaultProperties ( ) ; $ properties = [ ] ; foreach ( $ class -> getReflectionClass ( ) -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) as $ property ) { $ name = $ property -... | Generates the list of public properties to be lazy loaded with their default values . |
45,326 | public static function resolveFile ( $ proxyDir , $ proxyNamespace , $ className ) { if ( 0 !== strpos ( $ className , $ proxyNamespace ) ) { throw InvalidArgumentException :: notProxyClass ( $ className , $ proxyNamespace ) ; } $ classNameRelativeToProxyNamespace = substr ( $ className , strlen ( $ proxyNamespace ) ) ... | Resolves proxy class name to a filename based on the following pattern . |
45,327 | public static function register ( $ proxyDir , $ proxyNamespace , $ notFoundCallback = null ) { $ proxyNamespace = ltrim ( $ proxyNamespace , '\\' ) ; if ( ! ( null === $ notFoundCallback || is_callable ( $ notFoundCallback ) ) ) { throw InvalidArgumentException :: invalidClassNotFoundCallback ( $ notFoundCallback ) ; ... | Registers and returns autoloader callback for the given proxy dir and namespace . |
45,328 | private static function typeExists ( $ type , $ autoload = false ) { return class_exists ( $ type , $ autoload ) || interface_exists ( $ type , $ autoload ) || trait_exists ( $ type , $ autoload ) ; } | Checks whether a given type exists |
45,329 | protected function configureRoute ( Route $ route , \ ReflectionClass $ class , \ ReflectionMethod $ method , $ annot ) { $ classAnnot = $ this -> reader -> getClassAnnotation ( $ class , $ this -> routeAnnotationClass ) ; if ( $ classAnnot instanceof FrameworkExtraBundleRoute && $ service = $ classAnnot -> getService ... | Configures the _controller default parameter and eventually the HTTP method requirement of a given Route instance . |
45,330 | public function onKernelView ( GetResponseForControllerResultEvent $ event ) { $ controllerResult = $ event -> getControllerResult ( ) ; if ( ! $ controllerResult instanceof ResponseInterface ) { return ; } $ event -> setResponse ( $ this -> httpFoundationFactory -> createResponse ( $ controllerResult ) ) ; } | Do the conversion if applicable and update the response of the event . |
45,331 | public function getControllerArguments ( FilterControllerArgumentsEvent $ event ) { $ namedArguments = $ event -> getRequest ( ) -> attributes -> all ( ) ; $ argumentMetadatas = $ this -> argumentMetadataFactory -> createArgumentMetadata ( $ event -> getController ( ) ) ; $ controllerArguments = $ event -> getArguments... | Returns an associative array of the controller arguments for the event . |
45,332 | public function apply ( Request $ request , $ configurations ) { if ( \ is_object ( $ configurations ) ) { $ configurations = [ $ configurations ] ; } foreach ( $ configurations as $ configuration ) { $ this -> applyConverter ( $ request , $ configuration ) ; } } | Applies all converters to the passed configurations and stops when a converter is applied it will move on to the next configuration and so on . |
45,333 | private function applyConverter ( Request $ request , ParamConverter $ configuration ) { $ value = $ request -> attributes -> get ( $ configuration -> getName ( ) ) ; $ className = $ configuration -> getClass ( ) ; if ( \ is_object ( $ value ) && $ value instanceof $ className ) { return ; } if ( $ converterName = $ co... | Applies converter on request based on the given configuration . |
45,334 | public function add ( ParamConverterInterface $ converter , $ priority = 0 , $ name = null ) { if ( null !== $ priority ) { if ( ! isset ( $ this -> converters [ $ priority ] ) ) { $ this -> converters [ $ priority ] = [ ] ; } $ this -> converters [ $ priority ] [ ] = $ converter ; } if ( null !== $ name ) { $ this -> ... | Adds a parameter converter . |
45,335 | public function all ( ) { krsort ( $ this -> converters ) ; $ converters = [ ] ; foreach ( $ this -> converters as $ all ) { $ converters = array_merge ( $ converters , $ all ) ; } return $ converters ; } | Returns all registered param converters . |
45,336 | public function onKernelController ( FilterControllerEvent $ event ) { $ controller = $ event -> getController ( ) ; if ( ! \ is_array ( $ controller ) && method_exists ( $ controller , '__invoke' ) ) { $ controller = [ $ controller , '__invoke' ] ; } if ( ! \ is_array ( $ controller ) ) { return ; } $ className = $ th... | Modifies the Request object to apply configuration information found in controllers annotations like the template to render or HTTP caching configuration . |
45,337 | public function onKernelController ( FilterControllerEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( ! $ configuration = $ request -> attributes -> get ( '_cache' ) ) { return ; } $ response = new Response ( ) ; $ lastModifiedDate = '' ; if ( $ configuration -> getLastModified ( ) ) { $ lastModifiedDate ... | Handles HTTP validation headers . |
45,338 | public function onKernelResponse ( FilterResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( ! $ configuration = $ request -> attributes -> get ( '_cache' ) ) { return ; } $ response = $ event -> getResponse ( ) ; if ( ! \ in_array ( $ response -> getStatusCode ( ) , [ 200 , 203 , 300 , 301 , 302 , 3... | Modifies the response to apply HTTP cache headers when needed . |
45,339 | public function onKernelController ( FilterControllerEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ template = $ request -> attributes -> get ( '_template' ) ; if ( ! $ template instanceof Template ) { return ; } $ controller = $ event -> getController ( ) ; if ( ! \ is_array ( $ controller ) && method_exi... | Guesses the template name to render and its variables and adds them to the request object . |
45,340 | public function onKernelView ( GetResponseForControllerResultEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ template = $ request -> attributes -> get ( '_template' ) ; if ( ! $ template instanceof Template ) { return ; } if ( null === $ this -> twig ) { throw new \ LogicException ( 'You can not use the "@T... | Renders the template and initializes a new response object with the rendered template content . |
45,341 | private function getBundleForClass ( $ class ) { $ reflectionClass = new \ ReflectionClass ( $ class ) ; $ bundles = $ this -> kernel -> getBundles ( ) ; do { $ namespace = $ reflectionClass -> getNamespaceName ( ) ; foreach ( $ bundles as $ bundle ) { if ( 'Symfony\Bundle\FrameworkBundle' === $ bundle -> getNamespace ... | Returns the bundle name in which the given class name is located . |
45,342 | public function onKernelController ( FilterControllerEvent $ event ) { $ controller = $ event -> getController ( ) ; $ request = $ event -> getRequest ( ) ; $ configurations = [ ] ; if ( $ configuration = $ request -> attributes -> get ( '_converters' ) ) { foreach ( \ is_array ( $ configuration ) ? $ configuration : [... | Modifies the ParamConverterManager instance . |
45,343 | public function getProject ( ) { $ key = $ this -> getProjectId ( ) ; if ( empty ( $ key ) ) { return null ; } $ cacheKey = 'Cache.Project.' . $ key ; $ rtn = $ this -> cache -> get ( $ cacheKey , null ) ; if ( empty ( $ rtn ) ) { $ rtn = Factory :: getStore ( 'Project' , 'PHPCI' ) -> getById ( $ key ) ; $ this -> cach... | Get the Project model for this Build by Id . |
45,344 | public function setProject ( $ value ) { if ( $ value instanceof \ PHPCI \ Model \ Project ) { return $ this -> setProjectObject ( $ value ) ; } if ( is_array ( $ value ) && ! empty ( $ value [ 'id' ] ) ) { return $ this -> setProjectId ( $ value [ 'id' ] ) ; } return $ this -> setProjectId ( $ value ) ; } | Set Project - Accepts an ID an array representing a Project or a Project model . |
45,345 | protected function handleBareRepository ( Builder $ builder , $ reference , $ buildPath ) { $ gitConfig = parse_ini_file ( $ reference . '/config' , true ) ; if ( $ gitConfig [ 'core' ] [ 'bare' ] ) { $ cmd = 'mkdir %2$s; git --git-dir="%1$s" archive %3$s | tar -x -C "%2$s"' ; $ builder -> executeCommand ( $ cmd , $ re... | Check if this is a bare git repository and if so unarchive it . |
45,346 | protected function handleSymlink ( Builder $ builder , $ reference , $ buildPath ) { if ( is_link ( $ buildPath ) && is_file ( $ buildPath ) ) { unlink ( $ buildPath ) ; } $ builder -> log ( sprintf ( 'Symlinking: %s to %s' , $ reference , $ buildPath ) ) ; if ( ! symlink ( $ reference , $ buildPath ) ) { $ builder -> ... | Create a symlink if required . |
45,347 | protected function overrideSetting ( $ options , $ key ) { if ( isset ( $ options [ $ key ] ) && is_array ( $ options [ $ key ] ) ) { $ this -> { $ key } = $ options [ $ key ] ; } } | Override a default setting . |
45,348 | protected function processReport ( $ xmlString ) { $ xml = simplexml_load_string ( $ xmlString ) ; if ( $ xml === false ) { $ this -> phpci -> log ( $ xmlString ) ; throw new \ Exception ( 'Could not process PHPMD report XML.' ) ; } $ warnings = 0 ; foreach ( $ xml -> file as $ file ) { $ fileName = ( string ) $ file [... | Process PHPMD s XML output report . |
45,349 | protected function tryAndProcessRules ( ) { if ( ! empty ( $ this -> rules ) && ! is_array ( $ this -> rules ) ) { $ this -> phpci -> logFailure ( 'The "rules" option must be an array.' ) ; return false ; } foreach ( $ this -> rules as & $ rule ) { if ( strpos ( $ rule , '/' ) !== false ) { $ rule = $ this -> phpci -> ... | Try and process the rules parameter from phpci . yml . |
45,350 | protected function executePhpMd ( $ binaryPath ) { $ cmd = $ binaryPath . ' "%s" xml %s %s %s' ; $ path = $ this -> getTargetPath ( ) ; $ ignore = '' ; if ( count ( $ this -> ignore ) ) { $ ignore = ' --exclude ' . implode ( ',' , $ this -> ignore ) ; } $ suffixes = '' ; if ( count ( $ this -> suffixes ) ) { $ suffixes... | Execute PHP Mess Detector . |
45,351 | protected function getTargetPath ( ) { $ path = $ this -> phpci -> buildPath . $ this -> path ; if ( ! empty ( $ this -> path ) && $ this -> path { 0 } == '/' ) { $ path = $ this -> path ; return $ path ; } return $ path ; } | Get the path PHPMD should be run against . |
45,352 | protected function wasLastExecSuccessful ( $ errorCount ) { $ success = true ; if ( $ this -> allowed_warnings != - 1 && $ errorCount > $ this -> allowed_warnings ) { $ success = false ; return $ success ; } return $ success ; } | Returns a boolean indicating if the error count can be considered a success . |
45,353 | protected function setControllerView ( ) { if ( View :: exists ( $ this -> className ) ) { $ this -> controllerView = new View ( $ this -> className ) ; } else { $ this -> controllerView = new View \ Template ( '{@content}' ) ; } } | Set the view that this controller should use . |
45,354 | protected function setView ( $ action ) { if ( View :: exists ( $ this -> className . '/' . $ action ) ) { $ this -> view = new View ( $ this -> className . '/' . $ action ) ; } } | Set the view that this controller action should use . |
45,355 | public function execute ( ) { $ cmd = $ this -> executable ; if ( $ this -> args !== null ) { $ cmd .= " {$this->args}" ; } if ( $ this -> config !== null ) { $ cmd .= " -c '{$this->config}'" ; } if ( $ this -> directory !== null ) { $ dirPath = $ this -> phpci -> buildPath . DIRECTORY_SEPARATOR . $ this -> directory ;... | Run the Atoum plugin . |
45,356 | protected function getFlags ( ) { $ ignoreFlags = array ( ) ; foreach ( $ this -> ignore as $ ignoreDir ) { $ ignoreFlags [ ] = '--exclude "' . $ this -> phpci -> buildPath . $ ignoreDir . '"' ; } $ ignore = implode ( ' ' , $ ignoreFlags ) ; return array ( $ ignore ) ; } | Produce an argument string for PHP Parallel Lint . |
45,357 | public function summary ( ) { $ this -> response -> disableLayout ( ) ; $ projects = $ this -> projectStore -> getWhere ( array ( ) , 50 , 0 , array ( ) , array ( 'title' => 'ASC' ) ) ; $ this -> response -> setContent ( $ this -> getSummaryHtml ( $ projects ) ) ; return $ this -> response ; } | Ajax request for the project overview section of the dashboard . |
45,358 | protected function getSummaryHtml ( $ projects ) { $ summaryBuilds = array ( ) ; $ successes = array ( ) ; $ failures = array ( ) ; $ counts = array ( ) ; foreach ( $ projects as $ project ) { $ summaryBuilds [ $ project -> getId ( ) ] = $ this -> buildStore -> getLatestBuilds ( $ project -> getId ( ) ) ; $ count = $ t... | Generate the HTML for the project overview section of the dashboard . |
45,359 | protected function getGroupInfo ( ) { $ rtn = array ( ) ; $ groups = $ this -> groupStore -> getWhere ( array ( ) , 100 , 0 , array ( ) , array ( 'title' => 'ASC' ) ) ; foreach ( $ groups [ 'items' ] as $ group ) { $ thisGroup = array ( 'title' => $ group -> getTitle ( ) ) ; $ projects = $ this -> projectStore -> getBy... | Get a summary of the project groups we have and what projects they have in them . |
45,360 | public function getPluginClasses ( ) { $ arr = array ( ) ; foreach ( $ this -> pluginInformations as $ single ) { $ arr = array_merge ( $ arr , $ single -> getPluginClasses ( ) ) ; } return $ arr ; } | Returns an array of all the class names of plugins that have been loaded . |
45,361 | protected function checkJobLimit ( ) { $ this -> totalJobs ++ ; if ( $ this -> maxJobs != - 1 && $ this -> maxJobs <= $ this -> totalJobs ) { $ this -> stopWorker ( ) ; } } | Checks if this worker has done the amount of jobs it is allowed to do and if so tells it to stop after this job completes . |
45,362 | protected function verifyJob ( Job $ job , $ jobData ) { if ( empty ( $ jobData ) || ! is_array ( $ jobData ) ) { $ this -> pheanstalk -> delete ( $ job ) ; return false ; } if ( ! array_key_exists ( 'type' , $ jobData ) || $ jobData [ 'type' ] !== 'phpci.build' ) { $ this -> pheanstalk -> delete ( $ job ) ; return fal... | Checks that the job received is actually from PHPCI and has a valid type . |
45,363 | public function getBuild ( ) { $ key = $ this -> getBuildId ( ) ; if ( empty ( $ key ) ) { return null ; } $ cacheKey = 'Cache.Build.' . $ key ; $ rtn = $ this -> cache -> get ( $ cacheKey , null ) ; if ( empty ( $ rtn ) ) { $ rtn = Factory :: getStore ( 'Build' , 'PHPCI' ) -> getById ( $ key ) ; $ this -> cache -> set... | Get the Build model for this BuildError by Id . |
45,364 | public function setBuild ( $ value ) { if ( $ value instanceof \ PHPCI \ Model \ Build ) { return $ this -> setBuildObject ( $ value ) ; } if ( is_array ( $ value ) && ! empty ( $ value [ 'id' ] ) ) { return $ this -> setBuildId ( $ value [ 'id' ] ) ; } return $ this -> setBuildId ( $ value ) ; } | Set Build - Accepts an ID an array representing a Build or a Build model . |
45,365 | protected function getStatus ( $ projectId ) { $ branch = $ this -> getParam ( 'branch' , 'master' ) ; try { $ project = $ this -> projectStore -> getById ( $ projectId ) ; $ status = 'passing' ; if ( ! $ project -> getAllowPublicStatus ( ) ) { return null ; } if ( isset ( $ project ) && $ project instanceof Project ) ... | Returns status of the last build |
45,366 | public function ccxml ( $ projectId ) { $ project = $ this -> projectStore -> getById ( $ projectId ) ; $ xml = new \ SimpleXMLElement ( '<Projects/>' ) ; if ( ! $ project instanceof Project || ! $ project -> getAllowPublicStatus ( ) ) { return $ this -> renderXml ( $ xml ) ; } try { $ branchList = $ this -> buildStore... | Displays projects information in ccmenu format |
45,367 | public function image ( $ projectId ) { $ style = $ this -> getParam ( 'style' , 'plastic' ) ; $ label = $ this -> getParam ( 'label' , 'build' ) ; $ optionalParams = [ 'logo' => $ this -> getParam ( 'logo' ) , 'logoWidth' => $ this -> getParam ( 'logoWidth' ) , 'link' => $ this -> getParam ( 'link' ) , 'maxAge' => $ t... | Returns the appropriate build status image in SVG format for a given project . |
45,368 | public function view ( $ projectId ) { $ project = $ this -> projectStore -> getById ( $ projectId ) ; if ( empty ( $ project ) ) { throw new NotFoundException ( 'Project with id: ' . $ projectId . ' not found' ) ; } if ( ! $ project -> getAllowPublicStatus ( ) ) { throw new NotFoundException ( 'Project with id: ' . $ ... | View the public status page of a given project if enabled . |
45,369 | public function execute ( ) { $ build = $ this -> phpci -> buildPath ; if ( $ this -> directory == $ build || empty ( $ this -> directory ) ) { return true ; } if ( is_dir ( $ this -> directory ) ) { $ cmd = 'rm -Rf "%s"' ; if ( IS_WIN ) { $ cmd = 'rmdir /S /Q "%s"' ; } return $ this -> phpci -> executeCommand ( $ cmd ... | Wipes a directory s contents |
45,370 | protected function getHandlers ( $ key ) { $ handlers = array ( ) ; if ( isset ( $ this -> config [ $ key ] ) ) { if ( is_callable ( $ this -> config [ $ key ] ) ) { $ handlers = call_user_func ( $ this -> config [ $ key ] ) ; } elseif ( is_array ( $ this -> config [ $ key ] ) ) { $ handlers = $ this -> config [ $ key ... | Return an array of enabled log handlers . |
45,371 | public function getErrorsForBuild ( $ buildId , $ since = null ) { $ query = 'SELECT * FROM build_error WHERE build_id = :build' ; if ( ! is_null ( $ since ) ) { $ query .= ' AND created_date > :since' ; } $ query .= ' LIMIT 15000' ; $ stmt = Database :: getConnection ( 'read' ) -> prepare ( $ query ... | Get a list of errors for a given build since a given time . |
45,372 | public function getErrorTotalForBuild ( $ buildId ) { $ query = 'SELECT COUNT(*) AS total FROM build_error WHERE build_id = :build' ; $ stmt = Database :: getConnection ( 'read' ) -> prepare ( $ query ) ; $ stmt -> bindValue ( ':build' , $ buildId , \ PDO :: PARAM_INT ) ; if ( $ stmt -> execute ( ) )... | Gets the total number of errors for a given build . |
45,373 | public function getIsNewError ( $ hash ) { $ query = 'SELECT COUNT(*) AS total FROM build_error WHERE `hash` = :errorhash' ; $ stmt = Database :: getConnection ( 'read' ) -> prepare ( $ query ) ; $ stmt -> bindValue ( ':errorhash' , $ hash , \ PDO :: PARAM_INT ) ; if ( $ stmt -> execute ( ) ) { $ res... | Check if a build error is new . |
45,374 | protected function processReport ( $ xmlString ) { $ xml = simplexml_load_string ( $ xmlString ) ; if ( $ xml === false ) { $ this -> phpci -> log ( $ xmlString ) ; throw new \ Exception ( Lang :: get ( 'could_not_process_report' ) ) ; } $ warnings = 0 ; foreach ( $ xml -> duplication as $ duplication ) { foreach ( $ d... | Process the PHPCPD XML report . |
45,375 | public function getGroup ( ) { $ key = $ this -> getGroupId ( ) ; if ( empty ( $ key ) ) { return null ; } $ cacheKey = 'Cache.ProjectGroup.' . $ key ; $ rtn = $ this -> cache -> get ( $ cacheKey , null ) ; if ( empty ( $ rtn ) ) { $ rtn = Factory :: getStore ( 'ProjectGroup' , 'PHPCI' ) -> getById ( $ key ) ; $ this -... | Get the ProjectGroup model for this Project by Id . |
45,376 | public function setGroup ( $ value ) { if ( $ value instanceof \ PHPCI \ Model \ ProjectGroup ) { return $ this -> setGroupObject ( $ value ) ; } if ( is_array ( $ value ) && ! empty ( $ value [ 'id' ] ) ) { return $ this -> setGroupId ( $ value [ 'id' ] ) ; } return $ this -> setGroupId ( $ value ) ; } | Set Group - Accepts an ID an array representing a ProjectGroup or a ProjectGroup model . |
45,377 | public function execute ( ) { try { $ opts = array ( PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION ) ; $ pdo = new PDO ( 'sqlite:' . $ this -> path , $ opts ) ; foreach ( $ this -> queries as $ query ) { $ pdo -> query ( $ this -> phpci -> interpolate ( $ query ) ) ; } } catch ( \ Exception $ ex ) { $ this -> phpci -... | Connects to SQLite and runs a specified set of queries . |
45,378 | public function execute ( ) { if ( ! defined ( 'ENABLE_SHELL_PLUGIN' ) || ! ENABLE_SHELL_PLUGIN ) { throw new \ Exception ( Lang :: get ( 'shell_not_enabled' ) ) ; } $ success = true ; foreach ( $ this -> commands as $ command ) { $ command = $ this -> phpci -> interpolate ( $ command ) ; if ( ! $ this -> phpci -> exec... | Runs the shell command . |
45,379 | public function setConfigArray ( $ config ) { if ( is_null ( $ config ) || ! is_array ( $ config ) ) { throw new \ Exception ( Lang :: get ( 'missing_phpci_yml' ) ) ; } $ this -> config = $ config ; } | Set the config array as read from phpci . yml |
45,380 | public function execute ( ) { $ this -> build -> setStatus ( Build :: STATUS_RUNNING ) ; $ this -> build -> setStarted ( new \ DateTime ( ) ) ; $ this -> store -> save ( $ this -> build ) ; $ this -> build -> sendStatusPostback ( ) ; $ success = true ; $ previous_build = $ this -> build -> getProject ( ) -> getPrevious... | Run the active build . |
45,381 | protected function setupBuild ( ) { $ this -> buildPath = $ this -> build -> getBuildPath ( ) ; $ this -> interpolator -> setupInterpolationVars ( $ this -> build , $ this -> buildPath , PHPCI_URL ) ; $ this -> commandExecutor -> setBuildPath ( $ this -> buildPath ) ; if ( ! $ this -> build -> createWorkingCopy ( $ thi... | Set up a working copy of the project for building . |
45,382 | private function buildPluginFactory ( Build $ build ) { $ pluginFactory = new PluginFactory ( ) ; $ self = $ this ; $ pluginFactory -> registerResource ( function ( ) use ( $ self ) { return $ self ; } , null , 'PHPCI\Builder' ) ; $ pluginFactory -> registerResource ( function ( ) use ( $ build ) { return $ build ; } ,... | Returns a configured instance of the plugin factory . |
45,383 | public static function findConfigFile ( $ buildPath ) { if ( file_exists ( $ buildPath . 'phpunit.xml' ) ) { return 'phpunit.xml' ; } if ( file_exists ( $ buildPath . 'tests' . DIRECTORY_SEPARATOR . 'phpunit.xml' ) ) { return 'tests' . DIRECTORY_SEPARATOR . 'phpunit.xml' ; } if ( file_exists ( $ buildPath . 'phpunit.xm... | Try and find the phpunit XML config file . |
45,384 | protected function runConfigFile ( $ configPath ) { if ( is_array ( $ configPath ) ) { return $ this -> recurseArg ( $ configPath , array ( $ this , "runConfigFile" ) ) ; } else { if ( $ this -> runFrom ) { $ curdir = getcwd ( ) ; chdir ( $ this -> phpci -> buildPath . DIRECTORY_SEPARATOR . $ this -> runFrom ) ; } $ ph... | Run the tests defined in a PHPUnit config file . |
45,385 | protected function runDir ( $ directory ) { if ( is_array ( $ directory ) ) { return $ this -> recurseArg ( $ directory , array ( $ this , "runDir" ) ) ; } else { $ curdir = getcwd ( ) ; chdir ( $ this -> phpci -> buildPath ) ; $ phpunit = $ this -> phpci -> findBinary ( 'phpunit' ) ; $ cmd = $ phpunit . ' --tap %s "%s... | Run the PHPUnit tests in a specific directory or array of directories . |
45,386 | public function execute ( ) { $ this -> phpci -> quiet = true ; $ this -> phpci -> logExecOutput ( false ) ; foreach ( $ this -> directories as $ dir ) { $ this -> lintDirectory ( $ dir ) ; } $ this -> phpci -> quiet = false ; $ this -> phpci -> logExecOutput ( true ) ; $ errors = 0 ; $ warnings = 0 ; foreach ( $ this ... | Executes phptal lint |
45,387 | protected function lintDirectory ( $ path ) { $ success = true ; $ directory = new \ DirectoryIterator ( $ this -> phpci -> buildPath . $ path ) ; foreach ( $ directory as $ item ) { if ( $ item -> isDot ( ) ) { continue ; } $ itemPath = $ path . $ item -> getFilename ( ) ; if ( in_array ( $ itemPath , $ this -> ignore... | Run phptal lint against a directory of files . |
45,388 | protected function lintFile ( $ path ) { $ success = true ; list ( $ suffixes , $ tales ) = $ this -> getFlags ( ) ; $ lint = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR ; $ lint .= 'vendor' . DIRECTORY_SEPARATOR . 'phptal' . DIRECTORY_SEPARATOR . 'phptal' . DIRE... | Run phptal lint against a specific file . |
45,389 | protected function getFlags ( ) { $ tales = '' ; if ( ! empty ( $ this -> tales ) ) { $ tales = ' -i ' . $ this -> phpci -> buildPath . $ this -> tales ; } $ suffixes = '' ; if ( count ( $ this -> suffixes ) ) { $ suffixes = ' -e ' . implode ( ',' , $ this -> suffixes ) ; } return array ( $ suffixes , $ tales ) ; } | Process options and produce an arguments string for PHPTAL Lint . |
45,390 | public function isRunning ( $ pid ) { $ lastLine = exec ( sprintf ( 'tasklist /fi "PID eq %d" /nh /fo csv 2>nul:' , $ pid ) ) ; $ record = str_getcsv ( $ lastLine ) ; return isset ( $ record [ 1 ] ) && intval ( $ record [ 1 ] ) === $ pid ; } | Check if the process is running using the tasklist command . |
45,391 | public function execute ( ) { $ success = true ; foreach ( $ this -> env_vars as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ env_var = is_array ( $ value ) ? key ( $ value ) . '=' . current ( $ value ) : $ value ; } else { $ env_var = "$key=$value" ; } if ( ! putenv ( $ this -> phpci -> interpolate ( $ env_var... | Adds the specified environment variables to the builder environment |
45,392 | protected function loadPluginInfo ( ) { if ( $ this -> pluginInfo !== null ) { return ; } $ this -> pluginInfo = array ( ) ; foreach ( $ this -> composerPackages as $ package ) { $ this -> addPluginsFromPackage ( $ package ) ; } } | Load a list of available plugins from the installed composer packages . |
45,393 | private function getInternalID ( $ type = null , $ name = null ) { $ type = $ type ? : "" ; $ name = $ name ? : "" ; return $ type . "-" . $ name ; } | Get an internal resource ID . |
45,394 | protected function cloneByHttp ( Builder $ builder , $ cloneTo ) { return $ builder -> executeCommand ( 'hg clone %s "%s" -r %s' , $ this -> getCloneUrl ( ) , $ cloneTo , $ this -> getBranch ( ) ) ; } | Use a HTTP - based Mercurial clone . |
45,395 | protected function cloneBySsh ( Builder $ builder , $ cloneTo ) { $ keyFile = $ this -> writeSshKey ( ) ; $ cmd = 'hg clone --ssh "ssh -i ' . $ keyFile . '" %s "%s"' ; $ success = $ builder -> executeCommand ( $ cmd , $ this -> getCloneUrl ( ) , $ cloneTo ) ; if ( $ success ) { $ success = $ this -> postCloneSetup ( $ ... | Use an SSH - based Mercurial clone . |
45,396 | public function execute ( ) { $ addresses = $ this -> getEmailAddresses ( ) ; if ( count ( $ addresses ) == 0 ) { return false ; } $ buildStatus = $ this -> build -> isSuccessful ( ) ? "Passing Build" : "Failing Build" ; $ projectName = $ this -> build -> getProject ( ) -> getTitle ( ) ; try { $ view = $ this -> getMai... | Send a notification mail . |
45,397 | public function sendSeparateEmails ( array $ toAddresses , $ subject , $ body ) { $ failures = 0 ; $ ccList = $ this -> getCcAddresses ( ) ; foreach ( $ toAddresses as $ address ) { if ( ! $ this -> sendEmail ( $ address , $ ccList , $ subject , $ body ) ) { $ failures ++ ; } } return $ failures ; } | Send an email to a list of specified subjects . |
45,398 | protected function getEmailAddresses ( ) { $ addresses = array ( ) ; $ committer = $ this -> build -> getCommitterEmail ( ) ; if ( isset ( $ this -> options [ 'committer' ] ) && ! empty ( $ committer ) ) { $ addresses [ ] = $ committer ; } if ( isset ( $ this -> options [ 'addresses' ] ) ) { foreach ( $ this -> options... | Get the list of email addresses to send to . |
45,399 | protected function getCcAddresses ( ) { $ ccAddresses = array ( ) ; if ( isset ( $ this -> options [ 'cc' ] ) ) { foreach ( $ this -> options [ 'cc' ] as $ address ) { $ ccAddresses [ ] = $ address ; } } return $ ccAddresses ; } | Get the list of email addresses to CC . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.